GA-ind_2color

Download script
Author: Copyright � 2008, MetaQuotes Software Corp.
GA-ind_2color

This script functions as a specialized technical analysis tool designed to help traders identify momentum shifts and trend directions in the financial markets. By analyzing price history, it translates complex movements into visual signals that appear in a separate window on your trading platform.

Core Analytical Logic

The underlying logic of this indicator relies on three primary layers of calculation:

1. The Foundation (Moving Averages) The tool begins by tracking two different types of moving averages based on the closing price of assets. One is a "Fast" average, which reacts quickly to recent price changes, and the other is a "Slow" average, which represents the broader, longer-term trend. By combining these two averages together, the script creates a primary data stream that reflects the current strength of the market movement.

2. The Signal Layer (Smoothing) Once the primary data stream is established, the script applies a secondary calculation known as a "Signal" line. This layer takes the results from the first step and smooths them out further. Think of this as a filter that removes minor "noise" or temporary fluctuations, providing a clearer picture of where the market's main energy is heading.

3. Visual Trend Identification The final part of the logic involves comparing the primary data stream against the smoothed signal line. The script interprets the relationship between these two lines to provide clear visual feedback:

  • Bullish Momentum (Upward): When the primary data moves above the signal line, the script identifies this as a positive momentum shift.
  • Bearish Momentum (Downward): When the primary data falls below the signal line, the script identifies this as a negative momentum shift.

How it Appears on Your Chart

Instead of just showing you raw numbers, the script translates these calculations into visual elements. It highlights specific points where the market crosses these thresholds, making it easier for a user to see exactly when the trend might be shifting from one direction to another at a glance.

Indicators Used
Moving average indicatorMoving average indicator
Miscellaneous
Implements a curve of type %1
21 Views
0 Downloads
0 Favorites
GA-ind_2color
//+------------------------------------------------------------------+
//|                                                       GA-ind.mq4 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

//---- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 4
#property  indicator_color1  Gray
#property  indicator_color2  Blue
#property  indicator_color3  Red
#property  indicator_color4  Yellow
#property  indicator_width1  1
#property  indicator_width2  1
#property  indicator_width3  1

//---- indicator parameters
extern int FastEMA=8;
extern int SlowEMA=26;
extern int SignalSMA=8;
//---- indicator buffers
double     MacdBufferUp[];
double     MacdBufferDn[];
double     SignalBuffer[];
double     MacdBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexStyle(1,DRAW_ARROW);  
   SetIndexStyle(2,DRAW_ARROW);    
   
   SetIndexStyle(3,DRAW_LINE);
   SetIndexDrawBegin(3,SignalSMA);
   IndicatorDigits(Digits+1);
//---- indicator buffers mapping
   SetIndexBuffer(0,MacdBuffer);
   SetIndexBuffer(1,MacdBufferUp);
   SetIndexBuffer(2,MacdBufferDn);   
   
   
   SetIndexBuffer(3,SignalBuffer);
//---- name for DataWindow and indicator subwindow label
   IndicatorShortName("MACD("+FastEMA+","+SlowEMA+","+SignalSMA+")");
   SetIndexLabel(0,"");
   SetIndexLabel(1,"MACD UP");   
   SetIndexLabel(2,"MACD DN");    
   
   
   SetIndexLabel(3,"Signal");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
int start()
  {
  

  
   int limit;
   int counted_bars=IndicatorCounted();
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;

      for(int i=0; i<limit; i++)MacdBuffer[i]=iMA(NULL,0,FastEMA,0,MODE_EMA,PRICE_CLOSE,i)+iMA(NULL,0,SlowEMA,0,MODE_EMA,PRICE_CLOSE,i);

      for(i=0; i<limit; i++)SignalBuffer[i]=iMAOnArray(MacdBuffer,Bars,SignalSMA,0,MODE_SMA,i);
      
      for(i=0; i<limit; i++){
         MacdBufferUp[i]=EMPTY_VALUE;
         MacdBufferDn[i]=EMPTY_VALUE;         
         
            if(MacdBuffer[i]>SignalBuffer[i]){
               MacdBufferUp[i]=MacdBuffer[i];
            }
            if(MacdBuffer[i]<SignalBuffer[i]){
               MacdBufferDn[i]=MacdBuffer[i];            
            }            
         
      }
      
//---- done
   return(0);
  }

Comments