Pivot Points on intraday chart AFL needed

veluri1967

Well-Known Member
#1
Hello,

I am in need of AFL in Amibroker, which can automatically draw Pivot Point Lines ie PP, S1, S2, S3, R1, R2, R3 on intraday charts based on previous days eod data.

If anybody really have it, please post it here. Or if u already come across anywhere please give link here.

thank you all.
 

Sunny1

Well-Known Member
#2
_SECTION_BEGIN("Robert's Pivot Points");

//---------------------------------------------------------------------------
// Pivot Pointer
//---------------------------------------------------------------------------
// Now a days each and every trader wants pivot levels for thier day
// trading.But the main feature in this afl is you can get all types of
// pivot point in a single afl, Some of the traders use Woodie pivot,
// caramilla pivot, Fibonacci pivot and most of them used Classical
// pivot, i think this afl will solve all your needs.
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// Please write your comments to [email protected]
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
// This section gets whether they want pivot level for intraday or thier eod
//---------------------------------------------------------------------------

_N(ioreod =ParamList("Pivot Levels for ", "Intraday|EOD"));

if (ioreod=="Intraday")
{
yh = TimeFrameGetPrice( "H", inDaily, -1 );
yl = TimeFrameGetPrice( "L", inDaily, -1 );
yc = TimeFrameGetPrice( "C", inDaily, -1 );
}
else
{
yh = TimeFrameGetPrice( "H", inDaily, 0 );
yl = TimeFrameGetPrice( "L", inDaily, 0 );
yc = TimeFrameGetPrice( "C", inDaily, 0 );
}

//---------------------------------------------------------------------------
// To calculate the Pivot Levels
//---------------------------------------------------------------------------

