Calculate Future HHV getting prev also

HHV(Ref(C,150),150);

code is above. Working well when there is 150 entry after specific date. But when less (Say 50 data) it is getting previous also.

Say getting previous 100 and future 50. But I want if less then 150, it will get only future. How can I do that ?

Because HHV calculates:

the highest value in the ARRAY over the preceding periods ( periods includes the current day). HHV accepts periods parameter that can be constant as well as time-variant (array).

(Quote from HHV() function guide)

Study the example from this KB-Article: How to read highest high value of future bars.

Ref( HHV( C, 150 ), 150 )

I have read the article.

That futureHHV works when there is 150 data in future, but when in future there is 50, it is getting prev 100 and future 50.

Not solved.

If this is from the help manual: syntax : hhv( ARRAY, periods )

Then why are you doing this: HHV(Ref(C,150),150); and not this: hhv( c, 150 )

AmiBroker's logic is correct and absolute! Do not commit the uninformed mistake of doubting it.

What you are asking for, will always seek the Close of the current bar until the 150 bars are formed, since, it is going to look forward that many bars in future! Going by what you want:

Try and see for yourself:

bi = BarIndex();
lvbi = LastValue( bi );
BarDiff = lvbi - bi;

p = 150;
period = IIf( BarDiff < p, BarDiff, p );
FutHHV = Ref( HHV( C, period ), period );
2 Likes

FutHHV = Ref( HHV( C, period ), period ); this will be

FutHHV = HHV(Ref( C, period ), period );

Not working !!! above any

_SECTION_BEGIN("Ichimoku");
prds = Param( "Standard Line Periods", 13, 5, 26, 1 );
turn = Param( "Turning Line Periods", 3, 3, 10, 1 );
delay = Param( "Delayed Line Periods", 12, 4, 25, 1 );
span = Param( "Spans Periods", 16, 10, 52, 1 );
futurerange = Param( "Future Range", 150, 1, 300, 10 );

TL = ( HHV( H, turn ) + LLV( L, turn ) ) / 2;
SL = ( HHV( H, prds ) + LLV( L, prds ) ) / 2;
DL = Ref( C, delay );
Sp1 = ( SL + TL ) / 2;
Sp2 = ( HHV( H, span ) + LLV( L, span ) ) / 2;
Maxsp=Max(sp1,sp2);
_N( Title = StrFormat( "{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " + WriteVal( V, 1.0 ) + " {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ) );

bi = BarIndex();
lvbi = LastValue( bi );
BarDiff = lvbi - bi;
futurerange = IIf( BarDiff < futurerange, BarDiff, futurerange );
FutCP= HHV( Ref(C,futurerange ), futurerange );
FutCP1= HHV( Ref(C,103 ), 103 );
Filter=C>TL AND  TL>SL AND  TL<1.01*SL AND  SL>Ref(SL,-1); 

AddColumn(C,"CP",1.2);
AddColumn(FutCP,"FutCP",1.2);
AddColumn(FutCP1,"FutCP",1.2);
AddColumn(futurerange,"futurerange",1.2);
_SECTION_END();

My code is as above. Problem is thant When futurerange is 103, then in column futurerange it showing 103. where FutCP and FutCP1 are 7.7 and 9.1. Why ??????? actually it will be 9.1

How can I solve it ?????

This thread is temporarily closed until @arctushar proves that he has license.