How the backtester works - worldexplorer/SquareOne GitHub Wiki

How SquareOne’s backtester works:

  1. for every bar, 4 quotes are generated using 0.01% spread for Open, High, Low and Close (OLHC for white bar and OHLC for black bar);

  2. on each new bar and on each new quote, two strategy methods are invoked, where strategy developer is supposed to analyse bars/quotes and generate Buy/Sell orders;

  3. if strategy has generated a pending order (LimitOrder or StopOrder), on each new quote generated the Backtester.cs will check whether the next "planned" quote will go through any of the pending orders;

  4. if yes (one of the four "planned" quotes will break through the limit order), then one additional quote is generated specifically to trigger each matching limit order; and so on until there is no "obstacles" on our way to the "planned" quote (OHLC);

  5. when each pending order is filled, Script.OnAlertFilledCallback() is invoked, and may be others :)

I’m sorry but there is no better documentation available than (clean) source code; for the details just eyeball the Backtester implementation: https://github.com/worldexplorer/SquareOne/blob/v1.0-dev/Sq1.Core/Backtesting/Backtester.cs

for SpreadModelling and "0.01% spread" hardcoded, check https://github.com/worldexplorer/SquareOne/blob/v1.0-dev/Sq1.Core/Backtesting/BacktestSpreadModelerPercentage.cs

for the methods to be overriden in userland Script-derived class, search for "#region methods to override in derived strategy" here: https://github.com/worldexplorer/SquareOne/blob/v1.0-dev/Sq1.Core/StrategyBase/Script.cs

⚠️ **GitHub.com Fallback** ⚠️