#TripleCCI_Woodies

Download script
Author: Copyright � 2005, Jason Robinson (jnrtrading).
#TripleCCI_Woodies

This script is a specialized technical analysis tool designed for the MetaTrader platform. It visualizes market momentum and trends by analyzing three different "speeds" of price movement simultaneously, providing traders with a clear picture of whether the market is trending, consolidating, or preparing for a breakout.

Core Functionality

The tool operates by calculating three distinct versions of the Commodity Channel Index (CCI)—a standard momentum oscillator. By using different time periods for these three calculations, the script allows you to see the "big picture" (long-term trend) alongside "fast action" (short-term moves).

  • Trend CCI: Identifies the broad, overarching direction of the market.
  • Entry CCI: Focuses on intermediate movements to help identify potential entry points.
  • Turbo CCI: Provides high-sensitivity data for immediate price fluctuations.

Intelligent Timeframe Adaptation

One of the primary features of this script is its ability to be "context-aware." It includes an Automatic Timeframe Setting. Instead of requiring the user to manually change settings every time they switch from a 1-minute chart to a Daily chart, the script automatically adjusts its internal calculation periods based on the timeframe you are currently viewing. This ensures that the indicators remain relevant and synchronized with the market's volatility at different scales.

Visual Logic and Behavior

The script translates complex data into a visual histogram and line system:

  • Trend Identification: The tool tracks how long the "Trend CCI" stays above or below zero. It uses a specific logic gate to determine when a trend has established itself.
  • Color Coding & States: It categorizes market movement into different states:
    • Trend Up/Down: Highlights periods where the market is moving decisively in one direction.
    • No Trend (Neutral): Identifies "sideways" markets or periods of indecision where price is hovering near the zero line.
    • Time Bar Highlights: Provides a visual cue when a trend has reached a certain maturity level, signaling a sustained move.

Alert System

To help traders who cannot watch the charts every second, the script includes a Zero Cross Alert. It monitors both the "Trend" and "Entry" indicators simultaneously. If both of these indicators cross the zero line at the same time (moving from negative to positive or vice-versa), the system can trigger a notification. This serves as a double-confirmation signal that momentum is shifting in both the short and medium terms.

Summary for the User

In simple terms, this tool acts as a multi-layered filter. It cleans up "market noise" by showing you not just where the price is going right now, but whether that movement has enough strength to be considered a lasting trend or just a temporary fluctuation. It automatically scales itself to your current chart and provides visual cues to help you distinguish between active trading opportunities and stagnant market conditions.

Indicators Used
Commodity channel index
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screen
10 Views
0 Downloads
0 Favorites
#TripleCCI_Woodies
//+------------------------------------------------------------------+
//|                                                    DoubleCCI.mq4 |
//|                   Copyright © 2005, Jason Robinson (jnrtrading). |
//|                                      http://www.jnrtrading.co.uk |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Jason Robinson (jnrtrading)."
#property link      "http://www.jnrtrading.co.uk"

#property indicator_separate_window
#property indicator_buffers 8                    
#property indicator_color1 LimeGreen
#property indicator_color2 Crimson
#property indicator_color3 Orange
#property indicator_color4 Yellow
#property indicator_color5 Gray
#property indicator_color6 LightGray
#property indicator_color7 DarkOrange               
#property indicator_color8 Yellow
#property indicator_level1 100
#property indicator_level2 200
#property indicator_level3 300
#property indicator_level4 -300
#property indicator_level5 -200
#property indicator_level6 -100
#property indicator_level7 50
#property indicator_level8 -50


