Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Strategy not working

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

    Strategy not working

    Hi

    I've been having some problem with a strategy I've been working on.

    It was not possible to enable it yesterday so I've created a new one and it did work on drawing a signal on the chart.
    Only noticed that it was turning off randomly at some point (would find again the strategy not-enabled)
    I went then to try the performance on the Strategy analyser and noticed that it won't generate any run (not even a log). At the same time again on the chart I have the problem that the strategy won't turn on.
    Same strategy was drawing signals on the chart before and now not even that.
    Many thanks


    Attached the Zip file
    Attached Files

    #2
    Hello percma,

    Thanks for opening the thread.

    The strategy is hitting an error in OnStateChange() under State.Configure. We can see the OnStateChange() error noted in the Log tab of the Control Center and we can take debugging steps to see which part of OnStateChange() the error is coming from. Since this is a Strategy Builder built strategy, I have taken steps to find the origin of the error.

    It looks like you have your Profit Target and Stop Loss set to use indicator values. While the Strategy Builder does not limit you from doing this, it is not allowed to do in NinjaScript because the indicator would need to be assigned in State.DataLoaded or later. (State.Configure comes before State.DataLoaded. More information on NinjaTrader's states can be found at the end of this post.) I have requested that the menu items to assign the profit target/stop loss to an indicator value get removed so this issue can be avoided.

    Your goal can be accomplished by unlocking the strategy code and assigning your profit target/stop loss to the appropriate indicator values in OnBarUpdate(). An example on setting profit target and stop losses in OnBarUpdate() can be found in the Reference Samples section of the help guide. I'll include a link below.

    Using OnBarUpdate for dynamic Profit Target and Stop Loss - https://ninjatrader.com/support/help...of_stop_lo.htm

    Information on NinjaTrader's state system can be referenced in the help guide as well. This information is publicly available.

    OnStateChange() - https://ninjatrader.com/support/help...tatechange.htm

    NinjaScript LifeCycle - https://ninjatrader.com/support/help...fecycle_of.htm

    Please let us know if we can be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      will try to look at it. hopefully not behind my reach...
      will come back if I need some clarification.

      thanks

      Comment


        #4
        ok. out of my reach.

        in substance you are saying that I can't link any order management signal to any indicator available if I use the strategy builder?

        Comment


          #5
          Hello percma,

          The limitation is that it is not possible to use an indicator for SetProfitTarget, SetStopLoss, or SetTrailStop in the Strategy Builder due to where the generated code is placed.

          Another approach you may take can be to unlock the strategy when finished and then move the Set methods to the end of State.DataLoaded instead of where they are currently placed. This would not update automatically, but should allow you to place your stops and targets in reference to your indicator.

          Please let us know if you have any issues with this approach.
          Last edited by NinjaTrader_Jim; 06-12-2018, 07:49 AM.
          JimNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Kaledus, Today, 01:29 PM
          0 responses
          3 views
          0 likes
          Last Post Kaledus
          by Kaledus
           
          Started by PaulMohn, Today, 12:36 PM
          1 response
          16 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by yertle, Yesterday, 08:38 AM
          8 responses
          37 views
          0 likes
          Last Post ryjoga
          by ryjoga
           
          Started by rdtdale, Today, 01:02 PM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_LuisH  
          Started by alifarahani, Today, 09:40 AM
          3 responses
          19 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X