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 CaptainJack, 05-29-2026, 05:09 AM
      0 responses
      262 views
      0 likes
      Last Post CaptainJack  
      Started by CaptainJack, 05-29-2026, 12:02 AM
      0 responses
      168 views
      0 likes
      Last Post CaptainJack  
      Started by charlesugo_1, 05-26-2026, 05:03 PM
      0 responses
      170 views
      1 like
      Last Post charlesugo_1  
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      257 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      209 views
      0 likes
      Last Post CarlTrading  
      Working...
      X