Finding the HHV and LLV of Prv day in 5 Mins TF

Tomasz helped me to have the following code which finds the HHV and LLV of current day in 5 mins TF.
I just want to have the same but for Previous day.

//Today's High and Low & High Close and Low close


Any Help Would be Appreciated.

Gloria Filamino.

S  = Ref(Day(),0) != Ref(Day(),1);
Bs = Ref(BarsSince(S),-1);

PH  = ValueWhen(S,HHV(High,Bs));
PHI = ValueWhen(S,BarIndex()-HHVBars(High,Bs));
TH  = ValueWhen(Ref(S,-1),HHV(ValueWhen(ValueWhen(s,PHI,0) == BarIndex(),TimeNum()),Bs));

PL  = ValueWhen(S,LLV(Low,Bs));
PLI = ValueWhen(S,BarIndex()-LLVBars(Low,Bs));
TL  = ValueWhen(Ref(S,-1),LLV(ValueWhen(ValueWhen(S,PLI,0) == BarIndex(),TimeNum()),Bs));

1 Like

Just a necessary minor fix for Variables ( TL and TH and Bs )

Bs  = Ref(BarsSince(S),-1)+1;
TL  = Ref(ValueWhen(S,ValueWhen(ValueWhen(S,PLI,0) == BarIndex(),TimeNum())),-1);
TH  = Ref(ValueWhen(S,ValueWhen(ValueWhen(S,PHI,0) == BarIndex(),TimeNum())),-1);

Thanks Brother..
Did Awesome Job.
Small tweaking needed,i managed to do.

S  = Ref(Day(),0) != Ref(Day(),1);
Bs  = Ref(BarsSince(S),-1)+1;

PH  = ValueWhen(S,HHV(High,Bs));
PHI = ValueWhen(S,BarIndex()-HHVBars(High,Bs))+1;
TH  = Ref(ValueWhen(S,ValueWhen(ValueWhen(S,PHI,0) == BarIndex()+1,TimeNum())),-1);

PL  = ValueWhen(S,LLV(Low,Bs));
PLI = ValueWhen(S,BarIndex()-LLVBars(Low,Bs))+1;
TL  = Ref(ValueWhen(S,ValueWhen(ValueWhen(S,PLI,0) == BarIndex()+1,TimeNum())),-1);

AddColumn(PH,"Prv High",1.2);
AddColumn(TH,"High TN",1.2);
AddColumn(PHI,"Prv High BI",1);

AddColumn(PL,"Prv Low",1.2);
AddColumn(TL,"Low TN",1.2);
AddColumn(PLI,"Prv Low BI",1);

is it possible to get the UPPER body Value of Previous day "High" Candle?
is it possible to get the LOWER body Value of Previous day "Low" Candle?

Heartfelt Thanks for your time and effort.

Gloria Filamino.

1 Like

Hi @Sebastian

I'm just thinking, I wrote this code at my end and its working, but tried a slightly different approach.
We can then reference any past day(s).

bi   = BarIndex();
newD = Day() != Ref(Day(), -1);    // Test for New Day
op1  = ValueWhen( newD, bi, 1);    // get BarIndex of today
op2  = ValueWhen( newD, bi, 2);    // get BarIndex of previous day

//   Above opX can be used to refer to N number of past days

// For Previous Day Low
yL = ValueWhen( bi == LastValue( op1) -1, LowestSince( bi == LastValue( op2), L, 1), 1);
// op1 - 1 refers to last Bar of previous day

//  similarly. we can refer other Arrays like High
yH = ValueWhen( bi == LastValue( op1) -1, HighestSince( bi == LastValue( op2), H, 1), 1);

// I've used LastValue( opX) to assert more aggressively although not required
// unless the selector bar is in previous day :)

@Gloriafilamino kindly test this code more aggressively and I hope it works.


Thanks for showing interest.
I will surely check this too,

Gloria Filamino.

@Gloriafilamino , Does this mean the open/close values of the previous day ? , if so you can use Timeframegetprice() function
see instruction related to it from here

you may need to write additional two lines to your code .. Like this


Good Work @travick, i write a simiar code but using timeframegetprice() , then i realized that is not what gloria sought
although this was not so clear in the first post .. what i understood from 3rd post that she need to get the

1- TimeNum() & Barindex() of highest high for the previous day on 5m time frame
2- TimeNum() & Barindex() of lowest low for the previous day on 5m time frame

Your code will just give her the high and low of previous day that similar to sandy's code and that's not exactly what she sought, unless i misunderstood her request :slight_smile:


Thanks Sebastian and travick.
Both were useful and I am using Sebastian's one.
It works like gem.
Thanks all.
Gloria filamino.