I have a class that I need to pass an ATR to. In that class I am working with the ATR value from 0 bars ago, and also with one that aligns with my entry which occurred x bars ago.
I get an error when I try and pass this, so I've stripped everything down, and Printing in OnBarUpdate debug. Code looks like this:
{
{
protected override void OnBarUpdate()
{
{
Print("ATR[0]: " + ATR(14)[0]);
Print("ATR[0]: " + Atr.ATR(14)[0]);
Print("62");
I get the following output:
ATR[0]: 1.08263483965015
Strategy 'ArgyleSim': Error on calling 'OnBarUpdate' method on bar 15: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
I am confident I'm lacking an understanding of how that ATR() (and the Indicator()) classes work. Just ATR(14)[0] yields a result, while Atr.ATR(14)]0] creates above error. Can someone please point me in the direction of how to better understand this so I can correctly pass this into my class. Thank you very much for your help in advance.
Kind Regards,
Nathan.

Comment