# Future HHV / LLV calculation

Hi TZ or Anyone

i saw from this link : http://www.amibroker.com/kb/category/charting/indicators/
Would you please advise me , what is the FutureHHV / LLV value?
how to calculate this futureHHV/LLV.

SDevan

It is available using the Ref function, read this carefully

https://www.amibroker.com/guide/afl/ref.html

2 Likes

hi portfoliobuilder ,

thanks for the reply , do you have any idea the parameter of future ref ?
i using the ref function see the below code , i couldnt get the exact parameter as TJ made.
rngH = HHV(H,20);
rngrefhigh = Ref(rngH,-20);
Plot( rngrefhigh, “HHV”, colorGold, styleThick );

rngL = LLV(L,20);
rngrefLow = Ref(rngL,-20);
Plot( rngrefLow, “HHV”, colorGold, styleThick );

if you able to get the value of ref ,please let me know mate.

thanks

I am not certain what you are having a problem with as the code in the knowledge base example works fine.

Perhaps it is a bit confusing because one function uses Positive numbers to refer to previous bars, and the other function uses Negative numbers to refer to previous bars and Positive numbers to look into the future

So carefully read the appropriate User Guide sections.

https://www.amibroker.com/guide/afl/hhv.html
""hhv( high, 8)" returns the highest high price over the preceding eight periods."

https://www.amibroker.com/guide/afl/ref.html
"The formula "ref( C, 12 )" returns the closing price 12 periods ahead (this means looking up the future)" . If I wanted to use Ref to look into the past then I would use a negative number, Ref(C, -12) would look for the Close 12 bars in the past.

So in the Knowledge Base Example you were looking at, run an Exploration to illustrate what these calculations are creating.

Filter=1;
AddColumn(Ref(HHV( H, 20 ), 20), "Highest in Future 20 bars");
AddColumn(HHV( H, 20 ), "Highest in Past 20 bars");

This will produce an output like below where I have shown 20 days worth of "High" and in column 3 on the first bar you look into the future and find that 207.14 will be the Highest High. The next column looks backwards into the past.

3 Likes

hi portfoliobuilder
thanks for you explanation , finally i got the formula.

thanks

A small question here . Suppose I have stock with 100 days of listing data . Now supose i use the hhv(high,20 ) and the ref ( hhv( high,20) , 20) functions

1. how many data items will hhv( high,20 ) have ? Will it be 100 or 80 ? If , 80 , then what will be the values of remaining 20 ?
2. How many data items will ref ( hhv(high,20),20) have ? 100 , 80 ? If, 80, then what will be the remaining 20 values ?
3. what is the practical use of ref ( hhv(high,20),20 ) function. For example , at day 100 of the above mentioned stock, what information does this fucntion convey ?

I can do you a good favour by answering the three questions,
But i can do you a great service directing you here.
Kindly check it out
https://www.amibroker.com/guide/h_debugger.html
And
https://www.amibroker.com/guide/afl/_tracef.html

2 Likes

@saurabhk, Like @travick suggested, it is best if you actually go and LEARN what it means.

Personally I would suggest you use an Exploration, with columns for the various items of data that you would be looking at, and see the data like portfoliobuilder did above.

2 Likes

Thanks a lot fr the replies of @travick and ur self too . I got the first 2 points clear. The ref function shifts the array by the number of periods. But what is the usefulless of such shifts ?

Its explained here in the 2nd example
https://www.amibroker.com/guide/h_understandafl.html

1 Like

Ok , understood the concept of ref . Now as @travick sent a link about debugger; Would you explain how can we use it in our case . My watch window shows nothing

Thanks a lot pushing me to crunch the code and understand it myself . Here is the code that I explored

1 Like