Thanks for your notes.
The code in the example script attached in my previous post could be used directly in your strategy if you are wanting to get the highest price of the last 5 bars. This includes the CurrentBar (bar 0) and the previous 4 bars on the chart because HighestBar() will include the CurrentBar too.
A loop would need to be used to accomplish the goal you described instead of using HighestBar(). The loop might look something like this:
double HighestHigh = -1; int HighestBarAgo = -1; for(int i = 1; i < 6; i++) { if(High[i] > HighestHigh) { HighestHigh = High[i]; HighestBarAgo = i; } }
Comment