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

Hi,
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
xH=BarsSince(Day()!=Ref(Day(),-1));
yH=HHV(H,xH+1);
yhc=HHV(C,xh+1);
Hightoday=IIf(xH==0,yH,Ref(yH,0));


xL=BarsSince(Day()!=Ref(Day(),-1));
yL=LLV(L,xL+1);
yLc=LLV(C,xL+1);
LowTODAY=IIf(xL==0,yL,Ref(yL,0));

Any Help Would be Appreciated.

Regards,
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);
3 Likes

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);

Filter=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.

Regards,
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.

3 Likes

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

Regards,
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

TimeFrameGetPrice("Open",inDaily,-1);
TimeFrameGetPrice("Close",inDaily,-1);

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:

3 Likes

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