Get the previous HHV

Hi All,

Can anyone let me know how to get the previous Highest High from the latest one.

For e.g I have the following code to get the latest Highest high for last 30 periods.

h1 = HHV(H,30);

Now I want to find out what was the previous highest high (for previous 30 periods ) made prior to the latest Highest high i.e. h1 above.

Any help in this is highly appreciated.

Thanks.

prev30_h1 = Ref(HHV(H,30), -30);

Or if you mean for previous bar then just one bar.

prevbar_h1 = Ref(HHV(H,30), -1);
2 Likes

image

As shown in diagram , h1 is my current highest high , and now I want to start counting 30 days backwards from h1 and find the highest high for those 30 days back , which will give me h2.

period = 30;
prev_h1 = Ref(HHV(H,period), -HHVBars(H,period)-1);

Or this one

period = 30;
prev_h1 = Ref(HHV(H,period), -HHVBars(H,period)-period);

etc...

1 Like

image

Then remove "-1" for christ sake...

I have not tested this but just written in editor.
Also I do not have your symbol..

How about you use your brain too instead of just using my one?

Also no "thanks for help" just "giving me this" .... "not giving me that" ...

2 Likes

After I used my brain and didnt find anything working , so I posted it . Seems your brain is also not working

Then help yourself. Ciao!

1 Like

yes I will figure it out .

1 Like

Great way of showing appreciation @richyrich !

If it was up to me, it would be your last post on this forum.

3 Likes

I already showed my appreciation to everyone who offers help . But not if some one starts putting offending quotes

like
"
How about you use your brain too instead of just using my one?

Also no "thanks for help" just "giving me this" .... "not giving me that" ...
"

If you want to help someone who comes to the forum , just dont put additional quotes like above. Be to the point

Those are not offending quotes but just fact.
In this thread here you just add one demand after another.
Where is your code you tried?
What is the symbol used for comparison?
I do not see any "thanks for help" here in addition.
Only limited infos and demands and hidden complaining and last but not least "your brain is also not working". I didn't say yours were not working. I said how about using your one too. You got several hints to get you going!

I do not see your brain in action at all. Again where is your code you tried? Just seeing someone waiting for next line of code.

4 Likes

I am sincerely trying hard at my end to solve this HHV issue. But after lot of thinking , I couldn't get it , so I posted it. In my first post itself I already mentioned "Any help in this is highly appreciated". So your help
@fxshrat is indeed appreciated without a doubt . But I was taken a back when you said " How about you use your brain too instead of just using my one?" . My situation was that I got blocked at this problem and didnt know how to proceed further.
I am sorry if you felt my demands were high, when I thought I had just asked one query and never deviated to any other demand from it.

Upper one is your quote

This code is doing that looking for HHV prior to H1.

period = 30;
prev_h1 = Ref(HHV(H,period), -HHVBars(H,period)-1);

Your h1 has been

h1 = HHV(H,30);

Your problem is... your marked H2 is not the HHV (highest high value!!!) value looking back from H1!

b21a0084a9af6cad1c2996033567e4f8f4435e9d

BTW your h1 makes no sense to me too if the most right candle is the last one.
h1 = HHV(H,30);
would pick the red one within yellow square (but only if my eyes are correctly working).

4 Likes

Thanks @ fxshrat for pointing that out. The big picture is I am trying to code a divergence technique.
So I will have to make one change to space out the recent highest high and previous highest high by finding the previous highest high only after few bars have gone past backwards of recent high. Like just adding -10 instead of -1 to eliminate any further closeby highs to H1.

prev_h1 = Ref(HHV(H,period), -HHVBars(H,period)-10);

Thanks again.