Triple-MA-Buy-Sell-Alert-Trading-System

Triple-MA-Buy-Sell-Alert-Trading-System
Triple-MA-Buy-Sell-Alert-Trading-System

//www.aflcode.com
_SECTION_BEGIN("Price");
#include <T3_include.AFL>;
SetChartBkGradientFill( ParamColor("BgTop", ColorRGB( 172,172,172 )),
ParamColor("BgBottom", ColorRGB( 172,172,172 )),ParamColor("titleblock",ColorRGB( 172,172,172 ))); 
SetChartOptions(0,chartShowDates|chartShowArrows|chartLogarithmic|chartWrapTitle);
_N(Title = StrFormat("{{NAME}} - Sector: "+SectorID(1)+" - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) Vol " +WriteVal( V, 1.0 ) +" {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 )) ));
Plot( C, "", IIf(Close > Open, colorGreen, colorRed), styleBar + styleThick + styleNoLabel);

//Ribbon
uptrend=PDI()>MDI()AND Signal()<MACD();
downtrend=MDI()>PDI()AND Signal()>MACD();
Plot( 2, "",IIf( uptrend, colorGreen, IIf( downtrend, colorRed, 0 )), styleOwnScale|styleArea|styleNoLabel, -0.5, 100 );

//Plot(T3(C,3),"T3",colorTan,styleThick);
//Plot(T3(C,5),"T5",colorLime);
BuyAlert = Cross (T3(C,3), T3(C,5));
SellAlert = Cross (T3(C,5), T3(C,3));
shape = BuyAlert * shapeHollowUpArrow + SellAlert * shapeHollowDownArrow;
PlotShapes( shape, IIf( BuyAlert ,ColorRGB(210,0,210), colorPink ),0, IIf( BuyAlert , Low, High ) );



//Exploration

Buy = BuyAlert;
Sell =  SellAlert; 

Filter = Buy OR Sell;

AddColumn(Buy, "Buy", 1);
AddColumn(Sell, "Sell", 1);
AddColumn(V, "Volume", 1);
AddColumn(C, "Close", 1.2);
_SECTION_END();

_SECTION_BEGIN("MA1");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 200, 1, 10 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
_SECTION_END();

_SECTION_BEGIN("MA2");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 200, 1, 10 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
_SECTION_END();

_SECTION_BEGIN("MA3");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 200, 1, 10 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
_SECTION_END();

_SECTION_BEGIN("MA4");
P = ParamField("Price field",-1);
Periods = Param("Periods", 15, 2, 200, 1, 10 );
Plot( MA( P, Periods ), _DEFAULT_NAME(), ParamColor( "Color", colorCycle ), ParamStyle("Style") ); 
_SECTION_END();


BuyAlert = Cross (EMA(C,5), EMA(C,10));
SellAlert = Cross (EMA(C,10), EMA(C,5));
shape = BuyAlert * shapeUpArrow + SellAlert * shapeDownArrow;
PlotShapes( shape, IIf( BuyAlert ,colorGreen , colorRed ),0, IIf( BuyAlert , Low, High ) );
Previous
Next Post »