AFL MA50
//Bismillahi wassholatu wassalamu 'ala rosulillah
_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() );
MA50=MA(C,50);
Plot( MA50, "
MA50", coloraqua, ParamStyle("Style") );
Hrgbeli = SelectedValue(Ref(C,0));
Maxsementara=SelectedValue(Ref(H,0));
for( i = 0; NOT(SelectedValue(Ref(C,-i-1)) < SelectedValue(Ref(MA(C,50),-i-1)) AND SelectedValue(Ref(C,-i)) > SelectedValue(Ref(MA(C,50),-i))); i++ )
{
Hrgbeli = SelectedValue(Ref(C,-i-1));
Maxsementara = Max(Maxsementara,SelectedValue(Ref(H,-i-1)));
}
Loss = Param("persen loss",6,5,20,1);
persenlos = Hrgbeli - Hrgbeli*Loss/100;
Plot (hrgbeli, "
hargabeli", colorBlue, ParamStyle("Style") );
Plot (persenlos, "cutloss (" + Loss + "%)", colorRed, ParamStyle("Style")|styleNoRescale );
Plot (Maxsementara, "best H", colorGreen, ParamStyle("Style") );
trailing5persenDariPuncak = Maxsementara-5/100*Maxsementara; Plot (trailing5persenDariPuncak, "5% dari puncak", colorRed, styleDashed );
trailing10persenDariPuncak = Maxsementara-10/100*Maxsementara; Plot (trailing10persenDariPuncak, "10% dari puncak", colorAqua, styleDashed );
trailing5persenDariPuncak = Maxsementara-15/100*Maxsementara; Plot (trailing5persenDariPuncak, "15% dari puncak", colorRed, styleDashed |styleNoRescale );
bestgain = (Maxsementara-hrgbeli)/hrgbeli*100; //maksudnya adalah profit jika bisa jual di high
Currentprofit = (C-hrgbeli)/hrgbeli*100;
Plot (Currentprofit , "
Currentprofit ", colorblack, styleNoDraw |styleNoRescale );
Plot (bestgain, "best gain", colorBlack, styleNoDraw |styleNoRescale );
PlotText("BUY" , SelectedValue(BarIndex()-10) , Hrgbeli, colorBlack,colorYellow);
if (SelectedValue(Currentprofit) <25 )
{Plot (Hrgbeli+25/100*Hrgbeli, "25%", colorBlue, styleNoLabel|styleNoTitle|styleNoRescale );
PlotText("25 %" , SelectedValue(BarIndex()-10) , Hrgbeli+25/100*Hrgbeli, colorBlack,colorYellow);}
else
{if (SelectedValue(Currentprofit) <50)
{Plot (Hrgbeli+50/100*Hrgbeli, "50%", colorBlue, styleNoLabel|styleNoTitle|styleNoRescale );
PlotText("50 %" , SelectedValue(BarIndex()-10) , Hrgbeli+50/100*Hrgbeli, colorBlack,colorYellow);}
else
{PlotText("100 %" , SelectedValue(BarIndex()-10) , Hrgbeli+100/100*Hrgbeli, colorBlack,colorYellow);
Plot (Hrgbeli+100/100*Hrgbeli, "100%", colorBlue, styleNoLabel|styleNoTitle|styleNoRescale );}}
Buy=Cross(C,MA(C,50));
PlotShapes(IIf(Buy, shapeUpArrow , shapeNone), colorBlue,0,L,Offset=-10) ;
Sell=Cross(MA(C,50),C);
PlotShapes(IIf(Sell, shapeDownArrow , shapeNone), colorRed,0,H,Offset=-10) ;
_SECTION_END();
Comments
Post a Comment