I have a strategy that computes a variable using Historical Bid/Ask Data Series:
private double variable;
if (State == State.Configure)
{
AddDataSeries(null, BarsPeriodType.Tick, 1, MarketDataType.Last);
AddDataSeries(null, BarsPeriodType.Tick, 1, MarketDataType.Ask);
AddDataSeries(null, BarsPeriodType.Tick, 1, MarketDataType.Bid);
AddDataSeries(null, BarsPeriodType.Minute, 1);
}
protected override void OnBarUpdate()
{
region Volumetric Bar Updates
if (BarsInProgress == 0)
{
// helper function to plot the variable value on top of the bar
variable = 0;
}
#endregion
region Last Updates
else if (BarsInProgress == 1)
{
// logic to place orders based on variable value
}
#endregion
region Ask Update
else if (BarsInProgress == 2)
{
double price = Close[0];
double volume = Volume[0];
/*
Compute Variable here
*/
}
#endregion
region Bid Update
else if (BarsInProgress == 3)
{
double price = Close[0];
double volume = Volume[0];
/*
Compute Variable here
*/
}
#endregion
}
Historical/Strategy Analyzer:
Market Replay:
Please let me know where the discrepancy is happening, and if this is something that can be fixed via code or if this is just a backtesting problem.

Comment