Modified Guppy Multiple Moving Average Strategy: Amibroker AFL

Following the Trend is one of the sure-shot methods of making money through financial markets. But it’s important to choose the right set of technical indicators which gives a clear direction to a trend trader. Guppy multiple moving average (GMMA) is one of the most popular and accurate methods to identify the ongoing trend as well as trend reversals. It was developed by Daryl Guppy, an Australian trader who has put years of effort in developing this amazing indicator. In this post, we would explore a trading system based on Guppy multiple moving average. An AFL code is included along with Buy/Sell signals and backtesting results.

Guppy multiple moving average: A Closer Look

GMMA is composed of two sets of exponential moving averages. The first set is based on shorter timeframes of 3, 5, 8, 12, and 15 periods, while the second set uses longer timeframes of 30, 35, 40, 45, and 50 periods. The indicator suggests bullishness when all short-term EMAs cross above all long-term EMAs, and it gives a bearish signal when the short term EMAs cross below the long-term EMAs. The intersection between the two groups of moving averages indicates that a change in the trend occurred. Please note that the timeframes of moving averages are customizable, there is no hard and fast rule.

The shorter timeframe moving averages monitors the trading activity of short term traders, while longer timeframe moving averages monitors how long terms traders play the markets. It’s a smart and reliable method to gauge the overall market sentiment. While it works like wonders for trending stocks, it may not be very accurate for stocks trading sideways. Hence, it should be used with caution only on selected stocks.

We have tested the following system based on GMMA on Banknifty and Nifty, which are usually volatile and trending. The backtest results are quite convincing and the system has performed consistently well since the last 10+ years.

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

Guppy multiple moving average – AFL Overview

Preferred Time-frame
Indicators UsedEMA (Exponential Moving Average)
Buy ConditionAverage of (difference between shorter timeframe moving averages and longer timeframe moving averages) aka FastGuppy crosses the smoothed average of FastGuppy from bottom
Short ConditionAverage of (difference between shorter timeframe moving averages and longer timeframe moving averages) aka FastGuppy crosses the smoothed average of FastGuppy from top
Sell Condition
  • Same as Short
  • Stop Loss Hit
  • Target met
Cover Condition
  • Same as Buy
  • Stop Loss Hit
  • Target met
Stop Loss1%
Position Size10% of Equity
Initial Equity200000
Brokerage100 per order

GMMA Trading System – AFL Code

//  Formula Name:    Guppy multiple moving average Trading system
//  Author/Uploader: Trading Tuitions
//  E-mail:
//  Website:

_SECTION_BEGIN("Guppy multiple moving average Trading system");

SetBarsRequired( sbrAll );

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

Plot( Close, "Price",colorWhite, styleCandle );

guppy0= ema( close, 3 );
guppy1= ema( close, 5 );
guppy2= ema( close, 8 );
guppy3 = ema( close, 12 );
guppy4 = ema( close, 15 );

g1 = (guppy0+guppy1+guppy2+guppy3+guppy4)/5;

guppy5= ema( close, 30 );
guppy6= ema( close, 35 );
guppy7= ema( close, 40 );
guppy8 = ema( close, 45 );
guppy9 = ema( close, 50 );

g2 = (guppy5+guppy6+guppy7+guppy8+guppy9)/5;

SmoothFactor = param("smooth",5,5,50,1);

FastGuppy = g1-g2;
SlowGuppy = ema(FastGuppy, SmoothFactor);

Buy = Cross(FastGuppy,SlowGuppy);
Short = Cross(SlowGuppy,FastGuppy); 
Sell = Short;
Cover = Buy;


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

printf("\nBuy : " + Buy );  
printf("\nSell : " + Sell );  
printf("\nShort : " + Short );  
printf("\nCover : " + Cover );  
printf("\nDoji : " + abs(O-C) ); 

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

Guppy Multiple Moving Average

Also Read: McGinely Dynamic Trading System

Guppy multiple moving average- Backtest Report

GMMA trading system was backtested on Nifty and Banknifty over a period of 18 years. See the results below:

Nifty and Banknifty
Initial Capital200000
Final Capital5993117.09
Scrip NameNSE Nifty and NSE Banknifty
Backtest Period05-Apr-2000 to 25-Sep-2018
Net Profit %2896.56%
Annual Return %19.89%
Number of Trades1091
Winning Trade %33.64%
Average holding Period4.70 periods
Max consecutive losses14
Max system % drawdown-24.62%
Max Trade % drawdown-81.96%

Download the detailed backtest report here.

Equity Curve

There are brief period of drawdowns that this system has witnessed, but it has recovered from all the losses quickly


Profit Table


Additional Amibroker settings for backtesting

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

Symbol Info_Nifty

Banknifty Symbol Information


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

Related Posts


  1. Some of the points need clarifications,
    1.In the AFL code section, 5 sets of each short and long time frames are used while in the article 6 sets are advised.
    2, Short time frames of 3,5,8,10,12,18 are there in the article while in the AFL code 3,5,8,12,15 are used
    3.Long term time frame: 60 is skipped in AFL code
    5. Kindly through some light on how the average of long time frame is smothered in excel sheet.

    Thank you

    • Hi Shailendra,

      All the mentioned points are valid and corrected in the post. Thanks for your keen observation and feedback

  2. Hi,
    EMA18, crossing EMA60 will also give same results. So, what is purpose of using so many?
    Can you compare the results.?

    • Using multiple moving averages gives more accurate results and lesser whipsaws. This is the primary idea behind Guppy moving averages

Leave a Reply

Your email address will not be published. Required fields are marked *