AFL needed for Pivots

amitrandive

Well-Known Member
#1
Dear All

I need the AFL for intraday for the attached image , where all the daily pivot levels are displayed.Also it would be very helpful if it displays the weekely pivot levels in a similar fashion.

Thanks
Amit
 
Last edited:

johnnypareek

Well-Known Member
#2
pLEASE SELECT IN PARAMETER

HTML:
_SECTION_BEGIN("Price");

GraphXSpace=5;
SetChartOptions(0,chartShowArrows|chartShowDates);
_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 )) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
up=4969;
dn=4952;
//Plot(up,"UP Break",5,8);
//Plot(dn,"DN Break",4,8);

_SECTION_END();
 

amitrandive

Well-Known Member
#3
Dear Johnny

This AFL plots only the Price , and nothing in the parameters can be used to plot the pivots.

I want an AFL which on any time frame would plot all the daliy pivot(P,S1,S2,S3,R1,R2 and R3 levels ) and also the weekely pivot levels , as shown in the attached sketch.

Thanks
Amit
 

johnnypareek

Well-Known Member
#4
sorry wrongly posted

Here it is, select in parameters

HTML:
_SECTION_BEGIN("Price");

GraphXSpace=5;
SetChartOptions(0,chartShowArrows|chartShowDates);
_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 )) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 

_SECTION_END();



TimeFrameSet(inDaily);
DayH= LastValue(Ref(H,-1));
DayL= LastValue(Ref(L,-1));
DayC= LastValue(Ref(C,-1));
TimeFrameRestore();

//Daily 
PP = (DayL + DayH + DayC)/3;
R1  =  (2 * PP) - DayL;
S1  =  (2 * PP)  - DayH;
R2  =  PP + (DayH - DayL);
S2  =  PP - (DayH - DayL);
R3 = DayH + 2*(PP - DayL);
S3 = DayL - 2*(DayH - PP);

TimeFrameSet(inWeekly);
MonthH= LastValue(Ref(H,-1));
MonthL= LastValue(Ref(L,-1));
MonthC= LastValue(Ref(C,-1));
TimeFrameRestore();

//weekly 
MPP = (MonthL + MonthH + MonthC)/3;
MR1  =  (2 * MPP) - MonthL;
MS1  =  (2 * MPP)  - MonthH;
MR2  =  MPP + (MonthH- MonthL);
MS2  =  MPP - (MonthH- MonthL);
MR3  =  MonthH + 2*(MPP - MonthL);
MS3 =   MonthL - 2*(MonthH- MPP);

SHOWDPIVOTS = ParamToggle("Daily Pivots", "No|Yes",0);
SHOWMPIVOTS = ParamToggle("weekly Pivots","No|Yes",0); 
SHOW3 = ParamToggle("3rd Line", "No|Yes",0); 

	
for (i=BarCount-2;i>(BarCount-13);i--)//set the last bars to the final PP value
{
	PP[i] = PP[BarCount-1];
	R1[i] = R1[BarCount-1];
	R2[i] = R2[BarCount-1];
	S1[i] = S1[BarCount-1];
	S2[i] = S2[BarCount-1];

	ColorG[i] = colorGreen;
	ColorB[i] = colorBlue;
	ColorR[i] = colorRed;
}

//
// Conceal all but the trailing portion of the line
//
for (i=0;i<BarCount-15;i++) //hide the line except most recent 15 bars
{
	ColorR[i] = ColorG[i] = ColorB[i] = colorWhite;
}


if (SHOWDPIVOTS) {
Plot(R2, "R2",ColorG);
Plot(R1, "R1",ColorG);
Plot(PP, "PP",ColorB);
Plot(S1, "S1",ColorR);
Plot(S2, "S2",ColorR);
}

if (SHOWDPIVOTS & SHOW3)
{
		Plot(S3, "S3",ColorR);
		Plot(R3, "R3",ColorG);
}



if (SHOWMPIVOTS) {
Plot(MPP, "MPP",ColorB);
Plot(MR1, "MR1",ColorG);
Plot(MS1, "MS1",ColorR);
Plot(MS2, "MS2",ColorR);
Plot(MR2, "MR2",ColorG);
}

if (SHOWMPIVOTS & SHOW3)
{
		Plot(MR3, "MR3",ColorG);
		Plot(MS3, "MS3",ColorR);
}
 

amitrandive

Well-Known Member
#5
Dear Johnny

