This is in reference to the error I have been getting "Tried to reference back more bars ....Please increase the Max Bars Back setting." The code doesn't seem to obey the Max Bars Back setting that I set.
After breaking down and testing smalls snippets of the following code, I think the "extremes" function is the cause of the error. I performed the following to diagnose this:
1. Set Max Bars Back to 10.
2. Applying the indicator, it doesn't obey the setting and appears to randomly starts at any point.
2. By replacing 'barCount ' with 1, the code respect the Max Bars Back setting.