GMMA_Long_v1
Download scriptThis script is designed to function as a visual trend-tracking tool for traders using the MetaTrader platform. It specifically implements the "Long" component of the Guppy Multiple Moving Average (GMMA) strategy, which aims to provide a clearer picture of market momentum and long-term price direction by analyzing multiple data points simultaneously.
How the Logic Works
The core logic of this script relies on calculating a series of Exponential Moving Averages (EMAs). Unlike a standard moving average that treats all past price data equally, an exponential moving average places a higher weight on recent price action. This allows the indicator to react more quickly to new information while still maintaining a smooth flow.
The script processes the following specific technical details:
- Multiple Time Horizons: Instead of showing just one line, the script calculates six different EMAs at once. These correspond to specific time intervals: 30, 35, 40, 45, 50, and 60 periods.
- Data Source: The calculations are based on the "Close" price of the candles, which is the standard way to determine the final price at which a period ended.
- Visual Representation: The script takes these six distinct mathematical calculations and plots them as individual lines on your trading chart.
Purpose for the Trader
By displaying these six lines together, the script allows you to see the "flow" of the market:
- Trend Identification: When the lines are grouped closely together and moving in a specific direction, it indicates a strong, unified trend in the market.
- Momentum Analysis: The different periods (from 30 to 60) represent different speeds of market reaction. By seeing them all at once, you can observe whether short-term momentum is aligning with long-term trends or if they are beginning to diverge.
- Support and Resistance: Traders often use the "cluster" of these lines to identify zones where price might stall or bounce, providing a visual map of market sentiment over the preceding 60 periods.
In summary, this script automates the complex math required to plot multiple moving averages, allowing you to visually assess the health and direction of a long-term trend at a single glance.
//+------------------------------------------------------------------+
//| Guppy Mulitple Moving Average (Long).mq4 |
//| Code written by - Matt Trigwell |
//| Checked by - Linuxser |
//| |
//+------------------------------------------------------------------+
// ***** INSTRUCTIONS *****
// Add the GMMA Short indicator and the GMMA Long indicator to your charts.
// This is the GMMA Long indicator
// ***** For information on how to use this fantastic indicator *****
// http://www.guppytraders.com/
// http://www.market-analyst.com/kb/article.php/Guppy_Multiple_Moving_Average
// http://tradermike.net/2004/05/another_look_at_multiple_moving_averages
// http://karakoyunlar.blogspot.com
#property copyright "Code written by - Matt Trigwell"
#property indicator_chart_window
//#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Red
#property indicator_color2 Red
#property indicator_color3 Red
#property indicator_color4 Red
#property indicator_color5 Red
#property indicator_color6 Red
extern color Long=Red;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE,EMPTY,CLR_NONE,Long);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE,EMPTY,CLR_NONE,Long);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_LINE,EMPTY,CLR_NONE,Long);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexStyle(3,DRAW_LINE,EMPTY,CLR_NONE,Long);
SetIndexBuffer(3,ExtMapBuffer4);
SetIndexStyle(4,DRAW_LINE,EMPTY,CLR_NONE,Long);
SetIndexBuffer(4,ExtMapBuffer5);
SetIndexStyle(5,DRAW_LINE,EMPTY,CLR_NONE,Long);
SetIndexBuffer(5,ExtMapBuffer6);
//----
return(0);
}
int deinit()
{
return(0);
}
int start()
{
int i,j,limit,counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(i=0; i<limit; i++){
ExtMapBuffer1[i]=iMA(NULL,0,30,0,MODE_EMA,PRICE_CLOSE,i);
ExtMapBuffer2[i]=iMA(NULL,0,35,0,MODE_EMA,PRICE_CLOSE,i);
ExtMapBuffer3[i]=iMA(NULL,0,40,0,MODE_EMA,PRICE_CLOSE,i);
ExtMapBuffer4[i]=iMA(NULL,0,45,0,MODE_EMA,PRICE_CLOSE,i);
ExtMapBuffer5[i]=iMA(NULL,0,50,0,MODE_EMA,PRICE_CLOSE,i);
ExtMapBuffer6[i]=iMA(NULL,0,60,0,MODE_EMA,PRICE_CLOSE,i);
}
return(0);
}
//+------------------------------------------------------------------+
Comments