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 argusthome, 03-08-2026, 10:06 AM
      0 responses
      80 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      45 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      29 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      32 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      66 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X