I am encountering an issue with a strategy that uses a custom indicator (MyIndicator). When I add the indicator to my strategy using AddChartIndicator, the strategy compiles without any errors. However, when I try to enable the strategy on a chart, the "Enable" button remains checked for a few seconds and then automatically unchecks itself without any visible errors in the interface.
So my code is like:
public class StrategyTEST : Strategy
{
private MyIndicator myIndicator;
protected override void OnStateChange()
{
if (State == State.DataLoaded)
{
myIndicator = MyIndicator(
parameter1,
parameter2,
parameter3,
parameter4,
parameter5,
parameter6,
parameter7,
parameter8,
parameter9,
parameter10
);
AddChartIndicator(myIndicator);
}
}
protected override void OnBarUpdate()
{
if (CurrentBar < BarsRequiredToTrade)
return;
if (myIndicator != null)
{
double indicatorValue = myIndicator[0];
myIndicator.Update();
}
}
}
Also I just add this line
double indicatorValue = myIndicator[0];
any idea?

Comment