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;
    JesseNinjaTrader Customer Service

    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 SentientDavid, Today, 01:34 AM
      0 responses
      2 views
      0 likes
      Last Post SentientDavid  
      Started by MrForgetful, Today, 01:28 AM
      0 responses
      2 views
      0 likes
      Last Post MrForgetful  
      Started by falcondroneus, Today, 01:15 AM
      0 responses
      2 views
      0 likes
      Last Post falcondroneus  
      Started by Vikuno1, 11-28-2023, 11:42 PM
      15 responses
      357 views
      1 like
      Last Post PaulMohn  
      Started by PaulMohn, Yesterday, 02:06 AM
      3 responses
      12 views
      0 likes
      Last Post PaulMohn  
      Working...
      X