How to get stock price at historical indicator highs?

Hi everyone, I have a question that has been bothering me for a long time, and I couldn't find a solution in the answer library. I would like to obtain the corresponding stock price when a specific technical indicator is at its highest point, for example:
ASK_AFL

period = 25;
highestValue = HHV(MACD(r1, r2), period); // Indicator highestValue
pp = ValueWhen(highestValue,C); //price position

I can only obtain the closing price for the last day “lastvalue(c)”, not the corresponding price within the indicator.
Thank you very much!

pp=ValueWhen(highestValue==MACD(r1, r2),C);

Just right click on built in functions in editor and click on function reference to get more info quickly.
Then you can see how to use them correctly.

Thank you very much for your help. I tested this method using a watchlist. I found that some are correct, while others are not. I am working hard to understand why. However, I don't have a programming background (I am an automotive chassis engineer and CAE simulation engineer), but I will do my best to understand the solution you mentioned.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.