AFL of the week: 14-73 EMA crossover system

We are very excited to start this new section on our website called  ‘AFL of the week‘. Every Amibroker enthusiast spends days and weeks to code a profitable AFL. And the folks who are not familiar with programming end up paying thousands of bucks to purchase AFL’s, most of which turns out to be a scam. In this section, we’ll try to assist all these people by posting profitable AFL’s and trading systems. This would save both their time and money. We’ll post copy-paste enabled AFL code and the backtest report (whenever applicable). Believe me, there are no hidden terms and conditions here. Just stay tuned for a new AFL every week. Subscribe to our blog from the right-hand side of this page so that you get notifications right in your mailbox.

Please visit Trading Tuitions Academy to learn AFL coding and create your own Trading systems.

The 14-73 EMA Crossover system

This is a moving average crossover  strategy which works tremendously well in trends and gives small losses during trading ranges. We have tested this in Daily timeframe on highly liquid indices like Nifty and BankNifty.

AFL Overview

Paramter Value
Preferred Timeframe Daily
Indicators Used 14 period EMA, 73 period EMA
Buy Condition 14 period EMA crosses above 73 period EMA (Buy at next day Open)
Sell Condition 14 period EMA crosses below 73 period EMA (Sell at next day Open)
Stop Loss No fixed stoploss, Stop and reverse when AFL gives opposite signal
Targets No fixed target, Stop and reverse when AFL gives opposite signal
Position Size 150 (fixed)
Initial Equity 200000
Brokerage 50 per order
Margin 10%

AFL Code

//  Formula Name:    14-73 Crossover Trading System
//  Author/Uploader: Trading Tuitions
//  E-mail:          support@tradingtuitions.com
//  Website:         www.tradingtuitions.com

_SECTION_BEGIN("14-73 Crossover Trading System");

_N(Title = StrFormat("{{NAME}} – {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

//Initial Parameters

SetTradeDelays( 1, 1, 1, 1 );
SetOption( "InitialEquity", 200000);
SetOption("FuturesMode" ,True);
SetOption( "AllowPositionShrinking", True );


MALength1 = 14;
MALength2 = 73;

//Buy-Sell Logic

Buy = Cross(ema( C, MALength1 ),ema( C, MALength2 ));
Sell =Cross( ema( C, MALength2 ), ema( C, MALength1 )) ;

Buy = ExRem( Buy, Sell );
Sell = ExRem( Sell, Buy );
Short = Sell;
Cover = Buy;

Plot( Close, "Price", colorWhite, styleCandle );
Plot(ema( C, MALength1 ),"FastEMA",colorWhite);
Plot(ema( C, MALength2 ),"SlowEMA",colorBlue);

/* Plot Buy and Sell Signal Arrows */
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(Cover, shapeSquare, shapeNone),colorGreen, 0, L, Offset=-40);
PlotShapes(IIf(Cover, shapeSquare, shapeNone),colorLime, 0,L, Offset=-50);
PlotShapes(IIf(Cover, 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);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorRed, 0, H, Offset=40);
PlotShapes(IIf(Short, shapeSquare, shapeNone),colorOrange, 0,H, Offset=50);
PlotShapes(IIf(Short, shapeDownArrow, shapeNone),colorWhite, 0,H, Offset=-45);


AFL Screenshot

14-73 EMA CA

Backtest Report

 Paramter Value
  Nifty Bank Nifty
Initial Capital  200000  200000
Final Capital  708740 1727157.50
Backtest Period 02-Jan-2007 to 09-02-2016 02-Jan-2007 to 09-02-2016
Net Profit %  254.37%  763.58%
Annual Return % 14.90% 26.70%
Number of Trades 36 36
Winning Trade % 22.22% 38.89%
Average holding Period 61.28 periods 60.92 periods
Max consecutive losses 9 4
Max system % drawdown -59.29% -59.40%
Max Trade % drawdown -22.08% -97.77%

Download the detailed backtest report here.

Equity Curve


Equity Curve- Nifty

Bank Nifty:

Equity Curve- BNF

Additional Amibroker settings for backtesting

Goto Symbol–>Information, and specify the lot size and margin requirement. The below screenshot shows lot size of 30 and margin requirement of 10% for Bank Nifty:

Symbol Info


All the AFL’s posted in this section are for learning purpose. Trading Tuitions does not necessarily own these AFL’s and we don’t have any intellectual property rights on them. We might copy useful AFL’s from public forums and post it in this section in a presentable format. The intent is not to copy anybody’s work but to share knowledge. If you find any misleading or non-reproducible content then please inform us at support@tradingtuitions.com

Related Posts


  1. Hello Sir!
    Can this strategy be applied in excel too.
    And in Zerodha PI if you could share the tradescript with entering & exit codes.

Leave a Reply

Your email address will not be published.