Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator that plots returns of bars

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

    Indicator that plots returns of bars

    hi,

    i'm working on

    Plot4.Set(Closes[0][0]/Opens[0][0]-1) to plot returns of individual bars.

    what I want to do is to be able to change the look back period; meaning close[0] divided by open 10 bars ago. for some reason it's not compiling. why could this be?

    Plot4.Set(Closes[0][0]/Opens[0][10]-1)

    thanks

    #2
    Hello,

    Thank you for the question.

    What sort of error are you getting? Is this an acutal error being reported when you compile or is this not enabling on a chart?

    If you open the Tools -> Output window and then try this on the chart do you see any errors listed?

    If this is the only code you are most likely running into a not enough bars loaded error.

    This would resolve the error by ensuring you are at least 10 bars into processing before continuing. this is needed when checking barsago values, if you check 10 bars ago on bar 0, technically you are looking for bar -10 which will never exist.

    Code:
    if (CurrentBar < 10) return; //stop processing if the current bar is less than the amount of barsago you are requesting so 10
    
    double testValue = Closes[0][0] / Opens[0][10] - 1;
    also I am unsure if you are using a multi timeframe script or not, but if you are only looking at the charts current data series you can use the following:

    Code:
    if (CurrentBar < 10) return; 
    double testValue = Close[0] / Open[10] - 1;

    Comment


      #3
      I'm getting an out of range error; and yes this is a multi instrument indicator

      you're suggestion for current bar > 10 worked

      thank you
      Last edited by staycool3_a; 10-29-2014, 05:38 PM.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by CarlTrading, 03-31-2026, 09:41 PM
      1 response
      72 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      39 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      63 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      63 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      53 views
      0 likes
      Last Post CarlTrading  
      Working...
      X