//+------------------------------------------------------------------+ //| FX_Sniper's_Ergodic_CCI_&_Trigger_Alert_Fast by mladen | //+------------------------------------------------------------------+ //2008fxtsd //mod 2009fxtsd Trix_4c_alert_mtf.mq4 #property copyright "mladen" #property link "mladenfx@gmail.com" #property indicator_separate_window #property indicator_buffers 6 #property indicator_color1 Red #property indicator_color2 Green #property indicator_color3 Red #property indicator_color4 Green #property indicator_color5 DarkOrange #property indicator_color6 DodgerBlue #property indicator_width3 2 #property indicator_width4 2 #property indicator_width5 1 #property indicator_width6 1 // // // // // extern int Trixperiod = 5; extern int sigMAperiod = 7; extern int priorsmzper = 3; extern int smzperiod = 3; extern int MAmethod = 1; extern int price = 5; extern int TimeFrame = 0; extern bool alertsOn = false; extern bool alertsSound = true; extern bool alertsMessage = true; extern bool alertsEmail = false; extern bool osma = true; extern double osmaMult = 2; extern string note_timeframes = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN|0-CurrentTF"; 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"; string IndicatorFileName; double ErgoCCI[]; double MainCCI[]; double buffer1[]; double buffer2[]; double buffer3[]; double buffer4[]; double buffer5[]; double buffer6[]; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int init() { IndicatorBuffers(8); SetIndexBuffer(0,buffer1); SetIndexBuffer(1,buffer4); SetIndexBuffer(2,buffer3); SetIndexBuffer(3,buffer2); SetIndexBuffer(4,MainCCI); SetIndexLabel(4,"Trix"); SetIndexBuffer(5,ErgoCCI); SetIndexLabel(5,"TrixSigMA"); SetIndexBuffer(6,buffer5); SetIndexBuffer(7,buffer6); SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexStyle(2,DRAW_HISTOGRAM); SetIndexStyle(3,DRAW_HISTOGRAM); TimeFrame=MathMax(TimeFrame, Period()); string shortname = "Trix ("+Trixperiod+","+sigMAperiod+"; "+priorsmzper+","+smzperiod+"; "+MAmethod+","+price+") M"+TimeFrame+" "; IndicatorShortName (shortname); IndicatorFileName = WindowExpertName(); return(0); } // // // // // int start() { int i,r,limit,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]); buffer1[i] = iCustom(NULL,TimeFrame,IndicatorFileName,Trixperiod,sigMAperiod,priorsmzper,smzperiod,MAmethod,price,0,alertsOn,alertsSound,alertsMessage, alertsEmail,osma,osmaMult,0,y); buffer4[i] = iCustom(NULL,TimeFrame,IndicatorFileName,Trixperiod,sigMAperiod,priorsmzper,smzperiod,MAmethod,price,0,alertsOn,alertsSound,alertsMessage, alertsEmail,osma,osmaMult,1,y); buffer3[i] = iCustom(NULL,TimeFrame,IndicatorFileName,Trixperiod,sigMAperiod,priorsmzper,smzperiod,MAmethod,price,0,alertsOn,alertsSound,alertsMessage, alertsEmail,osma,osmaMult,2,y); buffer2[i] = iCustom(NULL,TimeFrame,IndicatorFileName,Trixperiod,sigMAperiod,priorsmzper,smzperiod,MAmethod,price,0,alertsOn,alertsSound,alertsMessage, alertsEmail,osma,osmaMult,3,y); MainCCI[i] = iCustom(NULL,TimeFrame,IndicatorFileName,Trixperiod,sigMAperiod,priorsmzper,smzperiod,MAmethod,price,0,alertsOn,alertsSound,alertsMessage, alertsEmail,osma,osmaMult,4,y); ErgoCCI[i] = iCustom(NULL,TimeFrame,IndicatorFileName,Trixperiod,sigMAperiod,priorsmzper,smzperiod,MAmethod,price,0,alertsOn,alertsSound,alertsMessage, alertsEmail,osma,osmaMult,5,y); } return(0); } // // // // // buffer1[i]=EMPTY_VALUE; buffer2[i]=EMPTY_VALUE; buffer3[i]=EMPTY_VALUE; buffer4[i]=EMPTY_VALUE; buffer5[i]=EMPTY_VALUE; buffer6[i]=EMPTY_VALUE; for(i=limit;i>=0;i--) buffer1[i]= iMA(NULL,0,priorsmzper,0,MAmethod,price,i); for(i=limit;i>=0;i--) buffer2[i]= iMAOnArray(buffer1,0,Trixperiod,0,MAmethod,i); for(i=limit;i>=0;i--) buffer3[i]= iMAOnArray(buffer2,0,Trixperiod,0,MAmethod,i); for(i=limit;i>=0;i--) buffer5[i]= iMAOnArray(buffer3,0,Trixperiod,0,MAmethod,i); for(i=limit;i>=0;i--) buffer4[i]= (buffer5[i]-buffer5[i+1])*1000; for(i=limit;i>=0;i--) MainCCI[i]= iMAOnArray(buffer4,0,smzperiod,0,MAmethod,i); for(i=limit;i>=0;i--) ErgoCCI[i]= iMAOnArray(MainCCI,0,sigMAperiod,0,MAmethod,i); for(i=limit;i>=0;i--) if (!osma) buffer6[i]=ErgoCCI[i]; else buffer6[i]=(iMAOnArray(MainCCI,0,smzperiod,0,MAmethod,i)- iMAOnArray(ErgoCCI,0,smzperiod,0,MAmethod,i))*osmaMult; // // // for(i=limit;i>=0;i--) { buffer1[i]=EMPTY_VALUE; buffer2[i]=EMPTY_VALUE; buffer3[i]=EMPTY_VALUE; buffer4[i]=EMPTY_VALUE; if (buffer6[i]>buffer6[i+1]) { if (buffer6[i]>0) buffer2[i]=buffer6[i]; else buffer3[i]=buffer6[i]; } else if (buffer6[i]>0) buffer4[i]=buffer6[i]; else buffer1[i]=buffer6[i]; // // // if (alertsOn) { if(MainCCI[i+1] < ErgoCCI[i+1] && MainCCI[i] > ErgoCCI[i]) doAlert("goes long"); if(MainCCI[i+1] > ErgoCCI[i+1] && MainCCI[i] < ErgoCCI[i]) doAlert("goes short"); } } return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // // // // // void doAlert(string doesWhat) { static string previousAlert="nothing"; static datetime previousTime; string message; if (previousAlert != doesWhat || previousTime != Time[0]) { previousAlert = doesWhat; previousTime = Time[0]; // // // // // message = StringConcatenate(Symbol()," M",Period()," ",TimeToStr(TimeLocal(),TIME_SECONDS)," trix ",doesWhat); if (alertsSound) PlaySound("ok.wav");//alert2 if (alertsMessage) Alert(message); if (alertsEmail) SendMail(StringConcatenate(Symbol()," trix crossing "),message); } }
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Indicator Curves created:
Implements a curve of type DRAW_HISTOGRAM
Indicators Used:
Moving average indicator
Custom Indicators Used:
IndicatorFileName
Order Management characteristics:
Other Features:
It issuies visual alerts to the screen
It plays sound alerts
It sends emails