to = TimeFrameGetPrice( "O", inDaily, 0 );
pivot = (yh + yl + yc) / 3;
range = yh - yl;
_N(pist =ParamList("Select Pivot Type ", "Classical Pivot|Woodie
Pivot|Caramilla Pivot|Fibonacci Pivot"));

if (pist =="Classical Pivot" )
{
r1 = (2 * pivot) - yl ;
s1 = (2 * pivot) - yh ;
r2 = pivot - s1 + r1;
s2 = pivot - (r1 - s1) ;
r3 = 2 * (pivot - yl) + yh ;
s3 = yl - (2 * (yh - pivot));
}

else if(pist =="Woodie Pivot" )
{
pivot = (yh + yl + yc + to) / 4;
r1 = (2 * pivot) - yl;
r2 = pivot + range;
r3 = yh + 2 * (pivot - yl);
r4 = r3 + range;
s1 = (2 * pivot) - yh;
s2 = pivot - range;
s3 = yl - 2 * (yh - pivot);
s4 = S3 - range;
}

else if(pist =="Caramilla Pivot" )
{
r4 = yc + range * 1.1/2;
r3 = yc + range * 1.1/4;
r2 = yc + range * 1.1/6;
r1 = yc + range * 1.1/12;
s1 = yc - range * 1.1/12;
s2 = yc - range * 1.1/6;
s3 = yc - range * 1.1/4;
s4 = yc - range * 1.1/2;
}

else
{
r3 = pivot + 1.000 * (yh - yl);
r2 = pivot + 0.618 * (yh - yl);
r1 = pivot + 0.382 * (yh - yl);
s1 = pivot - 0.382 * (yh - yl);
s2 = pivot - 0.618 * (yh - yl);
s3 = pivot - 1.000 * (yh - yl);
}

//---------------------------------------------------------------------------
// To Plot Pivot Levels in the screen
//---------------------------------------------------------------------------

_N(dsr =ParamList("Draw Intraday Pivot Levels ",
"None|Both|Support|Resistance"));

if (dsr =="Support" OR dsr == "Both")
{
Plot(pivot, "\n Pivot - ",colorGreen,1);
Plot(r1, "Resistance 1 - ",colorDarkRed,1);
Plot(r2, "Resistance 2 - ",colorDarkRed,1);
Plot(r3, "Resistance 3 - ",colorDarkRed,1);
Plot((pivot+r1)/2, "Mid Value of R1 & Pivot ",colorLightBlue,1);
Plot((r3+r2)/2, "Mid Value of R2 & R3 - ",colorLightBlue,1);
Plot((r1+r2)/2, "Mid Value of R1 & R2 - ",colorLightBlue,1);
}

if( dsr == "Resistance" OR dsr == "Both")
{
Plot(pivot, "\n Pivot - ",colorGreen,1);
Plot(s3, "Support 2 - ",colorDarkGreen,1);
Plot(s2, "Support 2 - ",colorDarkGreen,1);
Plot(s1, "Support 1 - ",colorDarkGreen,1);
Plot((s3+s2)/2, "Mid Value of S2 & S3 ",colorWhite,1);
Plot((s1+s2)/2, "Mid Value of S1 & S2 - ",colorWhite,1);
Plot((pivot+s1)/2, "Mid Value of S1 & Pivot ",colorWhite,1);
}

//---------------------------------------------------------------------------
// Printing the pivot level in interpretation window
//---------------------------------------------------------------------------


printf(Name()+ "\n\nResistance - 3 | %g\nResistance - 2 | %g\nResistance -
1 | %g\n" +
"Pivot | %g\nSupport - 1 | %g\nSupport - 2 |
%g\nSupport - 3 | %g",
r3,r2,r1,pivot,s1,s2,s3);


//---------------------------------------------------------------------------
// This section is for Exploration
//---------------------------------------------------------------------------

Filter = 1;
AddColumn(r3,"Resistance 3");
AddColumn(r2,"Resistance 2");
AddColumn(r1,"Resistance 1");
AddColumn(Pivot,"Pivot");
AddColumn(s1,"Support 1");
AddColumn(s2,"Support 2");
AddColumn(s3,"Support 3");

//---------------------------------------------------------------------------
// Add Pivot levels along with the title
//---------------------------------------------------------------------------

_N(Title = EncodeColor(colorBrown)+ StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}}
Open %g, Hi %g, Lo %g, Close %g(%.1f%%)\n"+
EncodeColor(4)+"Resistance 3 -=- %g ::::: Resistance 2 -=- %g ::::: Resistance
1 -=- %g :::::"+
EncodeColor(colorGreen)+" Pivot -=- %g"+
EncodeColor(29)+"\nSupport 1 -=- %g ::::: Support 2 -=- %g ::::: Support 3 -=-
%g\n ",
O, H, L, C,SelectedValue( ROC( C, 1 ) ),r3,r2,r1,pivot,s1,s2,s3));

//---------------------------------------------------------------------------
// End of Pivot Point
//---------------------------------------------------------------------------

_SECTION_END();
 

Sunny1

Well-Known Member
#3
OR THIS ONE

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

H1=SelectedValue( TimeFrameGetPrice( "H", inDaily, -1 ));
L1=SelectedValue(TimeFrameGetPrice( "L", inDaily, -1 ));
C1=SelectedValue(TimeFrameGetPrice( "C", inDaily, -1 ));

/*PIVOT Calculation*/
p = ( H1+ L1 + C1 )/3;
s1 = (2*p)-H1;
r1 = (2*p)-L1;
s2 = p -(H1 - L1);
s3 = S1 - (H1-L1);
r2 = p +(H1 - L1);
r3 = R1 +(H1-L1);

Plot (p,"Pivot",25,1);
Plot (r1,"R1",12,1);
Plot (r2,"R2",12,1);
Plot (r3,"R3",12,1);
Plot (s1,"S1",3,1);
Plot (s2,"S2",3,1);
Plot (s3,"S3",3,1);
 

veluri1967

Well-Known Member
#4
Dear Sunny,

You are really amazing. I have not yet tried them. But the way you have responded to my call, is really amazing.:clapping:

Thank you very much.
 

cbosein