//---- input parameters
extern int TrendCCI_Period = 50;
extern int EntryCCI_Period = 14;
extern int TurboCCI_Period = 6;                  
extern bool Zero_Cross_Alert;
extern bool Automatic_Timeframe_Setting;
extern int M1_TrendCCI_Period = 50;
extern int M1_EntryCCI_Period = 14;
extern int M1_TurboCCI_Period = 6;
extern int M5_TrendCCI_Period = 50;
extern int M5_EntryCCI_Period = 14;
extern int M5_TurboCCI_Period = 6;
extern int M15_TrendCCI_Period = 50;
extern int M15_EntryCCI_Period = 14;
extern int M15_TurboCCI_Period = 6;
extern int M30_TrendCCI_Period = 50;
extern int M30_EntryCCI_Period = 20;
extern int M30_TurboCCI_Period = 6;
extern int H1_TrendCCI_Period = 50;
extern int H1_EntryCCI_Period = 20;
extern int H1_TurboCCI_Period = 6;
extern int H4_TrendCCI_Period = 50;
extern int H4_EntryCCI_Period = 20;
extern int H4_TurboCCI_Period = 6;
extern int D1_TrendCCI_Period = 50;
extern int D1_EntryCCI_Period = 20;
extern int D1_TurboCCI_Period = 6;
extern int W1_TrendCCI_Period = 50;
extern int W1_EntryCCI_Period = 20;
extern int W1_TurboCCI_Period = 6;
extern int MN_TrendCCI_Period = 50;
extern int MN_EntryCCI_Period = 20;
extern int MN_TurboCCI_Period = 6;


