_SECTION_BEGIN("pivots hourly 2");
_SECTION_BEGIN ("Chart Setup");
SetChartBkColor(ParamColor("Outer panel",colorSkyblue));
SetChartBkGradientFill(
ParamColor("Upper Inner panel",colorLightBlue),
ParamColor("Lower Inner panel",colorLightYellow));
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() );
_SECTION_END ();
_SECTION_BEGIN ("Pivot Levels");
//--- Created by : KelvinHand -------
T_F =ParamList("TF Multiplier","Hour|Min|Day|Week|Month");
iInterval = Param("Interval", 1, 1);
Note1=ParamStr("-- Colors --", "PP, S1..S3, R1..R3");
PP_Color=ParamColor("PP Color",colorViolet);
Rn_Color=ParamColor("Rn Color",colorDarkRed);
Sn_Color=ParamColor("Sn Color",colorDarkGreen);
Note1=ParamStr("-- Styles --", "PP, R1S1, R2S2, R3S3");
PP_Style=ParamStyle("PP", styleDots|styleThick, maskAll);
R1S1_Style=ParamStyle("R1S1 Style", styleThick, maskAll);
R2S2_Style=ParamStyle("R2S2 Style", styleLine, maskAll);
R3S3_Style=ParamStyle("R3S3 Style", styleDashed,maskAll);
_SECTION_END ();
shift=-1;
switch (T_F)
{
case "Day": iPeriod = inDaily; break;
case "Hour": iPeriod = inHourly; break;
case "Min": iPeriod = in1Minute; break;
}
xTF = iInterval*iPeriod;
H1 = TimeFrameGetPrice( "H", xTF, shift );
L1 = TimeFrameGetPrice( "L", xTF, shift );
C1 = TimeFrameGetPrice( "C", xTF, shift );
// To calculate the Pivot Levels
PP = (H1 + L1 + C1) / 3;
R1 = (2 * PP) - L1 ;
S1 = (2 * PP) - H1 ;
R2 = PP - s1 + r1;
S2 = PP - (r1 - s1) ;
R3 = 2 * (PP - L1) + H1 ;
S3 = L1 - (2 * (H1 - PP));
// Plot Pivot Levels in the charts
//Plot (PP,"",PP_Color,PP_Style);
//Plot (R1,"",Rn_Color,R1S1_Style);
//Plot (S1,"",Sn_Color,R1S1_Style);
//Plot (R2,"",Rn_Color,R2S2_Style);
//Plot (S2,"",Sn_Color,R2S2_Style);
//Plot (R3,"",Rn_Color,R3S3_Style);
//Plot (S3,"",Sn_Color,R3S3_Style);
/*
BC = (High + Low)/2
TC = (Pivot - BC) + Pivot
*/
BC = (H1 + L1)/2;
TC = (PP - BC) + PP;
PlotOHLC(TC,BC,TC,BC,"",colorGrey50,styleNoLabel|styleCloud);
// Add Pivot levels on charts as text
Title = Title + EncodeColor(colorDarkTeal)+
"\nPivot T_F = "+NumToStr(iInterval,1.0)+" "+T_F + "\n" +
EncodeColor(Rn_Color)+"R3 = "+ r3 +"\n"+
EncodeColor(Rn_Color)+"R2 = "+ r2 + "\n"+
EncodeColor(Rn_Color)+"R1 = "+ r1 + "\n"+ "\n"+
EncodeColor(PP_Color)+"PP = "+ PP + "\n"+ "\n" +
EncodeColor(Sn_Color)+"S1 = "+ s1 + "\n"+
EncodeColor(Sn_Color)+"S2 = "+ s2 + "\n"+
EncodeColor(Sn_Color)+"S3 = "+ s3 + "\n";
_SECTION_END ();
x=PP[BarCount-1];
for(i=BarCount-2; i>0; i--)
if (PP[i]!=x)
{
i++;
break;
}
for(j=0; j<i; j++)
{
pp[j]=Null;
R1[j]=Null;
S1[j]=Null;
R2[j]=Null;
S2[j]=Null;
R3[j]=Null;
S2[j]=Null;
}
// Plot Pivot Levels in the charts
Plot (PP,"",PP_Color,PP_Style|styleNoRescale);
Plot (R1,"",Rn_Color,R1S1_Style|styleNoRescale);
Plot (S1,"",Sn_Color,R1S1_Style|styleNoRescale);
Plot (R2,"",Rn_Color,R2S2_Style|styleNoRescale);
Plot (S2,"",Sn_Color,R2S2_Style|styleNoRescale);
Plot (R3,"",Rn_Color,R3S3_Style|styleNoRescale);
Plot (S3,"",Sn_Color,R3S3_Style|styleNoRescale);
_SECTION_END();