Custom indicator is not responsive in cBot backtest

Created at 05 Mar 2024, 16:46
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
WA

wagmi.fund

Joined 05.12.2022

Custom indicator is not responsive in cBot backtest
05 Mar 2024, 16:46


Hello everyone, I am having a problem for some days now and I don't really know what to do about it.
I have written a cTrader Custom Indicator that has two outputs:

[Output("Nearest Long Level")]
public IndicatorDataSeries NearestLongLevelOutput { get; set; }
        
[Output("Nearest Short Level")]
public IndicatorDataSeries NearestShortLevelOutput { get; set; }

All good for now, in the Calculate() function of the indicator I update these two values on each bar:

double NearestLongLevel = NearestLongLevels.Count() > 0 ? NearestLongLevels.Max() : (Bars.LowPrices[index] - 1000);
double NearestShortLevel = NearestShortLevels.Count() > 0 ? NearestShortLevels.Min() : (Bars.HighPrices[index] + 1000);


NearestLongLevelOutput[index] = NearestLongLevel;
NearestShortLevelOutput[index] = NearestShortLevel;

 

When I try to use this indicator in a cBot in the backtest the Indicator is not responsive. Meaning it calculates level only when the backtest starts but then it stops updating values with each candle forming.

How can I resolve this?

Thanks

 


@wagmi.fund
Replies

PanagiotisCharalampous
06 Mar 2024, 06:44

Hi there,

It is better to share the complete indicator code so that somebody can help you with this.

Best regards,

Panagiotis


@PanagiotisCharalampous