double TrendCCI[];
double EntryCCI[];
double TurboCCI[];                  
double CCITrendUp[];
double CCITrendDown[];
double CCINoTrend[];
double CCITimeBar[];
double ZeroLine[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0, DRAW_HISTOGRAM, 0, 2);
   SetIndexBuffer(0, CCITrendUp);
   SetIndexStyle(1, DRAW_HISTOGRAM, 0, 2);
   SetIndexBuffer(1, CCITrendDown);
   SetIndexStyle(2, DRAW_HISTOGRAM, 0, 2);
   SetIndexBuffer(2, CCINoTrend);
   SetIndexStyle(3, DRAW_HISTOGRAM, 0, 2);
   SetIndexBuffer(3, CCITimeBar);
   SetIndexStyle(4, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexBuffer(4, TrendCCI);
   SetIndexLabel(4, "TrendCCI");
   SetIndexStyle(5, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexBuffer(5, EntryCCI);
   SetIndexLabel(5, "EntryCCI");
   SetIndexStyle(6, DRAW_LINE, STYLE_SOLID, 1);           
   SetIndexBuffer(6, TurboCCI);
   SetIndexLabel(6, "TurboCCI");
   SetIndexStyle(7, DRAW_LINE, STYLE_SOLID, 2);
   SetIndexBuffer(7, ZeroLine);
   
   
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() {

   int limit, i, trendCCI, entryCCI, turboCCI;
   static datetime prevtime = 0;
   static int trendUp = 0;
   static int trendDown = 0;

   int counted_bars = IndicatorCounted();
//---- check for possible errors
   if(counted_bars < 0) return(-1);
//---- last counted bar will be recounted
   if(counted_bars > 0) counted_bars--;

   limit=Bars-counted_bars;
   
   if (Automatic_Timeframe_Setting == true) {
      switch(Period()) {
         case 1: trendCCI = M1_TrendCCI_Period; entryCCI = M1_EntryCCI_Period; turboCCI = M1_TurboCCI_Period; break;
         case 5: trendCCI = M5_TrendCCI_Period; entryCCI = M5_EntryCCI_Period; turboCCI = M5_TurboCCI_Period; break;
         case 15: trendCCI = M15_TrendCCI_Period; entryCCI = M15_EntryCCI_Period; turboCCI = M15_TurboCCI_Period; break;
         case 30: trendCCI = M30_TrendCCI_Period; entryCCI = M30_EntryCCI_Period; turboCCI = M30_TurboCCI_Period; break;
         case 60: trendCCI = H1_TrendCCI_Period; entryCCI = H1_EntryCCI_Period; turboCCI = H1_TurboCCI_Period; break;
         case 240: trendCCI = H4_TrendCCI_Period; entryCCI = H4_EntryCCI_Period; turboCCI = H4_TurboCCI_Period; break;
         case 1440: trendCCI = D1_TrendCCI_Period; entryCCI = D1_EntryCCI_Period; turboCCI = D1_TurboCCI_Period; break;
         case 10080: trendCCI = W1_TrendCCI_Period; entryCCI = W1_EntryCCI_Period; turboCCI = W1_TurboCCI_Period; break;
         case 43200: trendCCI = MN_TrendCCI_Period; entryCCI = MN_EntryCCI_Period; turboCCI = MN_TurboCCI_Period; break;
      }
   }
   else {
      trendCCI = TrendCCI_Period;
      entryCCI = EntryCCI_Period;
      turboCCI = TurboCCI_Period;
   }
      IndicatorShortName("(TrendCCI: " + trendCCI + ", EntryCCI: " + entryCCI + ", TurboCCI: " + turboCCI + " ) ");
      for(i = limit; i >= 0; i--) {
         ZeroLine[i] = 0;
         TrendCCI[i] = iCCI(NULL, 0, trendCCI, PRICE_TYPICAL, i);
         EntryCCI[i] = iCCI(NULL, 0, entryCCI, PRICE_TYPICAL, i);
         TurboCCI[i] = iCCI(NULL, 0, turboCCI, PRICE_TYPICAL, i);         
      if (TrendCCI[i+1] < 0 && TrendCCI[i] >= 0) {
         if(trendDown < 4) {
            CCINoTrend[i] = 0;
            CCITrendUp[i] = TrendCCI[i];
            CCITrendDown[i] = 0;
            CCITimeBar[i] = 0;
         }
         else {
            trendUp = 0;
         }
      }
      if (TrendCCI[i] >= 0 ) {
         trendUp++;
         if(trendUp == 5) {
            CCITimeBar[i] = TrendCCI[i];
            CCINoTrend[i] = 0;
            CCITrendUp[i] = 0;
            CCITrendDown[i] = 0;
         }
         else if (trendUp > 5) {//(CCITimeBar[i+1] > 0 || CCITrendUp[i+1] > 0) {
            CCINoTrend[i] = 0;
            CCITrendUp[i] = TrendCCI[i];
            CCITrendDown[i] = 0;
            CCITimeBar[i] = 0;
        }
        else {
            CCINoTrend[i] = TrendCCI[i];
            CCITrendUp[i] = 0;
            CCITrendDown[i] = 0;
            CCITimeBar[i] = 0;
         }
      }
      
    
      if (TrendCCI[i+1] >= 0 && TrendCCI[i] < 0) {
         if(trendUp < 4) {
            CCINoTrend[i] = 0;
            CCITrendUp[i] = 0;
            CCITrendDown[i] = TrendCCI[i];
            CCITimeBar[i] = 0;
         }
         else {
            trendDown = 0;
         }
      }

      if (TrendCCI[i] <= 0 ) {
         trendDown++;
         if(trendDown == 5) {
            CCITimeBar[i] = TrendCCI[i];
            CCINoTrend[i] = 0;
            CCITrendUp[i] = 0;
            CCITrendDown[i] = 0;
         }
         else if (trendDown > 5) {//(CCITimeBar[i+1] < 0 || CCITrendDown[i+1] < 0) {
            CCINoTrend[i] = 0;
            CCITrendUp[i] = 0;
            CCITrendDown[i] = TrendCCI[i];
            CCITimeBar[i] = 0;
        }
        else {
            CCINoTrend[i] = TrendCCI[i];
            CCITrendUp[i] = 0;
            CCITrendDown[i] = 0;
            CCITimeBar[i] = 0;
         }
      }
      if (TrendCCI[i+1] == 0 && TrendCCI[i] >= 0 && CCITrendUp[i+2] > 0) {
         CCINoTrend[i] = 0;
         CCITrendUp[i] = TrendCCI[i];
         CCITrendDown[i] = 0;
         CCITimeBar[i] = 0;
     }
      
      
      
   }
   if (Zero_Cross_Alert == true) {
      if (prevtime == Time[0]) {
         return(0);
      }
      else {
         if(EntryCCI[0] < 0) {
            if((TrendCCI[0] < 0) && (TrendCCI[1] >= 0)) {
               Alert(Symbol(), " M", Period(), " Trend & Entry CCI Have both crossed îúçú zero");
            }
         }
         else if(EntryCCI[0] > 0) {
            if((TrendCCI[0] > 0) && (TrendCCI[1] <= 0)) {
               Alert(Symbol(), " M", Period(), " Trend & Entry CCI Have both crossed îòì zero");
            }
         }
         
         prevtime = Time[0];
      }
   }
   //ObjectCreate("ZeroLine", OBJ_HLINE, WindowFind("(TrendCCI: \" + trendCCI + \", EntryCCI: \" + entryCCI + \") "), 0, 0);
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments