Algorithmic Trading Platform & FIX API Solutions

QuantXpress provides trading APIs, FIX protocol solutions, algorithmic trading software, and low latency trading systems.

Our platform supports automated trading, market data APIs, and high-frequency trading infrastructure for developers and institutions.

Trading API and FIX Protocol Solutions

Build scalable trading systems using our FIX engine, market data APIs, and execution management systems.

Algorithmic Trading Platform FIX Protocol API Market Data API

Your First Strategy with BlitzTrader

8 min read • Technical Article

BlitzTrader is a high-performance framework engineered for the rapid development, testing, and live execution of algorithmic trading strategies. By abstracting away the "plumbing" of institutional trading, BlitzTrader allows quants and developers to bypass infrastructure intricacies and connectivity challenges, focusing their energy entirely on alpha generation.

With a C#-based, event-driven SDK, you can translate complex trading ideas into executable code with remarkable ease. What often takes traditional institutions months to move from research to production can be achieved within BlitzTrader in just a few days.

Key Benefits

Benefit Description
Standardized Lifecycle The BlitzTrader platform standardizes the entire development lifecycle through a robust set of primitives and a professional-grade SDK.
Native C# Environment Because both the core platform and the SDK are engineered in C#, you have the full power of a high-level, object-oriented language at your disposal.
Modular Plug-in Architecture Your strategy operates as a modular "plug-in" that integrates directly into the Blitz execution ecosystem.
Production-Ready Performance High-performance server-side execution is designed specifically for professional trading environments.

Building a SuperTrend-Based Trading Strategy

To demonstrate the ease of use, let's build a simple single-instrument strategy based on the SuperTrend indicator.

Strategy Logic

Condition Action
Closing price crosses above the SuperTrend upper band Buy (Long Entry) – Signals a potential uptrend
Closing price crosses below the SuperTrend lower band Sell (Short Entry) – Signals a strong downtrend

Data Source: 5-minute candlestick bars

Exit Conditions

The strategy automatically exits the position when any of the following conditions are met:

Exit Condition Description
MTM > MaxProfit Position has reached the profit target
MTM < MaxLoss Position has hit the stop-loss limit
TimeNum > ExitTime Current time exceeds the predefined exit time

Runtime Flexibility

All three exit parameters—MaxProfit, MaxLoss, and ExitTime—are configurable as input parameters. Traders can modify these values at runtime without recompiling or restarting the strategy.

This example demonstrates how easy it is to transform a technical trading rule into executable strategy code using BlitzTrader.

Core Components and Basic Structure

Every strategy in BlitzTrader inherits from StrategyBase, which provides access to the full platform lifecycle, market data, order events, and finer control.

Typical structure

public class MainStrategy : QX.Blitz.Core.StrategyBase 
{
}

Strategy Registration

Strategies use class-level attributes to supply metadata. This "Identity Card" allows the platform to discover, categorize, and manage versions of your strategy automatically.

A strategy is typically decorated as follows:

[StrategyAttribute("{28704030-AFFB-4C7A-A715-0B9A19BC4F90}", "PreC", "PreC", "X1", "QXT")] 
public class MainStrategy : QX.Blitz.Core.StrategyBase 
{ 
}

The StrategyAttribute defines the following information:

By adopting attribute-based registration, BlitzTrader enables seamless strategy discovery, automated deployment, controlled version management, and centralized lifecycle administration across all trading strategies.

Market-Agnostic Instruments (IVObject)

BlitzTrader uses Instrument Variable Objects (IVObjects) to decouple logic from specific symbols. Instead of hardcoding "RELIANCE", you define a variable that is mapped to a real instrument only at deployment. BlitzTrader then maintains this mapping throughout the entire lifecycle of the strategy instance.

Example:

private IVObject _ivInstrument = new IVObject(
    "FuturesIV",
    "Futures Instrument",
    true,
    InstrumentType.Futures | InstrumentType.Equity,
    MarketDataType.All,
    OrderEventType.All);

What this defines:

By using IVObject, BlitzTrader separates strategy logic from instrument configuration, making strategies more portable, scalable, and easier to operate in live markets.

Input Parameters: Runtime Control

Allow runtime customization (e.g., changing OrderQuantity on the fly).

Example:

[StrategyParameter("BarCompression", "3", "Candle Bar Compression")]
private int Input_BarCompression = 3;

[StrategyParameter("OrderQuantity", "1", "Order Quantity to trade")]
private int Input_OrderQuantity = 1;

[StrategyParameter("ExitTimeNum", "1520", "Squareoff position after this point and no new trade.")]
private int Input_ExitTimeNum = 1520;

Published Parameters: Real-Time Monitoring

While input parameters handle "control," Published Parameters handle "visibility." These attributes allow the strategy to push internal calculations, indicator values, or any statistics to the trading dashboard in real-time.

// Streams the live SuperTrend value to the dashboard for visual display
[StrategyPublishParameter("ST", DefaultValue = 0, Description = "Current SuperTrend Value")]
private double Output_SuperTrend = 0;

Following are some important override methods need to implement for Strategy logic.

