Weekly HL Y'day HL and Day-2 HL levels for Price action traders and all

extremist

Well-Known Member
#1
Code:
Period = Param("display length", 375, 2, 1875 ); 
bi = BarIndex(); 
procedure PlotLevel( array, nam, Col,sty ) 
{ 
 x = SelectedValue( bi ); 
 y = SelectedValue( array ); 
 Plot( IIf( bi >= x AND bi < x + Period, y, Null ),nam, Col, sty ); 
 PlotText( nam, x+1, y, Col ); 
} 

if( ParamToggle("Weekly HL", "No|Yes", 1))
{
wcol = ParamColor("Wkly Color", colordarkyellow);
wh = TimeFrameGetPrice("H",inWeekly,-1);
wl = TimeFrameGetPrice("L",inWeekly,-1);

PlotLevel( wh, "\nWH - "+wh+"", wcol,styleLine|stylethick ); 
PlotLevel( wl, "\nWL - "+wl+"", wcol,styleLine|stylethick ); 
}

if( ParamToggle("Y'Day HL", "No|Yes", 1))
{
dcol = ParamColor("Y'Day Color", colortan);
dh = TimeFrameGetPrice("H",indaily,-1);
dl = TimeFrameGetPrice("L",indaily,-1);

PlotLevel( dh, "\nDH - "+dh+"", dcol,styleLine ); 
PlotLevel( dl, "\nDL - "+dl+"", dcol,styleLine); 
}

if( ParamToggle("Today-2 HL", "No|Yes", 1))
{
d2col = ParamColor("D-2 Color", colororange);
d2h = TimeFrameGetPrice("H",indaily,-2);
d2l = TimeFrameGetPrice("L",indaily,-2);

PlotLevel( d2h, "\nD2H - "+d2h+"", d2col,styledashed ); 
PlotLevel( d2l, "\nD2L - "+d2l+"", d2col,styledashed ); 
}



This will help All traders to get Some prominent support and resistances.
This idea of deriving Supp and res i got from Karthik_sri's thread.

Hope this will help u all.

In this AFL u can varry the length of the lines from parameters and mainly it plots lines with respect to the cursor location so if u r backtesting some strategy it may come handy.

Regards
 
Last edited:

Mungus

Well-Known Member
#4
any AFL to mark High/Low of weekly and High/Low of last 2 days?
It'll make the work easier(lazy Trader mee) :D
I dont have any AFL for that...i think you can get that from Amitrandive post...

I hope this will help u all.
To save your energy and time.

the special feature to recognize the cursor location is very help full in backtesting your strategy without cluttering your chart much.


Code:
Period = Param("display length", 375, 2, 1875,1 ); 
bi = BarIndex(); 
procedure PlotLevel( array, nam, Col,sty ) 
{ 
 x = SelectedValue( bi ); 
 y = SelectedValue( array ); 
 Plot( IIf( bi >= x AND bi < x + Period, y, Null ),nam, Col, sty ); 
 PlotText( nam, x+1, y, Col ); 
} 

if( ParamToggle("Weekly HL", "No|Yes", 1))
{
wh = TimeFrameGetPrice("H",inWeekly,-1);
wl = TimeFrameGetPrice("L",inWeekly,-1);

PlotLevel( wh, "\nWH - "+wh+"", colordarkyellow,styleLine|stylethick ); 
PlotLevel( wl, "\nWL - "+wl+"", colordarkyellow,styleLine|stylethick ); 
}

if( ParamToggle("Y'Day HL", "No|Yes", 1))
{
dh = TimeFrameGetPrice("H",indaily,-1);
dl = TimeFrameGetPrice("L",indaily,-1);

PlotLevel( dh, "\nDH - "+dh+"", colortan,styleLine ); 
PlotLevel( wl, "\nDL - "+dl+"", colortan,styleLine); 
}

