Announcement

Collapse
No announcement yet.

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

    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.

        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 Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          578 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          334 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          554 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          551 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X