This script is designed as a custom technical analysis tool for the MetaTrader platform. Its primary purpose is to provide traders with a visual representation of market momentum by layering multiple moving averages onto a single chart.
Core Logic and Functionality
The tool operates by calculating six distinct moving averages simultaneously. Instead of relying on a single price line, it uses a multi-layered approach to help identify trends more clearly. Here is a breakdown of how the logic flows:
- Multi-Period Analysis: The script processes six different timeframes (periods) at once—specifically set by default at 3, 5, 8, 10, 12, and 15 units. By looking at these varying lengths, the tool allows you to see both very immediate price fluctuations and slightly broader, more established trends.
- Smoothing Method: The script utilizes an Exponential Moving Average (EMA) calculation logic. This specific method is favored by many traders because it reacts more quickly to recent price changes than a standard simple moving average, while still effectively smoothing out the "noise" of the market.
- Visual Uniformity: All six calculated lines are rendered in the same color (Orange) and plotted directly on your main price window. This allows you to observe the "clustering" or "spreading" of the lines.
- Customization Options: The script provides a suite of adjustable parameters that allow users to modify how the data is processed:
- Periods: You can change the numerical length of each average to suit different trading styles (e.g., scalping vs. swing trading).
- Shifts: You can physically move the lines forward or backward on the chart to align them with specific visual preferences.
- Price Source and Method: Users have the flexibility to define which price data point the averages should follow and which mathematical smoothing method the script should use.
How a Trader Uses This Logic
By viewing these six lines together, a trader is looking for "confluence." When all six lines move in the same direction and stay tightly grouped, it suggests a strong, high-confidence trend. Conversely, when the lines begin to cross each other or spread out significantly, it can signal market indecision or a potential reversal in price momentum.
//+------------------------------------------------------------------+
//| Guppy Short.mq4 |
//| jnr314 |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "jnr314"
#property link "https://www.mql5.com"
#property version "2.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 6
#property indicator_color1 Orange
#property indicator_color2 Orange
#property indicator_color3 Orange
#property indicator_color4 Orange
#property indicator_color5 Orange
#property indicator_color6 Orange
//--- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];
double ExtMapBuffer6[];
//--- input parameters
input int InpMAPeriod1=3; // Period 1
input int InpMAPeriod2=5; // Period 2
input int InpMAPeriod3=8; // Period 3
input int InpMAPeriod4=10; // Period 4
input int InpMAPeriod5=12; // Period 5
input int InpMAPeriod6=15; // Period 6
//---
input int InpMAShift1=0; // Shift 1
input int InpMAShift2=0; // Shift 2
input int InpMAShift3=0; // Shift 3
input int InpMAShift4=0; // Shift 4
input int InpMAShift5=0; // Shift 5
input int InpMAShift6=0; // Shift 6
//---
input ENUM_MA_METHOD InpMAMethod=MODE_EMA; // Method
input ENUM_APPLIED_PRICE InpMAPrice=1; // Applied Price
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//--- indicator buffers mapping
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexShift(0,InpMAShift1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexShift(1,InpMAShift2);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexShift(2,InpMAShift3);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,ExtMapBuffer4);
SetIndexShift(3,InpMAShift4);
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(4,ExtMapBuffer5);
SetIndexShift(4,InpMAShift5);
SetIndexStyle(5,DRAW_LINE);
SetIndexBuffer(5,ExtMapBuffer6);
SetIndexShift(5,InpMAShift6);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function
//+------------------------------------------------------------------+
int start()
{
int i,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,InpMAPeriod1,0,InpMAMethod,InpMAPrice,i);
ExtMapBuffer2[i]=iMA(NULL,0,InpMAPeriod2,0,InpMAMethod,InpMAPrice,i);
ExtMapBuffer3[i]=iMA(NULL,0,InpMAPeriod3,0,InpMAMethod,InpMAPrice,i);
ExtMapBuffer4[i]=iMA(NULL,0,InpMAPeriod4,0,InpMAMethod,InpMAPrice,i);
ExtMapBuffer5[i]=iMA(NULL,0,InpMAPeriod5,0,InpMAMethod,InpMAPrice,i);
ExtMapBuffer6[i]=iMA(NULL,0,InpMAPeriod6,0,InpMAMethod,InpMAPrice,i);
}
return(0);
}
//+------------------------------------------------------------------+
Comments