if( ParamToggle("Today-2 HL", "No|Yes", 1))
{
d2h = TimeFrameGetPrice("H",indaily,-2);
d2l = TimeFrameGetPrice("L",indaily,-2);

PlotLevel( d2h, "\nD2H - "+d2h+"", colororange,styledashed ); 
PlotLevel( d2l, "\nD@L - "+d2l+"", colororange,styledashed ); 
}
Super awesome,mind blowing code extremist Sir.
As you’ve decided to make us more lazy :D,one small request in param-

1)I’m little color blind,so if you could add like this to change the colors of those lines-(My background is Light Gray so cant see few lines)(I cant change the BG color due to my Eye Problem)



2)Bold letters for D2H,D@L(Its D2L,typo mistake),WH,WH(I see Big letters)

3)If you could add zone and lines both..
So we can switch it between the zone or line mode like this-
Line Mode-


Vs
Zone-


LoneWolf has a code for above but it needs many tweeks.Your code solves the purpose of backtesting too.

Hope I’m not asking too much,mere aankh me thoda gadbad hai,isliye yeh sab request Sirji.

Please,If possible code it for me.
 
Last edited:

mastermind007

Well-Known Member
#5
Code:
Period = Param("display length", 375, 2, 1875 ); 
bi = BarIndex(); 
procedure PlotLevel( array, nam, Col,sty ) 
{ 
 x = SelectedValue( bi ); 
 y = SelectedValue( array ); 
 Plot( IIf( bi >= x AND bi < x + Period, y, Null ),nam, Col, sty ); 
 PlotText( nam, x+1, y, Col ); 
} 

if( ParamToggle("Weekly HL", "No|Yes", 1))
{
wh = TimeFrameGetPrice("H",inWeekly,-1);
wl = TimeFrameGetPrice("L",inWeekly,-1);

PlotLevel( wh, "\nWH - "+wh+"", colordarkyellow,styleLine|stylethick ); 
PlotLevel( wl, "\nWL - "+wl+"", colordarkyellow,styleLine|stylethick ); 
}

if( ParamToggle("Y'Day HL", "No|Yes", 1))
{
dh = TimeFrameGetPrice("H",indaily,-1);
dl = TimeFrameGetPrice("L",indaily,-1);

PlotLevel( dh, "\nDH - "+dh+"", colortan,styleLine ); 
PlotLevel( dl, "\nDL - "+dl+"", colortan,styleLine); 
}

if( ParamToggle("Today-2 HL", "No|Yes", 1))
{
d2h = TimeFrameGetPrice("H",indaily,-2);
d2l = TimeFrameGetPrice("L",indaily,-2);

PlotLevel( d2h, "\nD2H - "+d2h+"", colororange,styledashed ); 
PlotLevel( d2l, "\nD@L - "+d2l+"", colororange,styledashed ); 
}
extremist
Very efficient refactoring !
 

extremist

Well-Known Member
#6
Super awesome,mind blowing code extremist Sir.
As you’ve decided to make us more lazy :D,one small request in param-

1)I’m little color blind,so if you could add like this to change the colors of those lines-(My background is Light Gray so cant see few lines)(I cant change the BG color due to my Eye Problem)



2)Bold letters for D2H,D@L(Its D2L,typo mistake),WH,WH(I see Big letters)

3)If you could add zone and lines both..
So we can switch it between the zone or line mode like this-
Line Mode-


Vs
Zone-


LoneWolf has a code for above but it needs many tweeks.Your code solves the purpose of backtesting too.

Hope I’m not asking too much,mere aankh me thoda gadbad hai,isliye yeh sab request Sirji.

Please,If possible code it for me.
added color selection.
Can not increase the thickness of the letters. SORRY.

And in second image how did u got the zones?
hand made or code made?
if code made then i would like to see tht code if u want to share.
 

Mungus

Well-Known Member
#7
The Colde/AFL was shared by LoneWolf in a Zone Form(Second Image)-

