AFL for Triple SMA strategy.
AFL for this strategy.
I actually created for the users who are requesting them.
You can change the parameters of 3 moving averages as per your need.
Technically these types of strategies might have worked very well a few decades back. For the current kinda markets it would be better if you use a better strategy with non-lagging indicators.
//////////////////////////////////////////////////////////////////
//// COPY THE CODE BELOW AND PASTE THEM AS AFL /////
//////////////////////////////////////////////////////////////////
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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
fmaper = Param("Fastest MA Period", 3, 1, 50);
mmaper = Param("Middle MA Period", 15, 1, 100);
smaper = Param("Slowest MA Period", 39, 1, 500);
periods = Param( "Periods", 15, 1, 200, 1 );
Ksmooth = Param( "%K avg", 3, 1, 200, 1 );
Dsmooth = Param( "%D avg", 3, 1, 200, 1 );
stocd = StochD( periods , Ksmooth, DSmooth );a
stock = StochK( periods , Ksmooth);
fastma = MA(C, fmaper);
midma = MA(C, mmaper);
slowma = MA(C, smaper);
Plot( fastma , _DEFAULT_NAME(), ParamColor( "Color Fast MA", colorCycle ), ParamStyle("Style Fast MA") );
Plot( midMA , _DEFAULT_NAME(), ParamColor( "Color Middle MA", colorCycle ), ParamStyle("Style Mid MA") );
Plot( slowMA, _DEFAULT_NAME(), ParamColor( "Color Slow MA", colorCycle ), ParamStyle("Style Slow MA") );
//raising ma.
Buyc1 = slowma > Ref(slowma, -1);
Buyc2 = Cross(fastma, midma);
buyfilter = stock > stocd AND stock > 20;
Sellc1 = slowma < Ref(slowma, -1);
Sellc2 = Cross(midma, fastma);
sellfilter = stock < stocd AND stock < 80;
"Buyc1 : " + Buyc1 ;
"Buyc2 : " + Buyc2 ;
"buyfilter : " + buyfilter ;
"Sellc1 : " + Sellc1 ;
"Sellc2 : " + Sellc2 ;
"sellfilter : " + sellfilter ;
Buy = Buyc1 AND Buyc2 AND buyfilter ;
Sell = Sellc1 AND Sellc2 AND sellfilter ;
Cover=Buy = ExRem(Buy, Sell);
Sell=Short = ExRem(Sell, Buy);
BuyPrice=CoverPrice=ValueWhen(Buy, C);
SellPrice=ShortPrice=ValueWhen(Sell, C);
PlotShapes(shapeUpArrow * Buy, colorGreen, 0, L);
PlotShapes(shapeDownArrow * Sell, colorRed, 0, H);
//////////////////////////////////////////////////////////////////
-----------------------------------------------------------
TRADING IS NOT A ROCKET SCIENCE, ONE HAS TO CREATE A BALANCE BETWEEN HIS LOGICAL THINKING & CONTROL OVER EMOTION.
I ALWAYS REGRET FOR THOSE WHO LOSE MONEY, BUT THAT'S WHAT TRADING IS ALL ABOUT.