Candle MA Long

Author: 2008 candlexu
Candle MA Long

This tool is designed to provide a visual trend analysis for financial charts by calculating and displaying multiple moving averages simultaneously. It focuses on identifying momentum and the direction of price movement through three distinct layers of data.

Core Logic Overview

The script functions by smoothing out price fluctuations to reveal the underlying market trend. It utilizes three different "time horizons" (defined by the periods 26, 30, and 35) to create a multi-layered view of the market's behavior. Because it uses an Exponential Moving Average (EMA), it gives slightly more weight to recent price action, making it more responsive to current market changes than a standard simple average.

How the Visuals Work

The indicator creates six distinct lines on your chart, which are organized into three pairs. Each pair represents one of the moving averages:

  1. Baseline Calculations: The script first calculates three continuous lines based on the price closing values over the specified periods. These serve as the foundation for the trend.
  2. Directional Filtering: To make the chart cleaner and easier to read, the script applies a logic filter to these three moving averages. Instead of showing a continuous line at all times, it only displays a segment of the line when the price movement is upward (increasing).
  3. Visual Identification: By only plotting the "rising" portions of these averages, the tool helps traders quickly distinguish between bullish momentum and flat or bearish consolidation. If a line appears on the chart, it signifies that the specific moving average is currently trending upwards; if the line disappears, it indicates the trend has leveled off or reversed.

Key Features for the User

  • Customizable Timeframes: Users can adjust the three primary periods (26, 30, and 35) to match their specific trading style, whether they prefer shorter-term fluctuations or longer-term trends.
  • Clarity of Movement: By filtering out the downward movements and only showing the rising segments, the tool minimizes "visual noise," allowing you to focus on the strength of upward price momentum.
  • Multi-Layered Analysis: By tracking three different averages at once, the tool allows you to see if multiple timeframes are moving in harmony, providing a clearer picture of market agreement.
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
Candle MA Long
//+------------------------------------------------------------------+
//|                  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_26=  26;
extern int long_30=  30;
extern int long_35=  35;


//---- 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_26,0,MODE_EMA,PRICE_CLOSE,i);
      ExtMapBuffer2[i]=iMA(NULL,0,long_30,0,MODE_EMA,PRICE_CLOSE,i);
      ExtMapBuffer3[i]=iMA(NULL,0,long_35,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