Code:
/**************************************
******** PREV SESSION'S HLC ***********
****************************************/

_SECTION_BEGIN("Two Day Range");

// Get Previous Day's High low and Close
PrevHigh = TimeFrameGetPrice("H", inDaily, -1);
PrevLow = TimeFrameGetPrice("L", inDaily, -1);
PrevClose = TimeFrameGetPrice("C", inDaily, -1);

// Get Previous 2 Day's High low and Close
Prev2High = TimeFrameGetPrice("H", inDaily, -2);
Prev2Low = TimeFrameGetPrice("L", inDaily, -2);
Prev2Close = TimeFrameGetPrice("C", inDaily, -2);

// Check bar's time
CurrBarTime = TimeNum();
DayStartTime = 91500;
DayEndTime = 153000;

// Check range condition
IsAllDay = CurrBarTime >= DayStartTime AND CurrBarTime <= DayEndTime;
IsToday = Day() == LastValue(Day()) AND Month() == LastValue(Month());

ShowPrevHLC = ParamToggle("Show Previous day Range", "Yes|No", 1);
ShowTwoDayRange = ParamToggle("Show Two Day Range", "Yes|No", 1);
ColorPrevDayRange = ParamColor("Previous Day Range Color", colorTurquoise);
ColorPrev2DayRange = ParamColor("Previous 2Day Range Color", colorGold);

x= Cum(1);

PDHbi = LastValue(ValueWhen(H==LastValue(PrevHigh), x));
PDH = IIf(x>PDHbi, ValueWhen(H==LastValue(PrevHigh), High), Null);
PDHO = IIf(x>PDHbi, ValueWhen(H==LastValue(PrevHigh), Open), Null);
PDHC = IIf(x>PDHbi, ValueWhen(H==LastValue(PrevHigh), Close), Null);

PDLbi = LastValue(ValueWhen(L==LastValue(prevLow), x));
PDL = IIf(x>PDLbi, ValueWhen(L==LastValue(prevLow), Low), Null);
PDLO = IIf(x>PDLbi, ValueWhen(L==LastValue(PrevLow), Open), Null);
PDLC = IIf(x>PDLbi, ValueWhen(L==LastValue(PrevLow), Close), Null);

P2DHbi = LastValue(ValueWhen(H==LastValue(Prev2High), x));
TwoDH = IIf(x>P2DHbi, ValueWhen(H==LastValue(Prev2High), High), Null);
TwoDHO = IIf(x>P2DHbi, ValueWhen(H==LastValue(Prev2High), Open), Null);
TwoDHC = IIf(x>P2DHbi, ValueWhen(H==LastValue(Prev2High), Close), Null);

P2DLbi = LastValue(ValueWhen(L==LastValue(Prev2Low), x));
TwoDL = IIf(x>P2DLbi, ValueWhen(L==LastValue(Prev2Low), Low), Null);
TwoDLO = IIf(x>P2DLbi, ValueWhen(L==LastValue(Prev2Low), Open), Null);
TwoDLC = IIf(x>P2DLbi, ValueWhen(L==LastValue(Prev2Low), Close), Null);

if(ShowPrevHLC AND Interval() <= 3600)
{
Plot(PDH, "", ColorPrevDayRange, styleLine|styleNoTitle|styleNoLabel|styleNoRescale);
Plot(PDL, "", ColorPrevDayRange, styleLine|styleNoTitle|styleNoLabel|styleNoRescale);
PlotOHLC(PDH,PDH,Max(PDHO, PDHC),Max(PDHO, PDHC),"", ColorBlend(ColorPrevDayRange, GetChartBkColor(), 0.9),styleNoRescale|styleCloud|styleNoLabel,Null, Null, 0, -5, 5);
PlotOHLC(PDL,PDL,Min(PDLO, PDLC),Min(PDLO, PDLC),"", ColorBlend(ColorPrevDayRange, GetChartBkColor(), 0.8),styleNoRescale|styleCloud|styleNoLabel,Null, Null, 0, -5, 5);
Plot(IIf(IsToday, PrevClose,Null), "", colorBlack, styleDashed|styleNoRescale|styleNoTitle|styleNoLabel);
}

