Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Limiting a Plot

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

    Limiting a Plot

    Hi,

    Is there a way I can limit the plot of say an SMA to display for just the last 20 bars of the chart?

    If so, would someone please post some sample code that would allow this.

    Thankyou.

    #2
    This is not supported by default. There probably is a way to custom code it in NinjaScript, but unfortunately we don't have a sample a hand.

    Comment


      #3
      rt-trader you can add this code at the start of the OnBarUpdate() section of the indicator code as a simple workaround. Now this code does not completely do what you are trying to achieve because it does not automatically remove old plotted points. If you hit F5 and refresh the chart it will remove old points though.
      Code:
      BarsRequired = Bars.Count-20;
      Edit: To achieve the exact behavior you wanted please check out the reference sample I have added. The magic is done in the Plot Override section. Basically what is happening is I am creating a Path object that traces only the SMA value for the last 20 bars. Then I tell it to draw that path and voila you have an indicator that only draws for the last 20 bars.
      Attached Files
      Last edited by NinjaTrader_JoshP; 08-25-2007, 06:55 PM.
      Josh P.NinjaTrader Customer Service

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      558 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      324 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
      545 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      547 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X