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

Does DrawRegion work in strategy?

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

    Does DrawRegion work in strategy?

    Hello.

    I made very simple code to draw 2 regions.

    It work great in indicator and don't work in strategy.

    What am I doing wrong ?
    Attached Files
    Last edited by fx.practic; 10-01-2015, 04:16 PM.
    fx.practic
    NinjaTrader Ecosystem Vendor - fx.practic

    #2
    Hello,

    I tried the strategy and indicator scripts on my end, and from what I can see both look identical.

    I have included an image of the strategy, on your end did you add and enable the strategy directly from the chart?

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

    Comment


      #3
      I just tried - on Chart works normally.

      I got error in Strategy Analyzer.
      Last edited by fx.practic; 09-30-2015, 10:13 PM.
      fx.practic
      NinjaTrader Ecosystem Vendor - fx.practic

      Comment


        #4
        Hello,

        Thank you for the reply.

        This would be expected due to the way you are using DrawRegion.

        In general the way you are currently doing this works on a chart because at the time you call DrawRegion in OnStartUp, it is able to create the object and at least assign the variables to the object as you update it later. Instead in a BackTest there is no chart until you open the chart so it is unable to create the object for the variables to draw the region from OnStartUp.

        I would suggest adding an input for yourself that you can select Backtest true/false and depending on that bool, use your current method or use OnBarUpdate like the examples for DrawRegion. This would allow both ways to be used depending if you are backtesting or on a chart.

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

        Comment


          #5
          Thank You, Jesse.
          It is absolutely clear now.

          I saw same effect with others ChartObjects in Startegy Analyzer.

          I need to use IRegion instead of indicator lines in strategy; for example to visualize the price of trailing stop.

          And now I use this quite primitive solution (if someone interesting - see screenshot).
          It work normally after first viewing Chart tab.
          Attached Files
          fx.practic
          NinjaTrader Ecosystem Vendor - fx.practic

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by fx.practic, 10-15-2013, 12:53 AM
          5 responses
          5,404 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by Shai Samuel, 07-02-2022, 02:46 PM
          4 responses
          95 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by DJ888, Yesterday, 10:57 PM
          0 responses
          7 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by MacDad, 02-25-2024, 11:48 PM
          7 responses
          159 views
          0 likes
          Last Post loganjarosz123  
          Started by Belfortbucks, Yesterday, 09:29 PM
          0 responses
          8 views
          0 likes
          Last Post Belfortbucks  
          Working...
          X