I’m trying to find the highest high since a new 13 week low was created. The date of the 13 week low will only change when the low of the current bar is less then the previous 12 weeks. I want to use the date of the 13 week low bar as a variable and use the HIGHESTHIGH function to find the highest high since the date of the 13 week low.
Is it possible to reference a variable in the HIGHESTHIGH function? Below is what I have done so far but script is not valid for H1.
//Lowest low for the last 13 weeks
L1 = LOWESTLOW(Week(PERIODAMOUNT=1), BARS=12, INCBAR=False);
//Low of current bar is not lower then the previous 12 weeks
L2 = LOW() < L1;
//Date since there was a new 13 week low
B1 = BARDATE(L2);
//Number of weeks since new 13 week low
B2 = (BARDATE() - B1)/7;
//Highest high since new 13 week low
H1 = HIGHESTHIGH(RANGE=Look Back Period, BARS = B2);
H1
In this example, V1 looks for the new 13 Week Low being set. $a looks for the number of bars since the new low was set, and the Highest High function references this count and sets the back bars accordingly.
In the image below you can see on ASX the last 13 week low was 144 bars ago. The Highest High (blue) line is using a lookback period of 144 bars.
If you enabled training mode and started hiding bars, the Highest High line would adjust based on the $a variable count.
Thank you for your reply. That works fine. I see what you mean, it’s only valid for current data. Is it possible to view historical instances from current data instead of using training mode?
Using the show plot like you have done above, when there is a new a new 13 week low the HighestHigh would reset to the high of the bar that created a new 13 week low. It would gradually step up when there are new highs until a there is new 13 week low where it would reset again.