Navigation:Home > Content >

DoubleCCIWoody-MTF-m5-Yan-Mod-S-28.mq4

Time: 2011-10-04 | Download file:DoubleCCIWoody-MTF-m5-Yan-Mod-S-28.mq4

//+------------------------------------------------------------------+
//|                                          Z MTF_DoubleWoodies.mq4 |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright " Z MTF_DoubleWoodies "
#property link      " Z MTF_DoubleWoodies "
//#include 

#property indicator_separate_window 
#property indicator_buffers 7
#property indicator_color1 Lime   
#property indicator_color2 Red   
#property indicator_width1 2
#property indicator_width2 2

#property indicator_color3 Silver
#property indicator_width3 2
#property indicator_color4 Yellow
#property indicator_width4 3
#property indicator_color5 Magenta
#property indicator_width5 3  
#property indicator_color6 White
#property indicator_width6 2
#property indicator_color7 Gold
#property indicator_width7 2

#property indicator_level1 165    
//#property indicator_level2 250
#property indicator_level3 54//62 for 15-CCi
#property indicator_level4 0
#property indicator_level5 -54//62
//#property indicator_level6 -250
#property indicator_level7 -165    

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

#property indicator_maximum 280                         
#property indicator_minimum -280  

extern int     TimeFrame         = 5;
extern int     TrendCCI_Period   = 28; //20
extern int     EntryCCI_Period   = 5;      
extern int     Trend_period      = 0;
extern int     CountBars         = 600;

extern bool    Use.EntryCCI.Alert   = False;
extern int     EntryCCI.Alert.Level = 0;
extern color   EntryCCI.Alert.ColorL = White;//LightGreen;
extern color   EntryCCI.Alert.ColorS = White;//PeachPuff;
extern bool    Draw.EntryCCI.Arrows   = True;

extern bool    Use.TrendCCI.Alert   = True;
extern int     TrendCCI.Alert.Level = 54;
extern color   TrendCCI.Alert.ColorL = Yellow;//RoyalBlue;
extern color   TrendCCI.Alert.ColorS = Yellow;//Red;
extern bool    Draw.TrendCCI.Arrows   = True;

//extern bool    Use.Pop.MSN.Alerts   =True;

extern int   LineSize1      = 2;
extern int   LineSize2      = 2;
extern int   LineSize3      = 2;//1

double TrendCCI[];
double EntryCCI[];
double CCITrendUp[];
double CCITrendDown[];
double CCINoTrend[];
double CCITimeBar[];
double ZeroLine[];


datetime alertTagTrendCCI;
datetime alertTagEntryCCI;
string signalTrendCCI;
string signalEntryCCI;
string lastsignalTrendCCI;
string lastsignalEntryCCI;

int iAlertCount = 0;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+

int init()
{
   SetIndexStyle  (0, DRAW_HISTOGRAM, 0,2);//Red
   SetIndexBuffer (0, CCITrendUp);
   SetIndexStyle  (1, DRAW_HISTOGRAM, 0,2);//Silver
   SetIndexBuffer (1, CCITrendDown);
   SetIndexStyle  (2, DRAW_HISTOGRAM, 0,2);//Gold
   SetIndexBuffer (2, CCINoTrend);
   SetIndexStyle  (3, DRAW_HISTOGRAM, 0,2);//DarkKhaki
   SetIndexBuffer (3, CCITimeBar);
   SetIndexStyle  (4, DRAW_LINE, STYLE_SOLID,2);//LimeGreen
   SetIndexBuffer (4, TrendCCI);
   SetIndexLabel  (4, "TrendCCI");
   SetIndexStyle  (5, DRAW_LINE, STYLE_SOLID,2);//Magenta
   SetIndexBuffer (5, EntryCCI);
   SetIndexLabel  (5, "EntryCCI");
   SetIndexStyle  (6, DRAW_LINE, STYLE_SOLID,2);//Gold 
   SetIndexBuffer (6, ZeroLine);  
  
   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";
   }
   string short_name;
   short_name="MTF Woodies ("+TimeFrame+","+TrendCCI_Period+","+EntryCCI_Period+")";
   IndicatorShortName(short_name);       
   SetIndexLabel(0,short_name);
   
   iAlertCount = 0;
}

