• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Configure State hit twice

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    Configure State hit twice

    Hi. We are using NT 8.0.18.1 64-bit and while developing our strategy we noticed that the Configure state is being hit twice and running our code twice.

    We've tested this with the sample strategy SampleAtmStrategy.cs and updated OnStateChange code to be this:

    PHP Code:
    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());
        }

    then added SampleAtmStrategy, pressed OK, and the output is this:

    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.

    #2
    Hello cmarkb,

    I just wanted to make a quick reply to let you know we are looking into this. Once I have more details I will reply back here.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello cmarkb,

      After speaking with QA it appears this is expected although not documented as an expectation. State.Configure seems to also be called multiple times like SetDefaults when used from a chart despite the help guide noting it should only be run once. The note we have about this happening for SetDefaults does not include Configure specifically which creates some confusion. There are cases where it does get executed more than once like SetDefaults, however the other executions are from the menu instances, not the chart instance. For one time actions, I would suggest moving what you can to State.DataLoaded to avoid this.

      Was there a more specific example you can provide which is affected by this being called more than once? Are you seeing a specific NinjaScript property that requires State.Configure failing due to this, or was this for your own logic and uses?



      I look forward to being of further assistance.
      JesseNinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by learningnt, Today, 10:52 PM
      0 responses
      2 views
      0 likes
      Last Post learningnt  
      Started by CandySNK, Today, 10:24 PM
      1 response
      5 views
      0 likes
      Last Post jiva12
      by jiva12
       
      Started by user1986, Today, 07:28 PM
      2 responses
      11 views
      0 likes
      Last Post NinjaTrader_EricB  
      Started by ericson, Today, 08:14 PM
      0 responses
      7 views
      0 likes
      Last Post ericson
      by ericson
       
      Started by jertrade, Today, 06:57 PM
      0 responses
      5 views
      0 likes
      Last Post jertrade  
      Working...
      X