I apologize that did not make myself clear the first time.I need an AFL on which I am able to get the current day and all the previous day daily pivot points.And also the weekly pivot point.

Please see attached images for explaining my point.

Thanks
Amit
 
Last edited:

johnnypareek

Well-Known Member
#6
Hmm chk out this

HTML:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();


_SECTION_BEGIN("pivots mw");
SetChartBkColor(2) ;
k=IIf(ParamList("select type","daily|next day")=="daily",-1,0);
k1=-1;
TimeFrameSet(inDaily);
day_h= LastValue(Ref(H,K));
day_l= LastValue(Ref(L,K));
day_c= LastValue(Ref(C,K));
TimeFrameRestore();
 
TimeFrameSet(inWeekly);
Week_h= LastValue(Ref(H,K1));
Week_l= LastValue(Ref(L,K1));;
Week_c= LastValue(Ref(C,K1));;
TimeFrameRestore();
 
TimeFrameSet(inMonthly);
month_h= LastValue(Ref(H,K1));
month_l= LastValue(Ref(L,K1));
month_c= LastValue(Ref(C,K1));
TimeFrameRestore();
 
/*--------------------------------------*/
// day
DH=Day_h;
DL=Day_L;
DC=Day_C;
 
// DAY PIVOT Calculation
pd = ( DH+ DL + DC )/3;
sd1 = (2*pd)-DH;
sd2 = pd -(DH - DL);
sd3 = Sd1 - (DH-DL);
sd4 = Sd2 - (DH-DL);
sd5 = Sd3 - (DH-DL);
rd1 = (2*pd)-DL;
rd2 = pd +(DH -DL);
rd3 = rd1 +(DH-DL);
rd4 = rd2 +(DH-DL);
rd5 = rd3 +(DH-DL);
dp=pd;
// week
WH=Week_h;
WL=Week_l;
WC=Week_c;
 
// WEEK PIVOT Calculation
pw = ( WH+ WL + WC )/3;
sw1 = (2*pw)-WH;
sw2 = pw -(WH - WL);
sw3 = Sw1 - (WH-WL);
sw4 = Sw2 - (WH-WL);
rw1 = (2*pw)-WL;
rw2 = pw +(WH -WL);
rw3 = rw1 +(WH-WL);
rw4 = rw2 +(WH-WL);
 
 
// month
MH=month_h;
ML=month_l;
MC=month_c;
 
// MONTH PIVOT Calculation
pm = ( MH+ ML + MC )/3;
sm1 = (2*pm)-MH;
sm2 = pm -(MH - ML);
sm3 = Sm1 - (MH-ML);
rm1 = (2*pm)-ML;
rm2 = pm +(MH -ML);
rm3 = rm1 +(MH-ML);
 
ppl = ParamToggle("Plot Pivot Levels","Off|On",1);
numbars = LastValue(Cum(Status("barvisible")));
fraction= IIf(StrRight(Name(),3) == "", 3.2, 3.2);
hts = Param("slide all",33,-1000,1000,1);
 
 
{
if(ppl==1) {
Plot(pd,"",colorPink,styleLine|styleDots|styleThick|styleNoRescale);
Plot(sd1,"",colorPink,styleDashed|styleNoRescale);
Plot(sd2,"",colorPink, styleDashed|styleNoRescale);
Plot(sd3,"",colorPink, styleDashed|styleNoRescale);
Plot(sd4,"",colorPink, styleDashed|styleNoRescale);
Plot(sd5,"",colorPink, styleDashed|styleNoRescale);
Plot(rd1,"",colorPink, styleDashed|styleNoRescale);
Plot(rd2,"",colorPink, styleDashed|styleNoRescale);
Plot(rd3,"",colorPink, styleDashed|styleNoRescale);
Plot(rd4,"",colorPink, styleDashed|styleNoRescale);
Plot(rd5,"",colorPink, styleDashed|styleNoRescale);
 
Plot(pw,"",colorGreen,styleLine|styleDots|styleThick|styleNoRescale);
Plot(sw1,"",colorDarkGreen, styleDashed|styleNoRescale);
Plot(sw2,"",colorDarkGreen, styleDashed|styleNoRescale);
Plot(sw3,"",colorDarkGreen, styleDashed|styleNoRescale);
Plot(sw4,"",colorDarkGreen, styleDashed|styleNoRescale);
Plot(rw1,"",colorDarkGreen, styleDashed|styleNoRescale);
Plot(rw2,"",colorDarkGreen, styleDashed|styleNoRescale);
Plot(rw3,"",colorDarkGreen, styleDashed|styleNoRescale);
Plot(rw4,"",colorDarkGreen, styleDashed|styleNoRescale);
 
 
/*Plot(pm,"",colorViolet,styleLine|styleDots|styleThick|styleNoRescale);
Plot(sm1,"",colorViolet, styleDashed|styleNoRescale);
Plot(sm2,"",colorViolet, styleDashed|styleNoRescale);
Plot(sm3,"",colorViolet, styleDashed|styleNoRescale);
Plot(rm1,"",colorViolet, styleDashed|styleNoRescale);
Plot(rm2,"",colorViolet, styleDashed|styleNoRescale);
Plot(rm3,"",colorViolet, styleDashed|styleNoRescale);
 */
i=1;
 
PlotText(" D-PVT = " + WriteVal(pd,fraction), LastValue(BarIndex())-(numbars/Hts), dp, colorPink);
PlotText(" DR1 = " + WriteVal(rd1,fraction), LastValue(BarIndex())-(numbars/Hts), rd1 , colorPink);
PlotText(" DS1 = " + WriteVal(sd1,fraction), LastValue(BarIndex())-(numbars/Hts), sd1 , colorPink);
PlotText(" DR2 = " + WriteVal(rd2,fraction), LastValue(BarIndex())-(numbars/Hts), rd2 , colorPink);
PlotText(" DS2 = " + WriteVal(sd2,fraction), LastValue(BarIndex())-(numbars/Hts), sd2 , colorPink);
PlotText(" DR3 = " + WriteVal(rd3,fraction), LastValue(BarIndex())-(numbars/Hts), rd3 , colorPink);
PlotText(" DS3 = " + WriteVal(sd3,fraction), LastValue(BarIndex())-(numbars/Hts), sd3 , colorPink);
PlotText(" DR4 = " + WriteVal(rd4,fraction), LastValue(BarIndex())-(numbars/Hts), rd4 , colorPink);
PlotText(" DS4 = " + WriteVal(sd4,fraction), LastValue(BarIndex())-(numbars/Hts), sd4 , colorPink);
PlotText(" DR5 = " + WriteVal(rd4,fraction), LastValue(BarIndex())-(numbars/Hts), rd5 , colorPink);
PlotText(" DS5 = " + WriteVal(sd4,fraction), LastValue(BarIndex())-(numbars/Hts), sd5 , colorPink);
 
PlotText(" W-PVT = " + WriteVal(pw,fraction), LastValue(BarIndex())-(numbars/Hts), pw , colorGreen);
 
PlotText(" WR1 = " + WriteVal(rw1,fraction), LastValue(BarIndex())-(numbars/Hts), rw1 , colorGreen);
PlotText(" WS1 = " + WriteVal(sw1,fraction), LastValue(BarIndex())-(numbars/Hts), sw1 , colorGreen);
PlotText(" WR2 = " + WriteVal(rw2,fraction), LastValue(BarIndex())-(numbars/Hts), rw2 , colorGreen);
PlotText(" WS2 = " + WriteVal(sw2,fraction), LastValue(BarIndex())-(numbars/Hts), sw2 , colorGreen);
PlotText(" WR3 = " + WriteVal(rw3,fraction), LastValue(BarIndex())-(numbars/Hts), rw3 , colorGreen);
PlotText(" WS3 = " + WriteVal(sw3,fraction), LastValue(BarIndex())-(numbars/Hts), sw3 , colorGreen);
PlotText(" WR4 = " + WriteVal(rw4,fraction), LastValue(BarIndex())-(numbars/Hts), rw4 , colorGreen);
PlotText(" WS4 = " + WriteVal(sw4,fraction), LastValue(BarIndex())-(numbars/Hts), sw4 , colorGreen);
 /*
PlotText(" M-PVT = " + WriteVal(pm,fraction), LastValue(BarIndex())-(numbars/Hts), pm , colorViolet);
 
PlotText(" MR1 = " + WriteVal(rm1,fraction), LastValue(BarIndex())-(numbars/Hts), rm1 ,colorViolet );
PlotText(" MS1 = " + WriteVal(sm1,fraction), LastValue(BarIndex())-(numbars/Hts), sm1 ,colorViolet );
PlotText(" MR2 = " + WriteVal(rm2,fraction), LastValue(BarIndex())-(numbars/Hts), rm2 ,colorViolet);
PlotText(" MS2 = " + WriteVal(sm2,fraction), LastValue(BarIndex())-(numbars/Hts), sm2 , colorViolet);
PlotText(" MR3 = " + WriteVal(rm3,fraction), LastValue(BarIndex())-(numbars/Hts), rm3 , colorViolet);
PlotText(" MS3 = " + WriteVal(sm3,fraction), LastValue(BarIndex())-(numbars/Hts), sm3 , colorViolet);
 */
}}
 
