Calculate method invoked with a smaller index than in previous invocation

Vibra since: 01 Aug 2022;

  01 Aug 2022, 20:47
Calculate method invoked with a smaller index than in previous invocation

Hi,

I noticed this behaviour when testing my indicator on a EURUSD 5tick chart. It's a recursive indicator which depends on previous calculated value, so the effect of this behaviour is that the previous value (which should be static after the bar is formed) is changed.

Here's some code to demostrate what I mean. It's not a big deal because I could easily circumvent this by checking if index < _lastIndex and then return without doing the calculation. But I'd like to highlight this anyways in case it's a bug.

int _lastIndex = -1;

public override void Calculate(int index)
{
    if(index < _lastIndex)
        Debug.WriteLine(index + " - incorrect?");
    else
        Debug.WriteLine(index);

    _lastIndex = index;
}

Best regards,
Vibra

PanagiotisCharalampous's avatar

PanagiotisCharalampous since: 13 Jan 2017;

  02 Aug 2022, 08:31

Hi Vibra,

Thanks for reporting this problem. We managed to reproduce it and we will have a look at it.

Best Regards,

Panagiotis 

Join us on Telegram and Facebook

Head of Community Management at cTrader