Active Member
#5
Hi Ravi P(,

Thanks for your AFL for Pivot points (Multi).

Requesting you for posting trading strategy (entry& exit of Long/short) & setup (TF, which pivot, in parameter selection) with this afl codes.

I am using this PIVOt Point AFL for nearly a year now.
It has given me good returns
Best Wishes.
Enjoy.

_SECTION_BEGIN("Multi Pivots");
_SECTION_BEGIN ("Multi Pivots - StockManiacs");
//chart colors
SetChartBkColor(ParamColor("Outer panel",colorSkyblue));
SetChartBkGradientFill(
ParamColor("Inner panel upper",colorLightBlue),
ParamColor("Inner panel lower",colorLightYellow)
,ParamColor("TitleBlock",colorWhite));
SetChartOptions(0,chartShowDates|chartShowArrows|chartLogarithmic|chartWrapTitle);

//basic price plotting
_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() );

T_F =ParamList("Pivot T_F","iDay|Hourly|2_Hrs|3_Hrs|4_Hrs|EOD|Weekly|Monthly");

if (T_F=="iDay")
{
H_1 = TimeFrameGetPrice( "H", inDaily, -1 );
L_1 = TimeFrameGetPrice( "L", inDaily, -1 );
C_1 = TimeFrameGetPrice( "C", inDaily, -1 );
O = TimeFrameGetPrice("O", inDaily); // current day's open
}
else if (T_F == "Hourly")
{
H_1 = TimeFrameGetPrice( "H", inHourly, -1 );
L_1 = TimeFrameGetPrice( "L", inHourly, -1 );
C_1 = TimeFrameGetPrice( "C", inHourly, -1 );
O = TimeFrameGetPrice( "O", inHourly );
}
else if (T_F == "2_Hrs")
{
H_1 = TimeFrameGetPrice( "H", inHourly*2, -1 );
L_1 = TimeFrameGetPrice( "L", inHourly*2, -1 );
C_1 = TimeFrameGetPrice( "C", inHourly*2, -1 );
O = TimeFrameGetPrice( "O", inHourly*2);
}
else if (T_F == "3_Hrs")
{
H_1 = TimeFrameGetPrice( "H", inHourly*3, -1 );
L_1 = TimeFrameGetPrice( "L", inHourly*3, -1 );
C_1 = TimeFrameGetPrice( "C", inHourly*3, -1 );
O = TimeFrameGetPrice( "O", inHourly*3);
}
else if (T_F == "4_Hrs")
{
H_1 = TimeFrameGetPrice( "H", inHourly*4, -1 );
L_1 = TimeFrameGetPrice( "L", inHourly*4, -1 );
C_1 = TimeFrameGetPrice( "C", inHourly*4, -1 );
O = TimeFrameGetPrice( "O", inHourly*4 );

}
else if (T_F == "EOD")
{
H_1 = TimeFrameGetPrice( "H", inDaily, 0 );
L_1 = TimeFrameGetPrice( "L", inDaily, 0 );
C_1 = TimeFrameGetPrice( "C", inDaily, 0 );
O = TimeFrameGetPrice( "O", inDaily );

}
else if (T_F == "Weekly")
{
H_1 = TimeFrameGetPrice( "H", inWeekly, -1 );
L_1 = TimeFrameGetPrice( "L", inWeekly, -1 );
C_1 = TimeFrameGetPrice( "C", inWeekly, -1 );
O = TimeFrameGetPrice( "O", inWeekly );
}
else if (T_F == "Monthly")
{
H_1 = TimeFrameGetPrice( "H", inMonthly, -1 );
L_1 = TimeFrameGetPrice( "L", inMonthly, -1 );
C_1 = TimeFrameGetPrice( "C", inMonthly, -1 );
O = TimeFrameGetPrice( "O", inMonthly );
}

// To calculate the Pivot Levels

R = H_1 - L_1; // Range
_N(Pivot =ParamList("Pivot Type ", "Classical|Woodies|Fibonacci|WF"));