protected override void OnInitialize() Called once to set up indicators and helper classes
protected override bool OnStart(out string errorString) Triggered when the strategy moves to a live state after explicit start from the dashboard.
protected override void OnStopping() Called when the strategy is stopped. No orders will flow after this point.
public override Version BuildVersion Assigns the build version of the strategy code
public override IVObject[] IVObjects Returns all instrument variables defined in the strategy.
public override bool ValidateInstrumentAssignments(KeyValuePair[] ivObjetToInstrumentMap, out string errorString) Called once during strategy instance creation to validate that the instrument attached to a variable is appropriate for the strategy logic.
protected override bool ValidateStrategyParameter(string parameterName, object paramterValue, out string errorString) Called when a user changes an input parameter; checks whether the change should be accepted based on proper value assignment.
protected override void OnMarketDataEvent(StrategyMarketDataEventArgs eventArgs) Main event called when any subscribed instrument’s market data price changes
protected override void OnOrderAccepted(IVObject ivObject, OrderAcceptedEventArgs orderAcceptedEventArgs) Called when an order is accepted by the exchange.
protected override void OnOrderRejected(IVObject ivObject, OrderRejectedEventArgs eventArgs) Called when an order is rejected by the exchange, internal OMS validation, or RMS.
protected override void OnTrade(IVObject ivObject, TradeDataEventArgs eventArgs) Called when the instrument is traded.

Helper Classes

IVInfo

A helper class initialized once for every IVObject. It provides access to important properties related to the instrument, real-time market data, and position statistics at any point in the program. Typically initialized in OnInitialize().

IVInfo ivInfo = base.GetIVInfo(_ivInstrument);

int lotSize = ivInfo.IVInstrument.Instrument.LotSize;
double currentLTP = ivInfo.MarketDataContainer.LastPrice;
int netPosition = ivInfo.Statistics.NetPosition;

IOrderCommandEx

This helper class manages order commands with easy-to-use yet powerful control over execution. It allows you to define execution algorithms for price quoting and order slicing, and provides user-friendly functions like EnterLong(), EnterShort(), SetPosition(), and GoFlat() to manage instrument positions without worrying about order lifecycle management.

IOrderCommandEX orderCommandEx = CreateRunTimeIVObject(Options, orderQuantity);
orderCommandEx.EnterLong(0);

TimeDataSeries and Indicator

These helper classes handle technical indicators based on TimeDataSeries, which represents candlestick data of a user-defined timeframe (e.g., 5-minute bars).

TimeDataSeries tds = TimeDataSeries.GetMinutesBarCompression(300, BarType.HeikinAshi);
FillHistoricalData(tds);

IndicatorBase indicatorSuperTrend = IndicatorRegistrationManager.Instance.GetIndicator("Supertrend", tds);
indicatorSuperTrend.SetFieldValue("LengthPeriod", 10);
indicatorSuperTrend.SetFieldValue("Multiplier", 3);

tds.OnBarDataCompletedEvent += TimeDataSeries_OnBarDataCompletedEvent;

private static void OnBarDataCompletedEvent(Guid id, IBarData barData, int currentBarIndex)
{
    double previousClose = tds[currentBarIndex - 1];
    double currentSuperTrend = indicatorSuperTrend[currentBarIndex];

    if (currentSuperTrend > previousClose)
    {
        orderCommandEx.EnterLong(0);
    }

    if (orderCommandEx.IVInfo.Statistics.NetPosition > 0 && currentSuperTrend < previousClose)
    {
        orderCommandEx.GoFlat();
    }
}

Implementing Risk Management and Time-Based Exits

A critical part of any automated strategy is the exit logic. In BlitzTrader, you typically handle this within OnMarketDataEvent for repeated evaluation. The following code demonstrates how to monitor your Mark-to-Market (MTM) and force a position to "Go Flat" if risk thresholds are hit or the trading session ends.

protected override void OnMarketDataEvent(StrategyMarketDataEventArgs eventArgs)
{
    // Ensure we have an active position before running risk logic
    if (ivInfo.Statistics.NetPosition != 0)
    {
        // Parse the target exit time from the user-defined parameter
        TimeSpan targetExitTime = TimeSpan.ParseExact(InputExitTime, "hhmmss", null);

        // Calculate total MTM by combining Realized and Unrealized P&L
        double mtm = _ivInfo.RealizedMTM + _ivInfo.UnrealizedMTM;

        // Check if any exit conditions are met:
        // 1. MTM has hit the Stop Loss (MaxLoss)
        // 2. MTM has reached the Profit Target (MaxProfit)
        // 3. The current exchange time has exceeded the allowed trading window
        if (mtm < -1 * Input_MaxLoss ||
            mtm > Input_MaxProfit ||
            _ivInfo.MarketDataContainer.LastUpdateTimeDT.TimeOfDay > targetExitTime)
        {
            // Execute a GoFlat command to liquidate all positions immediately
            orderCommandEx.GoFlat();
            TraceLogInfo($"Risk Exit Triggered. MTM: {mtm}, Time: {_ivInfo.MarketDataContainer.LastUpdateTimeDT.TimeOfDay}");
        }
    }
}

Conclusion

By combining these modular components, BlitzTrader transforms strategy development from a complex engineering challenge into a streamlined workflow. You focus on the Alpha, and the platform handles the Execution.

The complete sample code for this strategy can be found at the following GitHub Link.