Candle MA Long_
Download scriptThis tool is designed to help traders visualize market trends by calculating and displaying a series of "Moving Averages" on a price chart. Rather than looking at a single average, this script provides a multi-layered view of price momentum to help identify the direction in which the market is moving.
Core Logic Overview
The script operates by tracking three distinct sets of data simultaneously. It calculates three different Exponential Moving Averages (EMAs) based on specific timeframes: 40, 45, and 50 periods. Unlike a simple average, an "exponential" average gives more weight to recent price action, making it more responsive to sudden market shifts.
Visual Representation
To make the data easy to interpret at a glance, the script uses a clever visual logic:
- Primary Trend Lines: The script first plots three primary lines representing the 40, 45, and 50-period averages. These provide the baseline for the current market trend.
- Directional Highlights: The tool goes a step further by checking if these average lines are moving upward. If the current value of an average is higher than its previous value (indicating an increasing trend), the script highlights that specific point on the chart.
- Color Coding: By using alternating colors (Aqua and Red), the script creates a high-contrast visual environment. This allows traders to quickly distinguish between different layers of moving averages and see exactly where momentum is strengthening or shifting.
How it helps the trader
Instead of forcing you to interpret raw price candles, this logic smooths out the "noise" of the market. By focusing on the relationship between the 40, 45, and 50-period averages, the tool helps you see the broader flow of the market. When these lines cluster together and move in a specific direction, it serves as a visual cue for potential trend stability.
//+------------------------------------------------------------------+
//| Guppy Mulitple Moving Average (Short double).mq4|
//| candlexu@163.Com|
//| |
//+------------------------------------------------------------------+
#property copyright "2008 candlexu"
#property indicator_chart_window
//#property indicator_separate_window
#property indicator_buffers 6
#property indicator_color1 Aqua//Magenta
#property indicator_color2 Red
#property indicator_color3 Aqua
#property indicator_color4 Red
#property indicator_color5 Aqua
#property indicator_color6 Red
extern int long_40= 40;
extern int long_45= 45;
extern int long_50= 50;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer1_1[];
double ExtMapBuffer2[];
double ExtMapBuffer2_2[];
double ExtMapBuffer3[];
double ExtMapBuffer3_3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer1_1);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,ExtMapBuffer2);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3,ExtMapBuffer2_2);
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(4,ExtMapBuffer3);
SetIndexStyle(5,DRAW_LINE);
SetIndexBuffer(5,ExtMapBuffer3_3);
//----
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,long_40,0,MODE_EMA,PRICE_CLOSE,i);
ExtMapBuffer2[i]=iMA(NULL,0,long_45,0,MODE_EMA,PRICE_CLOSE,i);
ExtMapBuffer3[i]=iMA(NULL,0,long_50,0,MODE_EMA,PRICE_CLOSE,i);
}
for(j = Bars-counted_bars-1;j>=0;j--)
{
if(ExtMapBuffer1[j]>ExtMapBuffer1[j+1]) ExtMapBuffer1_1[j]=ExtMapBuffer1[j]; else ExtMapBuffer1_1[j]=EMPTY_VALUE;
if(ExtMapBuffer2[j]>ExtMapBuffer2[j+1]) ExtMapBuffer2_2[j]=ExtMapBuffer2[j]; else ExtMapBuffer2_2[j]=EMPTY_VALUE;
if(ExtMapBuffer3[j]>ExtMapBuffer3[j+1]) ExtMapBuffer3_3[j]=ExtMapBuffer3[j]; else ExtMapBuffer3_3[j]=EMPTY_VALUE;
}
return(0);
}
//+------------------------------------------------------------------+
Comments