Hi,
I haveCode button (use to enter/paste AFL formula)
attached an AFL of Classic Pivot.
I want to plot R2/R3 levels only if Today’s high crossed above R1,Else those lines should not be plotted.
Likewise i want to plot S2/S3 lines only if today’s Low crossed below S1,Else those lines should not be plotted.
I am looking for help to modify the Plot lines in the Attached AFL.
Thanks and Regards,
Gloria Filamino
_SECTION_BEGIN ("Chart Setup");
SetChartBkColor(ParamColor("Outer panel",colorBlack));
SetChartBkGradientFill(
ParamColor("Upper Inner panel",colorBlack),
ParamColor("Lower Inner panel",colorBlack));
SetChartOptions(0,chartShowDates|chartShowArrows|chartLogarithmic|chartWrapTitle);
xH=BarsSince(Day()!=Ref(Day(),-1));
yH=HHV(H,xH+1);
Hightoday=IIf(xH==0,yH,Ref(yH,0));
xL=BarsSince(Day()!=Ref(Day(),-1));
yL=LLV(L,xL+1);
LowTODAY=IIf(xL==0,yL,Ref(yL,0));
//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","Day|Min|Hour|Week|Month");
iInterval = Param("Interval", 1, 1);
Note1=ParamStr("-- Colors --", "PP, S1..S3, R1..R3");
PP_Color=ParamColor("PP Color",coloryellow);
Rn_Color=ParamColor("Rn Color",colorRed);
Sn_Color=ParamColor("Sn Color",colorbrightGreen);
Note1=ParamStr("-- Styles --", "PP, R1S1, R2S2, R3S3");
PP_Style=ParamStyle("PP", styleLine, maskAll);
R1S1_Style=ParamStyle("R1S1 Style", styleLine, maskAll);
R2S2_Style=ParamStyle("R2S2 Style", styleLine, maskAll);
R3S3_Style=ParamStyle("R3S3 Style", styleLine, 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);
// 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 ();