MACD_CCI_mtf

Download script
MACD_CCI_mtf

This tool is designed to assist traders by identifying potential market trends through the combination of two popular technical analysis indicators: the MACD (Moving Average Convergence Divergence) and the CCI (Commodity Channel Index).

Instead of just showing you lines on a graph, this script translates complex mathematical data into visual "signals" on your chart, helping to filter out market noise and highlight specific momentum shifts.

How the Logic Works

The script operates by looking at two different types of market information simultaneously:

  1. Trend Direction (MACD): The tool monitors the MACD, which tracks the relationship between two different moving averages. It looks for whether the current momentum is increasing or decreasing compared to the previous moment.
  2. Overbought/Oversold Context (CCI): The tool monitors the CCI, which measures how far the price is deviating from its average. This helps the script understand if the market is currently pushing in a positive direction (above zero) or a negative direction (below zero).

Signal Generation

The core logic of the script works by "cross-referencing" these two pieces of information to place specific markers on your chart:

  • Bullish Momentum: When the CCI confirms that the market is in a positive zone and the MACD shows that upward momentum is strengthening, the script places a specific marker (indicated by the Royal Blue color).
  • Bearish Momentum: When the CCI confirms the market is in a negative zone and the MACD shows that downward momentum is accelerating, the script places a different marker (indicated by the Red color).
  • Neutral/Other States: If the conditions for the specific bullish or bearish trends are not met, the script places a third type of marker (indicated by the Orange color) to show neutral activity.

Key Features

  • Multi-Timeframe Analysis: One of the most powerful aspects of this script is its ability to look at higher timeframes. For example, you can be looking at a 1-minute chart but have the script calculate signals based on the 15-minute or 1-hour trend. This ensures that your "local" trades are aligned with the "big picture" market move.
  • Customizable Sensitivity: The settings allow you to adjust the speed and sensitivity of both the MACD and CCI components, making it adaptable to different trading styles (from fast scalping to slower swing trading).
  • Visual Clarity: By using distinct colored arrows/markers rather than complex lines, the tool provides a clean visual summary, allowing you to see at a glance where the trend is shifting without having to manually interpret overlapping data.
Indicators Used
MACD Histogram
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
MACD_CCI_mtf
//+------------------------------------------------------------------+
//|                                                     MACD_CCI.mq4 |
//|                                   Copyright © 2009, challenger78 |
//+------------------------------------------------------------------+
//mod mtf

#property  copyright "challenger78"

#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  RoyalBlue
#property  indicator_color2  Red
#property  indicator_color3  Orange

#property  indicator_minimum 0
#property  indicator_maximum 77

extern int TimeFrame=0;

extern int macdMAfast   =144;  //12
extern int macdMAslow   =233;  //26;
extern int macdSigMA    =21;   //9
extern int macdPrice    =0;
extern int macdLnMode   =0;

extern int CCIperiod = 50;
extern int CCIprice  = 5;

extern double BarLevl = 5;

//0main;1signal
extern string  MA_Method_Price = "SMA0 EMA1 SMMA2 LWMA3||0O,1C 2H3L,4Md 5Tp 6WghC: Md(HL/2)4,Tp(HLC/3)5,Wgh(HLCC/4)6||macdLnMode:0main 1sig";
extern string TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF";

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




int init()
{
   SetIndexStyle(0,DRAW_ARROW);    SetIndexArrow(0,167);    SetIndexBuffer(0,buffer1);    SetIndexEmptyValue(0,EMPTY_VALUE); 
   SetIndexStyle(1,DRAW_ARROW);    SetIndexArrow(1,167);    SetIndexBuffer(1,buffer2);    SetIndexEmptyValue(1,EMPTY_VALUE);
   SetIndexStyle(2,DRAW_ARROW);    SetIndexArrow(2,167);    SetIndexBuffer(2,buffer3);    SetIndexEmptyValue(2,EMPTY_VALUE); 
   
   
   TimeFrame=MathMax(TimeFrame,Period());  
   
   string name1= " macd: "+macdMAfast+","+macdMAslow+","+macdSigMA;
   string name2= " cci: " +CCIperiod;

   IndicatorShortName("MACDCCI"+name1+name2+" "+TimeFrame);  

   
   return(0);
}



int start()
{
   int i,limit;
   int counted_bars = IndicatorCounted();
   if(counted_bars < 0) return(-1);
   if(counted_bars > 0) counted_bars--;
   limit = Bars - counted_bars;
         if(TimeFrame!=Period())
         limit = MathMax(limit,TimeFrame/Period());
   
   for (i=limit; i>= 0; i--)
   {
              int y =iBarShift(NULL,TimeFrame,Time[i]);
                  
      double  macd0 =iMACD(NULL,TimeFrame,macdMAfast,macdMAslow,macdSigMA,macdPrice,macdLnMode,y);
      double  macd1 =iMACD(NULL,TimeFrame,macdMAfast,macdMAslow,macdSigMA,macdPrice,macdLnMode,y+1);

      double  cci   =iCCI (NULL,TimeFrame,CCIperiod,CCIprice,y);
                
                
                         
      buffer1[i]=EMPTY_VALUE;    buffer2[i]=EMPTY_VALUE;      buffer3[i]=EMPTY_VALUE;    
      
      if (cci > 0 && macd0 > macd1 )   buffer1[i] = BarLevl;  
      else 
      if (cci < 0 && macd0 < macd1 )   buffer2[i] = BarLevl;  
      else                             buffer3[i] = BarLevl;
   
   }
   return(0);
}

Comments