MTF_CCI_Woodies_Lnx_v3_1





//+------------------------------------------------------------------+
//|                                          MTF_Real Woodie CCI.mq4 |
//|                Based on the code of Jason Robinson (jnrtrading). |
//|                                                                  |
//| After read the Woodie introductory document I started a search   |
//| for the right coloured CCI.                                      |
//| I can´t find anyone in accomplish with the explanation of Woodie |
//| So, I take the code from another CCI, and I added                |
//| the center LSMA line according to the official explanation.      |
//| Everything you see is an exact copy like it´s explained in the   |
//| document new_woodie_do1. Specially the colors.                   |
//| If you have some doubts can obtain a copy                        |
//| from http://woodiescciclub.com/                                  |
//|                                                                  |
//| Linuxser 2007                                                    |
//| for any doubts or suggestions contact me on Forex-TSD forum      |
//+------------------------------------------------------------------+
#property copyright "Under The GNU General Public License"
#property link      "www.gnu.org"


#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1 DodgerBlue   
//#property indicator_width1 2
#property indicator_color2 Red   //SaddleBrown
//#property indicator_width2 2
#property indicator_color3 Yellow //Gray
//#property indicator_width3 2
#property indicator_color4 Yellow //Gold
//#property indicator_width4 2
#property indicator_color5 DimGray //Black
//#property indicator_width5 1
#property indicator_color6 AliceBlue //Crimson
//#property indicator_width6 2
#property indicator_color7 Lime  //Gold  <<<<<<<<<<<<<<<<<<<<<<<<<<
//#property indicator_width7 2
#property indicator_color8 Magenta //Gold  <<<<<<<<<<<<<<<<<<<<<<<<<<
//#property indicator_width8 2

#property indicator_level1 450
#property indicator_level2 350
#property indicator_level3 250
#property indicator_level4 100
#property indicator_level5 -100
#property indicator_level6 -250
#property indicator_level7 -350
#property indicator_level8 -450

#property indicator_levelcolor Silver 
#property indicator_levelstyle STYLE_DOT
#property indicator_levelwidth 1


//---- input parameters
extern int TimeFrame=0;
extern int TrendCCI_Period = 55;//14
extern int EntryCCI_Period = 13;//6
extern int LSMAPeriod = 25;     // LSMA period
extern int Trend_period = 2;//5
extern int  CountBars=500; 
extern int   CCISize=2;
extern int   TCCISize=2;
extern int   TrendSize=1;
extern int   NoTrendSize=1;
extern int   LineSize3=0;

double TrendCCI[];
double EntryCCI[];
double CCITrendUp[];
double CCITrendDown[];
double CCINoTrend[];
double CCITimeBar[];
double ZeroLine[];
double LSMABuffer1[];
double LSMABuffer2[];
int EMAPeriod  = 55;     // EMA period
int FromZero   = 0;      // Distance from zero level
double LineHighEMA[];
double LineLowEMA[];

int trendUp, trendDown;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()  {
//---- indicators
   SetIndexStyle(4, DRAW_LINE, STYLE_SOLID,CCISize);
   SetIndexBuffer(4, TrendCCI);
   SetIndexLabel(4, "TrendCCI");
   SetIndexStyle(0, DRAW_HISTOGRAM, 0,TrendSize);
   SetIndexBuffer(0, CCITrendUp);
   SetIndexLabel (0, NULL);
   SetIndexStyle(1, DRAW_HISTOGRAM, 0,TrendSize);
   SetIndexBuffer(1, CCITrendDown);
   SetIndexLabel (1, NULL);
   SetIndexStyle(2, DRAW_HISTOGRAM, 0,NoTrendSize);
   SetIndexBuffer(2, CCINoTrend);
   SetIndexLabel (2, NULL);
   SetIndexStyle(3, DRAW_HISTOGRAM, 0,NoTrendSize);
   SetIndexBuffer(3, CCITimeBar);
   SetIndexLabel (3, NULL);
   SetIndexStyle(5, DRAW_LINE, STYLE_SOLID,TCCISize);// 1 <<<<<<<<<<<<<<<<<<<<<<<<<<<
   SetIndexBuffer(5, EntryCCI);
   SetIndexLabel(5, "EntryCCI");
   SetIndexStyle(6, DRAW_ARROW, STYLE_SOLID,LineSize3);
   SetIndexBuffer(6, LSMABuffer2);
   SetIndexLabel (6, NULL);
   SetIndexArrow(6,167);
   SetIndexStyle(7, DRAW_ARROW, STYLE_SOLID,LineSize3);
   SetIndexBuffer(7, LSMABuffer1); 
   SetIndexArrow(7,167);
   SetIndexLabel (7, NULL);

//---- name for DataWindow and indicator subwindow label
   switch(TimeFrame)
   {
      case 1 : string TimeFrameStr="Period_M1"; break;
      case 5 : TimeFrameStr="Period_M5"; break;
      case 15 : TimeFrameStr="Period_M15"; break;
      case 30 : TimeFrameStr="Period_M30"; break;
      case 60 : TimeFrameStr="Period_H1"; break;
      case 240 : TimeFrameStr="Period_H4"; break;
      case 1440 : TimeFrameStr="Period_D1"; break;
      case 10080 : TimeFrameStr="Period_W1"; break;
      case 43200 : TimeFrameStr="Period_MN1"; break;
      default : TimeFrameStr="Current Timeframe";
   }
      IndicatorShortName("MTF_wCCI[TF"+TimeFrame+"]("+ TrendCCI_Period+") [TCCI: " + EntryCCI_Period + "] [per LSMA: " + LSMAPeriod + "] [Trend: " + Trend_period + "] ");   

  }
