AFL FRACTAL
// bismillahi wassholatu wassalamu 'ala rosulillah
_SECTION_BEGIN("SimpleFractal");
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() );
UpFractal= ValueWhen(
(Ref(H,-2) >= Ref(H, -4)) AND
(Ref(H,-2) >= Ref(H, -3)) AND
(Ref(H,-2) >= Ref(H, -1)) AND
(Ref(H,-2) >= H), Ref(H,-2));
DownFractal= ValueWhen(
(Ref(L,-2) <= Ref(L, -4)) AND
(Ref(L,-2) <= Ref(L, -3)) AND
(Ref(L,-2) <= Ref(L, -1)) AND
(Ref(L,-2) <= L), Ref(L,-2));
Plot(UpFractal, "
UpFractal", coloraqua);
Plot(DownFractal, "DownFractal", colorRed);
Buy = Cross( C, UpFractal ) ;
Sell = Cross( DownFractal, C ) ;
Hrgbeli = SelectedValue(Ref(C,0));
//protexi = SelectedValue(Ref(L,0));
Maxsementara=SelectedValue(Ref(H,0));
for( i = 1; NOT(SelectedValue(Ref(C,-i))<SelectedValue(Ref(downfractal,-i)) AND SelectedValue(Ref(C,-i-1))>=SelectedValue(Ref(downfractal,-i-1)));i++ )
{
// Maxsementara = Max(Maxsementara,SelectedValue(Ref(H,-i+1)));
}
for (j = 0; j<i AND NOT(SelectedValue(Ref(C,-i+j))>SelectedValue(Ref(upfractal,-i+j)) AND SelectedValue(Ref(C,-i+j-1))<=SelectedValue(Ref(upfractal,-i+j-1)));j++ )
{
Hrgbeli = SelectedValue(Ref(C,-i+j+1));
//protexi = Max(protexi,SelectedValue(Ref(L,-i+j+1)));
// Maxsementara = Max(Maxsementara,SelectedValue(Ref(H,-i+j+1)));
}
for (k=0; k<=i-j;k++)
{
Maxsementara = Max(Maxsementara,SelectedValue(Ref(H,-k)));
}
Loss = Param("persen loss",6,3,20,1);
persenlos = Hrgbeli - Hrgbeli*Loss/100;
Plot (hrgbeli, "
hargabeli", colorblue, ParamStyle("Style") );
Plot (persenlos, "cutloss (" + Loss + "%)", colorRed, ParamStyle("Style") );
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 );}}
PlotShapes(IIf(Buy==1, shapeHollowUpArrow , shapeNone), colorGreen, 0,Low, Offset=-15);
PlotShapes(IIf(Sell==1, shapeHollowDownArrow, shapeNone), colorRed, 0,High, Offset=-15);
_SECTION_END();
keren min
ReplyDelete