We've tested this with the sample strategy SampleAtmStrategy.cs and updated OnStateChange code to be this:
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = NinjaTrader.Custom.Resource.NinjaScriptStrategyDescriptionSampleATMStrategy;
Name = NinjaTrader.Custom.Resource.NinjaScriptStrategyNameSampleATMStrategy;
// This strategy has been designed to take advantage of performance gains in Strategy Analyzer optimizations
// See the Help Guide for additional information
IsInstantiatedOnEachOptimizationIteration = false;
}
else if (State == State.Configure)
{
Print(DateTime.Now.ToString() + " " + guid + " " + State.ToString());
}
else if (State == State.Active)
{
Print(DateTime.Now.ToString() + " " + guid + " " + State.ToString());
}
else if (State == State.DataLoaded)
{
Print(DateTime.Now.ToString() + " " + guid + " " + State.ToString());
}
}
28/06/2019 8:11:54 PM 89ff26c5-0212-4410-8e32-127baafbb9d2 Configure
28/06/2019 8:11:54 PM 3808acfa-c442-4158-9b07-597ccdfa8871 Configure
28/06/2019 8:11:54 PM 3808acfa-c442-4158-9b07-597ccdfa8871 DataLoaded
Enabling NinjaScript strategy 'Sample ATM strategy/150544919' : On starting a real-time strategy - StartBehavior=WaitUntilFlat EntryHandling=All entries EntriesPerDirection=1 StopTargetHandling=By strategy position ErrorHandling=Stop strategy, cancel orders, close positions ExitOnSessionClose=True / triggering 30 seconds before close SetOrderQuantityBy=Strategy ConnectionLossHandling=Recalculate DisconnectDelaySeconds=10 CancelEntriesOnStrategyDisable=False CancelExitsOnStrategyDisable=False Calculate=On bar close IsUnmanaged=False MaxRestarts=4 in 5 minutes
Is there a way so that Configure will only be run once? Thanks.
Comment