Here is the very simple and classical example to build a triple EMA (Exponential Moving Average Crossover system). System is quite popular if anyone (trader/investor) is a newbie to classical technical analysis. In this AFL the triple moving average buy, sell signals are coded and comes with Scanning and Exploration functionality.
It is a simple trend following system where the system shows buy signal if 3 EMA > 13 EMA > 34 EMA and shows a sell signal if 3 EMA < 13 EMA < 34 EMA. It works good in a trending market. When a stock/index is not trending (when it’s going sideways) the moving averages will intermingle and repeatedly crisscross each other especially during the consolidation phase. A Trader can take advantage during this phase and can use this indicator to trade the next move.
[wp_ad_camp_5]
However like any other trend following system this system too has its own disadvantages. Catches signals very late, sometimes at the peak. And it could withstand the noise in a sideways market to some extend avoiding multiple whipsaws compared to a double moving average crossover system.
Nifty Futures Hourly Charts with Triple EMA Crossover
Triple EMA Crossover Amibroker AFL Code
_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", colorDefault ), styleNoTitle | ParamStyle("Style") | GetPriceStyle() );
_SECTION_END();
_SECTION_BEGIN("Triple EMA Crossover Rules");
P1 = ParamField("Price field",-1);
Periods1 = Param("Periods1", 3, 2, 300, 1, 10 );
Plot( EMA( P1, Periods1 ), _DEFAULT_NAME(), ParamColor( "Color1", colorCycle ), ParamStyle("Style1") );
P2 = ParamField("Price field",-1);
Periods2 = Param("Periods2", 13, 2, 300, 1, 10 );
Plot( EMA( P2, Periods2 ), _DEFAULT_NAME(), ParamColor( "Color2", colorCycle ), ParamStyle("Style2") );
P3 = ParamField("Price field",-1);
Periods3 = Param("Periods3", 34, 2, 300, 1, 10 );
Plot( EMA( P3, Periods3 ), _DEFAULT_NAME(), ParamColor( "Color3", colorCycle ), ParamStyle("Style3") );
Buy = EMA(P1, Periods1) > EMA(P2, Periods2) AND EMA(P2, Periods2) > EMA(P3, Periods3);
Sell = EMA(P1, Periods1) < EMA(P2, Periods2) AND EMA(P2, Periods2) < EMA(P3, Periods3);
Buy = ExRem(Buy,Sell);
Sell = ExRem(Sell,Buy);
Filter=Buy OR Sell;
SetOption("NoDefaultColumns", True );
AddColumn( DateTime(), "Date", formatDateTime );
AddColumn( IIf( Buy, 66, 83 ), "Signal", formatChar );
addcolumn( Close, "Close price", 1.4 );
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Buy, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Buy, shapeUpArrow, shapeNone),colorWhite, 0,L, Offset=-45);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Sell, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Sell, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);
_SECTION_END();
Thanks very much.
please confirm these indicators can be carried over for the next day also ?
Rajendran,
Can you please suggest a correct S/L for this strategy, thanks!
You cant fix a stoploss and trade this strategy. And you cant do system trading with this.
Y cannot we do system trading ?
Dear Rajandran, is there a AFL for the below mentioned strategy
INDICATOR:
EMA 5,20,50 Period
VMA 5 Period
MACD Short Period 12,Long Period 26,EMA Period 9
RSI 10 Period
SSTO K Period 14,D Period 3
BUY:CROSS EMA5 & EMA20 (upward)
EMA20>EMA50
RSI INCREASING OR ABOVE 50
SSTO %K>%D
SELL:CROSS EMA5 & EMA20 (downward) OR CROSS %K & %D (downward) OR %K<%D
kanakaraja
how did u get your parameter periods in 3 Ema’s like 3, 2, 300, 1, 10 ?…do you have any parameter periods that i can use for EMA8. >SMA 20..>SMA 50..>SMA 100….so i can make also a buy signal when this 4 moving average aligned and below the price?…thanks very much sir
you need to understand Amibroker AFL functions to know better. To code your own strategies you need to be familiar with AFL code.
i already have the code for it …what is lacking is the parameters..for ema8, sma20,sma 50,sma 100…can u please provide it for me..or post an afl about it…thanks boss,,:)
Hi Mr Rajandran. I am from Singapore. Do you have codes on Atlas Line for MT4. I tried searching the web but to no avail. Thank you very much and have a nice day ! Cheers!
HOW THIS AFL TO NON REPEAT SIGNAL.?
AND HOW TO HIDE SHOW EMA ON SCREEN?
Hi, Is there an ex4 MT4 Indicator for this?
Hi Sir,
If i add a line in this code that i will buy a script if it crosses 3 EMA > 13 EMA > 34 EMA. Suppose i get a list of scripts with buy signal and buy price and target price and stoploss and i want to backtest all those scripts which are given by this afl. Is there any way of backtesting these scripts automatically through any afl which would give me the profit/loss in each script for past 1 year or 2 year.
SIR, i need EMA 20 50 100 crossover BUY AND SELL SYSTEM ALERT. plz help
can u suggest to enter into a profession of Real time data feed supply
I am looking for data feed software
sir i want 250 ema 180ema 120ema 50ema converging at one point (candle)
if ema is above the candle then sell and if ema is below the candle buy
i want alert output also for this
hope you can help me