if(ShowTwoDayRange AND Interval() <= 3600)
{
Plot(TwoDH, "", ColorPrev2DayRange , styleLine|styleNoTitle|styleNoLabel|styleNoRescale);
Plot(TwoDL, "", ColorPrev2DayRange , styleLine|styleNoTitle|styleNoLabel|styleNoRescale);
PlotOHLC(TwoDH,TwoDH,Max(TwoDHO, TwoDHC),Max(TwoDHO, TwoDHC),"", ColorBlend(ColorPrev2DayRange , GetChartBkColor(), 0.8),styleNoRescale|styleCloud|styleNoLabel,Null, Null, 0, -5, 5);
PlotOHLC(TwoDL,TwoDL,Min(TwoDLO, TwoDLC),Min(TwoDLO, TwoDLC),"", ColorBlend(ColorPrev2DayRange , GetChartBkColor(), 0.8),styleNoRescale|styleCloud|styleNoLabel,Null, Null, 0, -5, 5);
}
 
#9
Code:
Period = Param("display length", 375, 2, 1875 ); 
bi = BarIndex(); 
procedure PlotLevel( array, nam, Col,sty ) 
{ 
 x = SelectedValue( bi ); 
 y = SelectedValue( array ); 
 Plot( IIf( bi >= x AND bi < x + Period, y, Null ),nam, Col, sty ); 
 PlotText( nam, x+1, y, Col ); 
} 

if( ParamToggle("Weekly HL", "No|Yes", 1))
{
wcol = ParamColor("Wkly Color", colordarkyellow);
wh = TimeFrameGetPrice("H",inWeekly,-1);
wl = TimeFrameGetPrice("L",inWeekly,-1);

PlotLevel( wh, "\nWH - "+wh+"", wcol,styleLine|stylethick ); 
PlotLevel( wl, "\nWL - "+wl+"", wcol,styleLine|stylethick ); 
}

if( ParamToggle("Y'Day HL", "No|Yes", 1))
{
dcol = ParamColor("Y'Day Color", colortan);
dh = TimeFrameGetPrice("H",indaily,-1);
dl = TimeFrameGetPrice("L",indaily,-1);

PlotLevel( dh, "\nDH - "+dh+"", dcol,styleLine ); 
PlotLevel( dl, "\nDL - "+dl+"", dcol,styleLine); 
}

if( ParamToggle("Today-2 HL", "No|Yes", 1))
{
d2col = ParamColor("D-2 Color", colororange);
d2h = TimeFrameGetPrice("H",indaily,-2);
d2l = TimeFrameGetPrice("L",indaily,-2);

PlotLevel( d2h, "\nD2H - "+d2h+"", d2col,styledashed ); 
PlotLevel( d2l, "\nD2L - "+d2l+"", d2col,styledashed ); 
}



This will help All traders to get Some prominent support and resistances.
This idea of deriving Supp and res i got from Karthik_sri's thread.

Hope this will help u all.

In this AFL u can varry the length of the lines from parameters and mainly it plots lines with respect to the cursor location so if u r backtesting some strategy it may come handy.

Regards
Nice extremist,
May i ask you? did you used Plottext function and used dynamic array in any afl?
 
Last edited:

extremist

Well-Known Member
#10
Nice extremist,
May i ask you? did you used Plottext function and used dynamic array in any afl?
in this same code i'm using plot text.
and bro i'm not The Programmer.
I'm BE Mech i use to hate programming but life demanded it so learnt by reverse engineering the AFL codes.
So i'm unable to understand "dynamic array".
I might have used it but don't know tht it is called as Dynamic array.

Regards
 

Similar threads