protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Strategy here.";
Name = "EquityEdgeSpike";
Calculate = Calculate.OnEachTick;
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 = 20;
// Disable this property for performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = true;
Multiplier = 2;
}
else if (State == State.Configure)
{
}
else if (State == State.DataLoaded)
{
ATR1 = ATR(Close, 14);
ATR1.Plots[0].Brush = Brushes.DarkCyan;
AddChartIndicator(ATR1);
SetTrailStop(@"Long", CalculationMode.Ticks, ATR1[0], false);
}
}
Setting SetTrailStop generate this error -
SetTrailStop(@"Long", CalculationMode.Ticks, ATR1[0], false);
Error on Calling OnStateChange method: Object reference not set to instance of an object

Comment