//--end----------------------------------------------------------------------------
_SECTION_END();
 
#7
Dear Johnny

I apologize that did not make myself clear the first time.I need an AFL on which I am able to get the current day and all the previous day daily pivot points.And also the weekly pivot point.

Please see attached images for explaining my point.

Thanks
Amit


Hello Johnny ji,

Kindly provide Pivot points afl for every day as shown in picture by Amit in above post (Pls watch white image.. Daily pivots shown)

One u posted is for Single day only.


Thanx you in advance
 

rrrajguru

Well-Known Member
#9
Shruti, I think you are searching for this one.........



Code:
_SECTION_BEGIN("Price");
SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}},{{VALUES}},\n Op - %g \n Hi - %g \n Lo - %g \n Cl - %g", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));
Plot( C, "Close", ParamColor("Color", colorBlack ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() ); 
_SECTION_END();


// Pivot Levels //
numbars = LastValue(Cum(Status("barvisible")));
hts = -33.5;
DayH = TimeFrameGetPrice("H", inDaily, -1); DayHI = LastValue (DayH,1);// yesterdays high
DayL = TimeFrameGetPrice("L", inDaily, -1); DayLI = LastValue (DayL,1); // yesterdays low
DayC = TimeFrameGetPrice("C", inDaily, -1); // yesterdays close
DayO = TimeFrameGetPrice("O", inDaily); // current day open
DayH2= TimeFrameGetPrice("H", inDaily, -2); DayH2I = LastValue (DayH2,1); // Two days before high
DayL2= TimeFrameGetPrice("L", inDaily, -2); DayL2I = LastValue (DayL2,1); // Two days before low
DayH3= TimeFrameGetPrice("H", inDaily, -3); DayH3I = LastValue (DayH3,1); // Three days before high
DayL3= TimeFrameGetPrice("L", inDaily, -3); DayL3I = LastValue (DayL3,1); // Three days before low

PP = (DayL + DayH + DayC)/3; PPI = LastValue (PP,1); // Pivot
R1 = (PP * 2) - DayL; R1I = LastValue (R1,1); // Resistance 1
S1 = (PP * 2) - DayH; S1I = LastValue (S1,1); // Support 1
R2 = PP + R1 - S1; R2I = LastValue (R2,1); // Resistance 2
S2 = PP - R1 + S1; S2I = LastValue (S2,1); // Support 2
R3 = PP + R2 - S1; R3I = LastValue (R3,1); // Resistance 3
S3 = PP - R2 + S1; S3I = LastValue (S3,1); // Support 3

ppl = ParamToggle("Pivot Levels","Show|Hide",1);
if(ppl==1) {
Plot(PP, "PP",colorYellow,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(R1, "R1",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(S1, "S1",colorGreen,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(R2, "R2",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(S2, "S2",colorGreen,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(R3, "R3",colorViolet,styleDots|styleNoLine|styleNoRescale|styleNoTitle);
Plot(S3, "S3",colorGreen,styleDots|styleNoLine|styleNoRescale|styleNoTitle);

PlotText(" Pivot ", LastValue(BarIndex())-(numbars/Hts), PPI, colorYellow);
PlotText(" R1 " , LastValue(BarIndex())-(numbars/Hts), R1I, colorViolet);
PlotText(" S1 " , LastValue(BarIndex())-(numbars/Hts), S1I, colorViolet);
PlotText(" R2 " , LastValue(BarIndex())-(numbars/Hts), R2I, colorViolet);
PlotText(" S2 " , LastValue(BarIndex())-(numbars/Hts), S2I, colorViolet);
PlotText(" R3 " , LastValue(BarIndex())-(numbars/Hts), R3I, colorViolet);
PlotText(" S3 " , LastValue(BarIndex())-(numbars/Hts), S3I, colorViolet);
}

////////////////////////////////////////////////////////////////////////////////
 

Similar threads

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?