• 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

Strategie calculation does not work

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

    Strategie calculation does not work

    Hey guys,


    I have develop a automatic Strategy.
    In itself, it works great, but in some situations is no longer calculated.
    But I don´t know why.

    The amazing thing is that it does not work if I disable the strategy and reactivate it.
    The strategy is enabled but it is not calculated in Status.RealTime. It only calculated the Status.Historical

    But when I removed the strategy and restarted it will be calculated again in Status.Historical and Status.Realtime.


    Do you have an idea why the strategy does not switch to Status.RealTime and calculated?


    Best regards
    Martin


    #2
    Hello Martin89,

    Thanks for your post.

    When you apply the strategy, please check the "strategies" tab of the Ninjatrader control center and observe the color of the strategy name. If it is Green then the strategy is ready to place live trades. If it is yellow/orange then the strategy is not ready to place live trades and is waiting to complete that last historical trade. Please see, " Understanding the strategies tab" on this page of the help guide: https://ninjatrader.com/support/help...tegies_tab.htm

    If when you apply the strategy and check the name color in the strategies tab and the color is not green or yellow then look to make sure that the "enabled" check box on the right of that row is checked. If it is not checked and you then check it and it immediately unchecks, please look at the "Log" tab of the control center for any run time error messages related to the strategy.

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hey NinjaTrader_PaulH

      Thanks for your fast replay.

      I'm very familiar with the strategy tab and the different colors of the strategy names.

      When the error occurs everything is fine.
      The strategy is activated, the strategy name is green in the strategy tab and the historical filling process is complete without error messages in the log tab or in the output window.
      But in the Status.Realtime the strategy does not continue.
      No errors. No calculation.Nothing happens.


      I suspect that it's because I hide some standard NinjaTrader parameters in the UI.
      Can this be possible?


      I hide the following parameter in the propertie region:

      [Browsable(false)]
      public new Calculate Calculate {get;set;}

      [Browsable(false)]
      public new string Name {get;set;}

      [Browsable(false)]
      public new MaximumBarsLookBack MaximumBarsLookBack {get;set;}

      [Browsable(false)]
      public new int BarsRequiredToTrade {get;set;}

      [Browsable(false)]
      public new StartBehavior StartBehavior {get;set;}

      [Browsable(false)]
      public new OrderFillResolution OrderFillResolution {get;set;}

      [Browsable(false)]
      public new bool IsFillLimitOnTouch {get;set;}

      [Browsable(false)]
      public new double Slippage {get;set;}

      [Browsable(false)]
      public new int EntriesPerDirection {get;set;}

      [Browsable(false)]
      public new EntryHandling EntryHandling {get;set;}

      [Browsable(false)]
      public new StopTargetHandling StopTargetHandling {get;set;}

      [Browsable(false)]
      public new SetOrderQuantity SetOrderQuantity {get;set;}

      [Browsable(false)]
      public new TimeInForce TimeInForce {get;set;}



      Thank you for your help.


      Best regards
      Martin

      Comment


        #4
        Hello Martin,

        Thanks for your reply.

        Please add a print statement in OnBarUpdate() to provide a print showing the state.

        For example: Print (Time[0]+" State: "+State);

        Using your properties, on my end this is what I see:

        11/20/2019 9:11:00 AM State: Historical
        11/20/2019 9:12:00 AM State: Historical
        11/20/2019 9:13:00 AM State: Historical
        Enabling NinjaScript strategy 'Martin89test/185718290' : 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
        11/20/2019 9:14:00 AM State: Realtime
        11/20/2019 9:15:00 AM State: Realtime
        11/20/2019 9:16:00 AM State: Realtime

        Paul H.NinjaTrader Customer Service

        Comment


          #5
          Hey Paul,

          I already had the idea and realized that I only came to State.Historical.

          I noticed that this only happens if the strategy of NinjaTrader (ConnectionLoss or RealtimeError) was closed. I was able to activate the strategy afterwards, but she did not switch to Status.RealTime.

          But if I remove the strategy and add it back in, it will work again.





          Comment


            #6
            Hello Martin,

            Thanks for your reply.

            Please disconnect from your data feed, close Ninjatrader, restart NinjaTrader and verify you have live charts.

            Remove your strategy from the chart (or strategy tab).

            Use print statement I provided, recompile your strategy and apply the strategy to a live chart verify the strategy is processing in real time.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              Hi Paul,

              I made it as you said and detect the following:

              The strategy was closed from NinjaTrader during the night due to connection lost and activated not again.

              When I activated the strategy from the "Strategie" Tab the next morning, the strategie name was green but she did not switch to the State.Realtime.

              Only after i activated the strategy in the chart via the strategy menu did she switch to the Status.Realtime.

              How can i change it that the strategie switch to the State.Realtime when she actived from the "Strategie" Tab after close connetion lost?

              Comment


                #8
                Hello Martin89,

                There wouldn't be anything that would be stopping the strategy from transitioning to realtime data when it is enabled from the Control Center. There just needs to be iterating realtime data.

                If you add a print Print("Reached State.Realtime"); in OnStateChange when State == State.Realtime, you should see this print in the output window when there is realtime data. Once realtime data starts iterating, you should be able to observe the following print in the output window.

                Code:
                        protected override void OnBarUpdate()
                        {
                            if (State == State.Realtime)
                            {
                                Print("Processing Realtime Data");
                            }
                        }
                I have attached a strategy that can test these prints. I would suggest testing the same in your strategy after testing this script. If you are hitting issues with your strategy, I suggest checking the log tab of the Control Center for any errors that would cause the strategy to abort, or if your logic is not allowing these prints to be reached.

                If you have an issue with this test strategy, please let us know.
                Attached Files
                JimNinjaTrader Customer Service

                Comment


                  #9
                  Okay, I will test it.
                  And give you an info which status is reached in case of error.

                  I also see no reason why the strategy stop. Because the Strategie works.
                  In any case, I see no erros in the Log tab.
                  The only error I get so far is that the strategy no longer changes to the status Real.Time after there was a connection loss error. (At my customers too!)
                  But only if the strategy is already over 20 hours running.
                  Could this possibly be a reason? (The strategy is calculated OnPriceChange)

                  Comment


                    #10
                    Hello Martin89,

                    Below is a video showing the steps I have taken with the test strategy. If you can hit the issue with this test strategy, please let me know any specifics I'll need to reproduce on my end.

                    Demo - https://drive.google.com/file/d/1UE-...w?usp=drivesdk

                    If you are hitting this issue only with your strategy, I would suggest commenting sections of code until the issue is identified in the strategy logic or until we have a small example that can demonstrate the issue and we can use to file a report. If you are able to modify the test strategy so it can reproduce the behavior, that will be a way forward as well.

                    I look forward to assisting.
                    JimNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by HiddenPhilosopher, Today, 07:24 PM
                    0 responses
                    2 views
                    0 likes
                    Last Post HiddenPhilosopher  
                    Started by dkbyond, Today, 06:43 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post dkbyond
                    by dkbyond
                     
                    Started by i2w8am9ii2, Today, 06:05 PM
                    0 responses
                    1 view
                    0 likes
                    Last Post i2w8am9ii2  
                    Started by YevhenShynkarenko, Today, 05:46 PM
                    0 responses
                    4 views
                    0 likes
                    Last Post YevhenShynkarenko  
                    Started by Bionian, Today, 04:14 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post Bionian
                    by Bionian
                     
                    Working...
                    X