//----
   return(0);
 
 
//+------------------------------------------------------------------+
//| MTF                                                              |
//+------------------------------------------------------------------+
int start()
  {
   datetime TimeArray[];
   int    i,limit,y=0,counted_bars=IndicatorCounted();
 
// Plot defined time frame on to current time frame
   ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame); 
   
    limit=Bars-counted_bars+TimeFrame/Period();
   for(i=0,y=0;i<limit;i++)
   {
   if (Time[i]<TimeArray[y]) y++;

/***********************************************************   
   Add your main indicator loop below.  You can reference an existing
      indicator with its iName  or iCustom.
   Rule 1:  Add extern inputs above for all neccesary values   
   Rule 2:  Use 'TimeFrame' for the indicator time frame
   Rule 3:  Use 'y' for your indicator's shift value
 **********************************************************/  
 
  CCITrendUp[i]=iCustom(NULL,TimeFrame,"CCI_Woodies_Lnx_v3_1",TrendCCI_Period,EntryCCI_Period,LSMAPeriod,Trend_period,CountBars,CCISize,TCCISize,TrendSize,NoTrendSize,LineSize3,0,y);
  CCITrendDown[i]=iCustom(NULL,TimeFrame,"CCI_Woodies_Lnx_v3_1",TrendCCI_Period,EntryCCI_Period,LSMAPeriod,Trend_period,CountBars,CCISize,TCCISize,TrendSize,NoTrendSize,LineSize3,1,y);
  CCINoTrend[i]=iCustom(NULL,TimeFrame,"CCI_Woodies_Lnx_v3_1",TrendCCI_Period,EntryCCI_Period,LSMAPeriod,Trend_period,CountBars,CCISize,TCCISize,TrendSize,NoTrendSize,LineSize3,2,y);
  CCITimeBar[i]=iCustom(NULL,TimeFrame,"CCI_Woodies_Lnx_v3_1",TrendCCI_Period,EntryCCI_Period,LSMAPeriod,Trend_period,CountBars,CCISize,TCCISize,TrendSize,NoTrendSize,LineSize3,3,y);
  TrendCCI[i]=iCustom(NULL,TimeFrame,"CCI_Woodies_Lnx_v3_1",TrendCCI_Period,EntryCCI_Period,LSMAPeriod,Trend_period,CountBars,CCISize,TCCISize,TrendSize,NoTrendSize,LineSize3,4,y);
  EntryCCI[i]=iCustom(NULL,TimeFrame,"CCI_Woodies_Lnx_v3_1",TrendCCI_Period,EntryCCI_Period,LSMAPeriod,Trend_period,CountBars,CCISize,TCCISize,TrendSize,NoTrendSize,LineSize3,5,y);
  LSMABuffer2[i]=iCustom(NULL,TimeFrame,"CCI_Woodies_Lnx_v3_1",TrendCCI_Period,EntryCCI_Period,LSMAPeriod,Trend_period,CountBars,CCISize,TCCISize,TrendSize,NoTrendSize,LineSize3,6,y);
  LSMABuffer1[i]=iCustom(NULL,TimeFrame,"CCI_Woodies_Lnx_v3_1",TrendCCI_Period,EntryCCI_Period,LSMAPeriod,Trend_period,CountBars,CCISize,TCCISize,TrendSize,NoTrendSize,LineSize3,7,y);

 
   SetIndexBuffer(0,  CCITrendUp);
   SetIndexBuffer(1, CCITrendDown);
   SetIndexBuffer(2, CCINoTrend);
   SetIndexBuffer(3, CCITimeBar);
   SetIndexBuffer(4, TrendCCI);
   SetIndexBuffer(5, EntryCCI);
   SetIndexBuffer(6, LSMABuffer2);
   SetIndexBuffer(7, LSMABuffer1);  
   
   }  
     
//
   return(0);
  }
//+-------------------------------------





Sample





Analysis



Market Information Used:

Series array that contains open time of each bar


Indicator Curves created:

Implements a curve of type DRAW_LINE

Implements a curve of type DRAW_HISTOGRAM
Implements a curve of type DRAW_ARROW

Indicators Used:




Custom Indicators Used:
CCI_Woodies_Lnx_v3_1

Order Management characteristics:

Other Features: