Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
CCIFilter_Email
//+------------------------------------------------------------------+
//| CCIFilter vX.mq4 |
//| |
//| mod by Raff, email & sound by cja |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Forex-TSD.com "
#property link "http://www.forex-tsd.com/"
#property indicator_separate_window
#property indicator_buffers 7
#property indicator_color1 Gray
#property indicator_color2 Green
#property indicator_color3 Aqua
#property indicator_color4 Gold
#property indicator_color5 Tomato
#property indicator_color6 Red
#property indicator_color7 Lime
#property indicator_width1 3
#property indicator_width2 3
#property indicator_width3 3
#property indicator_width4 3
#property indicator_width5 3
#property indicator_width6 2
#property indicator_width7 2
//---- input parameters
extern string IIIIIIIIIIIII="<<< CCI Settings >>>>>>>>>>>";
extern int CCIPeriod = 14;
extern int CCIPrice = 0;
extern string IIIIIIIIIIIIII="<<< Alert Settings >>>>>>>>>>>";
extern bool SoundAlert_ON = false;
extern string SoundFile ="alert2.wav";
extern bool SendEmail = false;
extern bool Pop_UP_Alert = false;
extern string IIIIIIIIIIIIII....Arrow_Numbers="<<< 233/234-241/242-225/226 >>>>>>>>>>>";
extern string IIIIIIIIIIIIII....Dot_Numbers="<<< 159/158/108/174 >>>>>>>>>>>";
extern int SignalUP_Arrow = 233;
extern int SignalDN_Arrow = 234;
extern int UpperTriggerLevel = 100;
extern int LowerTriggerLevel = -100;
extern int CriticalLevel_UP = 250;
extern int CriticalLevel_DN = -250;
extern bool HISTOGRAM = false;
extern bool Alerts = true;
extern string CriticalLevelUP = "Critical Level UPPER";
extern string CriticalLevelDN = "Critical Level LOWER";
extern string ZeroBuyAlert = "Zero Cross";
extern string ZeroSellAlert = "Zero Cross";
extern string UpperTriggerBuyAlert = "Upper Trigger Cross";
extern string UpperTriggerSellAlert = "Upper Trigger Cross";
extern string LowerTriggerBuyAlert = "Lower Trigger Cross";
extern string LowerTriggerSellAlert = "Lower Trigger Cross";
//---- indicator buffers
double CCI[];
double UpBuffer1[];
double UpBuffer2[];
double DnBuffer1[];
double DnBuffer2[];
double DnArr[];
double UpArr[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(7);
int DrawType = DRAW_LINE;
if (HISTOGRAM) DrawType = DRAW_HISTOGRAM;
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID);
SetIndexStyle(1,DrawType,STYLE_SOLID);
SetIndexStyle(2,DrawType,STYLE_SOLID);
SetIndexStyle(3,DrawType,STYLE_SOLID);
SetIndexStyle(4,DrawType,STYLE_SOLID);
SetIndexStyle(5,DRAW_ARROW);
SetIndexArrow(5,SignalDN_Arrow);
SetIndexBuffer(5,DnArr);
SetIndexStyle(6,DRAW_ARROW);
SetIndexArrow(6,SignalUP_Arrow);
SetIndexBuffer(6,UpArr);
SetIndexBuffer(0,CCI);
SetIndexBuffer(1,UpBuffer1);
SetIndexBuffer(2,UpBuffer2);
SetIndexBuffer(3,DnBuffer1);
SetIndexBuffer(4,DnBuffer2);
SetIndexBuffer(5,DnArr);
SetIndexBuffer(6,UpArr);
SetLevelValue(0,ZeroBuyAlert );
SetLevelValue(1,UpperTriggerLevel );
SetLevelValue(2,CriticalLevel_UP );
SetLevelValue(3,CriticalLevel_DN);
SetLevelValue(4,LowerTriggerLevel);
SetLevelStyle(STYLE_DOT,1,DarkSlateGray);
IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)-2);
string ALERT1="",ALERT2="",ALERT3="";
if(SoundAlert_ON==true)ALERT1="ON";
if(SoundAlert_ON==false)ALERT1="OFF";
if(SendEmail==true)ALERT2="ON";
if(SendEmail==false)ALERT2="OFF";
if(Pop_UP_Alert==true)ALERT3="ON";
if(Pop_UP_Alert==false)ALERT3="OFF";
string short_name;
short_name="CCI [ Pop_UP "+ALERT3+" ] [ Sound "+ALERT1+" ] [ Email "+ALERT2+" ]";
IndicatorShortName(short_name);
SetIndexLabel(0,"CCI");
SetIndexLabel(1,"UpTrend");
SetIndexLabel(2,"Mild UpTrend");
SetIndexLabel(3,"Mild DownTrend");
SetIndexLabel(4,"DownTrend");
SetIndexDrawBegin(0,CCIPeriod);
SetIndexDrawBegin(1,CCIPeriod);
SetIndexDrawBegin(2,CCIPeriod);
SetIndexDrawBegin(3,CCIPeriod);
SetIndexDrawBegin(4,CCIPeriod);
return(0);
}
//+------------------------------------------------------------------+
//| CCIFilter |
//+------------------------------------------------------------------+
int start()
{
int shift,trend;
double CCI0, CCI1;
double UpDnZero, UpDnBuffer;
if (UpperTriggerLevel<0) UpperTriggerLevel=0;
if (LowerTriggerLevel>0) UpperTriggerLevel=0;
for(shift=Bars-CCIPeriod-1;shift>=0;shift--)
{
DnArr[shift]=EMPTY_VALUE;
UpArr[shift]=EMPTY_VALUE;
CCI[shift]=EMPTY_VALUE;
CCI0=iCCI(NULL,0,CCIPeriod,CCIPrice,shift);
CCI1=iCCI(NULL,0,CCIPeriod,CCIPrice,shift+1);
UpDnZero=0; UpDnBuffer=1;
if (!HISTOGRAM) {UpDnZero=EMPTY_VALUE; UpDnBuffer=CCI0; CCI[shift]=CCI0;}
UpBuffer1[shift]=UpDnZero;
UpBuffer2[shift]=UpDnZero;
DnBuffer1[shift]=UpDnZero;
DnBuffer2[shift]=UpDnZero;
if (CCI0>UpperTriggerLevel) UpBuffer1[shift]=UpDnBuffer;
if (CCI0>0 && CCI0<=UpperTriggerLevel) UpBuffer2[shift]=UpDnBuffer;
if (CCI0<0 && CCI0>=LowerTriggerLevel) DnBuffer1[shift]=UpDnBuffer;
if (CCI0<LowerTriggerLevel) DnBuffer2[shift]=UpDnBuffer;
if (CCI0>0 && CCI1<=0) {if(!HISTOGRAM) UpArr[shift]=0; if(shift==0) Alerts(ZeroBuyAlert);}
if (CCI0<0 && CCI1>=0) {if(!HISTOGRAM) DnArr[shift]=0; if(shift==0) Alerts(ZeroSellAlert);}
if (CCI0>UpperTriggerLevel && CCI1<=UpperTriggerLevel && UpperTriggerLevel>0) {if(!HISTOGRAM) UpArr[shift]=UpperTriggerLevel; if(shift==0) Alerts(UpperTriggerBuyAlert);}
if (CCI0<UpperTriggerLevel && CCI1>=UpperTriggerLevel && UpperTriggerLevel>0) {if(!HISTOGRAM) DnArr[shift]=UpperTriggerLevel; if(shift==0) Alerts(UpperTriggerSellAlert);}
if (CCI0>LowerTriggerLevel && CCI1<=LowerTriggerLevel && LowerTriggerLevel<0) {if(!HISTOGRAM) UpArr[shift]=LowerTriggerLevel; if(shift==0) Alerts(LowerTriggerBuyAlert);}
if (CCI0<LowerTriggerLevel && CCI1>=LowerTriggerLevel && LowerTriggerLevel<0) {if(!HISTOGRAM) DnArr[shift]=LowerTriggerLevel; if(shift==0) Alerts(LowerTriggerSellAlert);}
if (MathAbs(CCI0)>CriticalLevel_UP && MathAbs(CCI1)<=CriticalLevel_UP) {if(shift==0) Alerts(CriticalLevelUP);}
if (MathAbs(CCI0)<CriticalLevel_DN && MathAbs(CCI1)>=CriticalLevel_DN) {if(shift==0) Alerts(CriticalLevelDN);}
}
return(0);
}
void Alerts(string AlertText)
{
static datetime timeprev;
if(timeprev<iTime(NULL,0,0) && Alerts) {timeprev=iTime(NULL,0,0);if (Pop_UP_Alert==true)Alert(AlertText," ",Symbol()," - ",Period()," at ", Close[0]," - ", TimeToStr(TimeLocal(),TIME_SECONDS));
if (SendEmail==true)SendMail("CCI Alert",AlertText+"\n "+Symbol()+" M"+Period()+""+DoubleToStr(Bid,Digits)+"\n"
+"Time = "+TimeToStr(TimeLocal(),TIME_SECONDS)+"\n"+"Date = "+TimeToStr(TimeLocal(),TIME_DATE)+"");
if(SoundAlert_ON==true)PlaySound(SoundFile);}
}
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---