int deinit()
{  for(int i=0;i0) limit++; else if (limit>100) limit=CountBars;  

   for(i=0,y=0;iEntryCCI.Alert.Level*(-1)) && (EntryCCI[1]EntryCCI.Alert.Level)) 
               {  signalEntryCCI="Long";
                  if ((lastsignalEntryCCI != signalEntryCCI) && (alertTagEntryCCI!=Time[0]) && (iAlertCount==0))
            //      {  Alert ("EntryCCI crossing LONG ",Symbol(),"   \n Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
            //         if (Use.Pop.MSN.Alerts) pop ((Symbol()+" "+Period()+"min "+" EntryCCI Crossing LONG "), "C:\\");
                    {   PlaySound("Alert2.wav");
                     iAlertCount++;
                  }
                  alertTagEntryCCI = Time[0];
                  lastsignalEntryCCI=signalEntryCCI;
               }
               else
               {  signalEntryCCI="None";
                  iAlertCount=0;
               }
            }
         }

         if (Use.TrendCCI.Alert)
         {
            if ((TrendCCI[2]>TrendCCI.Alert.Level*(-1)) && (TrendCCI[1]TrendCCI.Alert.Level)) 
               {  signalTrendCCI="Long";
                  if ((lastsignalTrendCCI != signalTrendCCI) && (alertTagTrendCCI!=Time[0]) && (iAlertCount==0))
               //   {  Alert ("TrendCCI crossing LONG ",Symbol(),"   \n Date="+TimeToStr(CurTime(),TIME_DATE)+" "+TimeHour(CurTime())+":"+TimeMinute(CurTime())+" Symbol="+Symbol()+" Period="+Period());
             //        if (Use.Pop.MSN.Alerts) pop ((Symbol()+" "+Period()+"min "+" TrendCCI Crossing LONG "), "C:\\");
                  {   PlaySound("Alert2.wav");
                     iAlertCount++;
                  }
                  alertTagTrendCCI = Time[0];
                  lastsignalTrendCCI=signalTrendCCI;
               }
               else
               {  signalTrendCCI="None";
                  iAlertCount=0;
               }
            }
         }
      }
   }
   
   if ((Draw.EntryCCI.Arrows==True) || (Draw.TrendCCI.Arrows==True))
   {
      for(i=600; i>=0; i--) 
      {  
         if (Draw.EntryCCI.Arrows==True)
         {
            if ((EntryCCI[i+2]>EntryCCI.Alert.Level*(-1)) && (EntryCCI[i+1]EntryCCI.Alert.Level)) 
               {  ObjectCreate ("EntryCCILong  "+TimeToStr(Time[i+1]),OBJ_ARROW,0,Time[i+1],Low[i+1]-8*Point);
                  ObjectSet    ("EntryCCILong  "+TimeToStr(Time[i+1]),OBJPROP_ARROWCODE,217);
                  ObjectSet    ("EntryCCILong  "+TimeToStr(Time[i+1]),OBJPROP_WIDTH,3);
                  ObjectSet    ("EntryCCILong  "+TimeToStr(Time[i+1]),OBJPROP_COLOR,EntryCCI.Alert.ColorL);
               }
            }
         }


         if (Draw.TrendCCI.Arrows==True)
         {
            if ((TrendCCI[i+2]>TrendCCI.Alert.Level*(-1)) && (TrendCCI[i+1]TrendCCI.Alert.Level)) 
               {  
                  ObjectCreate ("TrendCCILong  "+TimeToStr(Time[i+1]),OBJ_ARROW,0,Time[i+1],Low[i+1]-2*Point);//-12
                  ObjectSet    ("TrendCCILong  "+TimeToStr(Time[i+1]),OBJPROP_ARROWCODE,116);
                  ObjectSet    ("TrendCCILong  "+TimeToStr(Time[i+1]),OBJPROP_WIDTH,3);
                  ObjectSet    ("TrendCCILong  "+TimeToStr(Time[i+1]),OBJPROP_COLOR,TrendCCI.Alert.ColorL);
               }
            }
         }
      }
   }

   return(0);
}

Recommend