I'm working on a strategy that will detect a gap on the S&P500 index, then enter a trade depending on the gap direction. When I'm backtesting with downloaded Market Replay data, it seems to work fine. However, when I apply the strategy to a live chart it stops at one of my debug print statements. See the code below.
Is there something I need to change when checking if there's enough data? Or do I even need that line?
Thanks,
MJ
protected override void OnStateChange()
{
if (State == State.Historical)
{
}
else if (State == State.Configure)
{
// Add data series...
AddDataSeries("MES 06-24", BarsPeriodType.Second, 3);
AddDataSeries("^SP500", BarsPeriodType.Minute, 5);
}
}
protected override void OnBarUpdate()
{
// Check for the S&P 500 series to perform gap analysis...
if (BarsInProgress == 2)
// Ensure there's enough data
if (CurrentBars[0] < 1 || CurrentBars[2] < 1)
Print("Not enough data to analyze.")
return; // Not enough data to analyze.

Comment