if (Pivot =="Classical" )
{
PP = (H_1 + L_1 + C_1) / 3;
r1 = (2 * PP) - L_1 ;
s1 = (2 * PP) - H_1 ;
r2 = PP - s1 + r1;
s2 = PP - (r1 - s1) ;
r3 = 2 * (PP - L_1) + H_1 ;
s3 = L_1 - (2 * (H_1 - PP));
r4 = Null;
s4 = Null;
}
else if(Pivot =="Woodies" )
{
PP = (H_1 + L_1 + C_1 + O) / 4;
r1 = (2 * PP) - L_1;
r2 = PP + R;
r3 = H_1 + 2 * (PP - L_1);
r4 = r3 + R;
s1 = (2 * PP) - H_1;
s2 = PP - R;
s3 = L_1 - 2 * (H_1 - PP);
s4 = S3 - R;
}

else if(Pivot =="Fibonacci" )
{
PP = (H_1 + L_1 + C_1) / 3;
r3 = PP + 1.000 * R;
r2 = PP + 0.618 * R;
r1 = PP + 0.382 * R;
s1 = PP - 0.382 * R;
s2 = PP - 0.618 * R;
s3 = PP - 1.000 * R;
r4 = Null;
s4 = Null;
}
else if (Pivot == "WF")
{
PP = (H_1 + L_1 + O + O) / 4;
s1 = PP - (R * 0.38);
s2 = PP - (R * 0.62);
s3 = PP - (R * 1.272);
r1 = PP + (R * 0.38);
r2 = PP + (R * 0.62);
r3 = PP + (R * 1.272);
r4 = Null;
s4 = Null;
}

//Defining TF on charts
procedure AddT_fParam(defaultvalue)
{
global T_F;
T_F = ParamList("Time Frame", List = "iDay|Hourly|2_Hrs|3_Hrs|4_Hrs|EOD|Weekly|Monthly", defaultvalue);

if(T_F == "iDay") T_F = inDaily;
else if(T_F == "Hourly") T_F = inHourly;
else if(T_F == "2_Hrs") T_F = inHourly*2;
else if(T_F == "3_Hrs") T_F = inHourly*3;
else if(T_F == "4_Hrs") T_F = inHourly*4;
else if(T_F == "EOD") T_F = inDaily;
else if(T_F == "Weekly") T_F = inWeekly;
else if(T_F == "Montly") T_F = inMonthly;
}

// Plot Pivot Levels in the charts

Plot (PP,"PP",colorViolet,styleDots,styleThick,1);
Plot (r1,"R1",colorDarkRed,styleLine,styleThick,1);
Plot (r2,"R2",colorDarkRed,styleLine,styleThick,1);
Plot (r3,"R3",colorDarkRed,styleLine,styleThick,1);
Plot (s1,"S1",colorDarkGreen,styleLine,styleThick,1);
Plot (s2,"S2",colorDarkGreen,styleLine,styleThick,1);
Plot (s3,"S3",colorDarkGreen,styleLine,styleThick,1);
Plot (r4,"R4",colorDarkRed,styleLine,styleThick,1);
Plot (s4,"S4",colorDarkGreen,styleLine,styleThick,1);


// Add Pivot levels on charts as text
Title = Title + EncodeColor(colorDarkTeal)+
"\n,Pivot T_F = "+T_F + " \n " +
EncodeColor(colorRed)+"R4 = "+ r4 +"\n"+
EncodeColor(colorRed)+"R3 = "+ r3 +"\n"+
EncodeColor(colorRed)+"R2 = "+ r2 + "\n"+
EncodeColor(colorRed)+"R1 = "+ r1 + "\n"+ "\n"+
EncodeColor(colorViolet)+"PP = "+ PP + "\n"+ "\n" +
EncodeColor(colorGreen)+"S1 = "+ s1 + "\n"+
EncodeColor(colorGreen)+"S2 = "+ s2 + "\n"+
EncodeColor(colorGreen)+"S3 = "+ s3 + "\n"+
EncodeColor(colorGreen)+"S4 = "+ s4 + " \n" ;

_SECTION_END ();
_SECTION_END();
 

Similar threads