I'm trying to make a strategy based on a custom indicator. But I get an error when I run the strategy analyzer.
"Indicator "CustomIndicator": Error on calling 'OnStateChange' method: Object reference not set to an instance of an object."
The strategy analyzer gets to the piece of code I have highlighted in bold.
I have a piece of my code and hope that someone can help me.
#region Variables
private int upSize = 7;
private UpStyle upType = UpStyle.Standard;
private int dtbStrength = 15;
private Series<double> upTrend;
private CustomIndicator cusInd;
#endregion
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"High volume with hammer in downwaves or shooting star in upwaves.";
Name = "ReversalVolumeCandle";
Calculate = Calculate.OnBarClose;
EntriesPerDirection = 1;
EntryHandling = EntryHandling.AllEntries
IsExitOnSessionCloseStrategy = true;
ExitOnSessionCloseSeconds = 30;
IsFillLimitOnTouch = false;
MaximumBarsLookBack = MaximumBarsLookBack.TwoHundredFiftySix;
OrderFillResolution = OrderFillResolution.Standard;
Slippage = 0;
StartBehavior = StartBehavior.WaitUntilFlat;
TimeInForce = TimeInForce.Gtc;
TraceOrders = false;
RealtimeErrorHandling = RealtimeErrorHandling.StopCancelClose;
StopTargetHandling = StopTargetHandling.PerEntryExecution;
BarsRequiredToTrade = 0;
IsInstantiatedOnEachOptimizationIteration = true;
}
else if (State == State.Configure)
{
cusInd = CustomIndicator(UpStyle.Standard, 7, 15, false, true, true);
AddChartIndicator(cusInd);
}
}
Comment