Login Page - Create Account

Support Board


Date/Time: Sun, 02 Feb 2025 06:56:15 +0000



Post From: sc.Index off by 1 on candle open on backtest replay

[2019-08-24 03:04:53]
User806682 - Posts: 19
Hello,

Wondering if this is a bug or expected behavior.

I have a study that will execute an order on the candle open, given that previous candle patterns match certain parameters. This works most of the time. But in rare cases, I find that sc.Index is off by 1, meaning it's not at the correct index for the new candle, while sc.ArraySize has been increased by 1 compared to the previous candle.
This only happens sometimes during backtest replay and only once at the beginning of some candles.

I'm currently handling it by doing this:

if (sc.Index != sc.ArraySize-1) {
  return;
}

Thanks.