Ultimately, I am trying to find out if the current price (on a 1-minute chart or otherwise) is a 5-Day high or a 5-Day low.
I am confident that I can perform the necessary calculations to make that determination if I could just find the highs and lows over the past 5 days.
There is where my problem lies. I am trying to use the following:
Bars.GetDayBar(2).Low // or replace 2 with 1,3,4, or 5.
This works on a daily chart but breaks on a 1-minute chart.
So, in the OnBarUpdate() method, I place the following code:
double myVar = Bars.GetDayBar(2).Low; // find the low from 2 days ago
Print(myVar.ToString());
Note: Since I am wanting to find the previous 5 days highs/lows, I have this at the top of my OnBarUpdate() method:
if (CurrentBars[0] < 5)
return;
This works perfectly on a daily chart.
On a 1-minute chart, I get the following error message:
"Error on calling OnBarUpdate method on bar 5: Object reference not set to an instance of an object."
Any help on this would be greatly appreciated!
Comment