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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      152 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      87 views
      1 like
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      131 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      127 views
      1 like
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      106 views
      0 likes
      Last Post CarlTrading  
      Working...
      X