MACD_CCI

This indicator is designed to assist traders in identifying potential market trends by combining two distinct types of technical analysis: momentum and moving average crossovers. By synthesizing these different perspectives, the tool aims to filter out market noise and highlight specific directional signals.

How the Logic Works

The script monitors the price action of a currency pair or asset using three primary components:

1. Momentum Tracking (CCI) The tool utilizes the Commodity Channel Index (CCI), which measures how far the current price is moving relative to its average price over a specific period. In this logic, the CCI acts as a "sentiment" filter to determine if the market has positive or negative momentum.

2. Trend Analysis (Moving Averages) The script calculates two different Exponential Moving Averages (EMAs)—one "Fast" and one "Slow." By subtracting the Slow average from the Fast average, the tool creates a dynamic trend line.

  • If this value is increasing, it suggests upward momentum.
  • If this value is decreasing, it suggests downward momentum.

3. Signal Generation The indicator looks for a specific "confluence," meaning it only triggers a signal when both the momentum and the trend agree simultaneously. The logic categorizes market behavior into three distinct states:

  • Bullish Signal: Triggered when the momentum is positive (above zero) and the trend line is currently moving upward compared to the previous candle. This suggests a stronger move toward the upside.
  • Bearish Signal: Triggered when the momentum is negative (below zero) and the trend line is moving downward compared to the previous candle. This suggests a stronger move toward the downside.
  • Neutral/No-Signal: If the momentum and the trend do not align in the same direction, the script identifies these as neutral areas where no specific trade signal is generated.

Visual Representation

On your trading chart, these signals are displayed as distinct visual markers (arrows). This allows you to quickly see where the market satisfies both the "strength" requirement of the CCI and the "direction" requirement of the Moving Averages, providing a more confirmed entry or exit point than using either indicator alone.

Indicators Used
Commodity channel indexMoving average indicator
Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
MACD_CCI
//+------------------------------------------------------------------+
//|                                                     MACD_CCI.mq4 |
//|                                   Copyright © 2009, challenger78 |
//+------------------------------------------------------------------+
#property  copyright "challenger78"

#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Blue
#property  indicator_color2  Red
#property  indicator_color3  Yellow

#property  indicator_minimum 0
#property  indicator_maximum 2

extern int FastLen = 144;
extern int SlowLen = 233;
extern int CCI = 50;

double buffer1[], buffer2[], buffer3[];

int init()
{
   SetIndexStyle(0,DRAW_ARROW);    SetIndexArrow(0,110);    SetIndexBuffer(0,buffer1);    SetIndexEmptyValue(0,EMPTY_VALUE); 
   SetIndexStyle(1,DRAW_ARROW);    SetIndexArrow(1,110);    SetIndexBuffer(1,buffer2);    SetIndexEmptyValue(1,EMPTY_VALUE);
   SetIndexStyle(2,DRAW_ARROW);    SetIndexArrow(2,110);    SetIndexBuffer(2,buffer3);    SetIndexEmptyValue(2,EMPTY_VALUE); 
   
   return(0);
}

int start()
{
   int limit;
   int counted_bars = IndicatorCounted();
   if(counted_bars < 0) return(-1);
   if(counted_bars > 0) counted_bars--;
   limit = Bars - counted_bars;
   
   for(int i = 0; i < limit; i++)
   {
      double cci =   iCCI(NULL, 0, CCI, PRICE_TYPICAL, i);
      double ma_0 = iMA(NULL, 0, FastLen, 0, MODE_EMA, PRICE_CLOSE, i) - 
                     iMA(NULL, 0, SlowLen, 0, MODE_EMA, PRICE_CLOSE, i);
      double ma_1 = iMA(NULL, 0, FastLen, 0, MODE_EMA, PRICE_CLOSE, i + 1) - 
                     iMA(NULL, 0, SlowLen, 0, MODE_EMA, PRICE_CLOSE, i + 1);
                         
      buffer1[i]=EMPTY_VALUE;    buffer2[i]=EMPTY_VALUE;      buffer3[i]=EMPTY_VALUE;    
      
      if (cci > 0 && ma_0 > ma_1) buffer1[i] = 1;  
      else if (cci < 0 && ma_0 < ma_1) buffer2[i] = 1;
      else buffer3[i] = 1;
   }
   return(0);
}

Comments