//+------------------------------------------------------------------+ //| past regression deviated.mq4 | //| Copyright © 2006, tageiger, aka fxid10t@yahoo.com | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2006, tageiger, aka fxid10t@yahoo.com" #property link "http://www.metaquotes.net" #property indicator_chart_window #property indicator_buffers 7 #property indicator_color1 Yellow #property indicator_color2 LimeGreen #property indicator_color3 LimeGreen #property indicator_color4 Orange #property indicator_color5 Orange #property indicator_color6 Red #property indicator_color7 Red //---- input parameters extern int period=0; /*default 0 means the channel will use the open time from "x" bars back on which ever time period the indicator is attached to. one can change to 1,5,15,30,60...etc to "lock" the start time to a specific period, and then view the "locked" channels on a different time period...*/ extern int LR.length=55; // bars back regression begins extern double std.channel.1 = 0.809; // 1st channel extern double std.channel.2 = 1.618; // 2nd channel extern double std.channel.3 = 2.618; // 3nd channel extern bool SoundAlert = false; extern bool PopUpAlert = false; extern bool EmailAlert = false; extern string LowerOrangeSoundFile = "alert.wav"; extern string UpperOrangeSoundFile = "alert2.wav"; extern string YellowSoundFile = "alert2.wav"; extern bool useCCI=true; extern int CCI_Period = 14; extern int buyzone=-100; extern int sellzone=100; double prevtimeLowerOrange = 0, prevtimeUpperOrange = 0, prevtimeYellow = 0; //---- indicator buffers double mean.Buffer[]; double high.1.Buffer[]; double low.1.Buffer[]; double high.2.Buffer[]; double low.2.Buffer[]; double high.3.Buffer[]; double low.3.Buffer[]; int init() { /*---- line shifts when drawing SetIndexShift(0,JawsShift); SetIndexShift(1,TeethShift); SetIndexShift(2,LipsShift); //---- first positions skipped when drawing*/ IndicatorBuffers(7); SetIndexDrawBegin(0,LR.length); SetIndexDrawBegin(1,LR.length); SetIndexDrawBegin(2,LR.length); SetIndexDrawBegin(3,LR.length); SetIndexDrawBegin(4,LR.length); SetIndexDrawBegin(5,LR.length); SetIndexDrawBegin(6,LR.length); //---- 3 indicator buffers mapping SetIndexBuffer(0,mean.Buffer); SetIndexBuffer(1,high.1.Buffer); SetIndexBuffer(2,low.1.Buffer); SetIndexBuffer(3,high.2.Buffer); SetIndexBuffer(4,low.2.Buffer); SetIndexBuffer(5,high.3.Buffer); SetIndexBuffer(6,low.3.Buffer); //---- drawing settings SetIndexStyle(0,DRAW_LINE,0); SetIndexArrow(0,158); SetIndexStyle(1,DRAW_LINE,0); SetIndexArrow(1,158); SetIndexStyle(2,DRAW_LINE,0); SetIndexArrow(2,158); SetIndexStyle(3,DRAW_LINE,0); SetIndexArrow(3,158); SetIndexStyle(4,DRAW_LINE,0); SetIndexArrow(4,158); SetIndexStyle(5,DRAW_LINE,0); SetIndexArrow(5,158); SetIndexStyle(6,DRAW_LINE,0); SetIndexArrow(6,158); //---- index labels SetIndexLabel(0,"mean"); SetIndexLabel(1,"1st Std up"); SetIndexLabel(2,"1st Std down"); SetIndexLabel(3,"2nd Std up"); SetIndexLabel(4,"2nd Std down"); SetIndexLabel(5,"3rd Std up"); SetIndexLabel(6,"3rd Std down"); //---- initialization done return(0);} int deinit() {ObjectsDeleteAll(0,OBJ_ARROW);ObjectDelete(period+"m "+LR.length+" TL");} int start() { ObjectDelete(period+"m "+LR.length+" TL"); int limit; int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; limit=Bars-counted_bars; //---- main loop for(int i=0; i low.2.Buffer[1] && Close[2] <= low.2.Buffer[2]) { AlertOK = false; if (useCCI) { if (cci > buyzone) AlertOK = true; } else AlertOK = true; if (AlertOK) { if ((prevtimeLowerOrange != Time[0])) { prevtimeLowerOrange = Time[0]; if (SoundAlert)PlaySound(LowerOrangeSoundFile); if (EmailAlert) SendMail("PRD BUY on " + Symbol()+ " " + Period() + " Minute Chart", " Close above Lower Orange @ Hour " + Hour() + " Minute " + Minute()); if (PopUpAlert)Alert(Symbol()," ",Period()," Minute Chart"," PRD Buy @ Hour ",Hour()," Minute ",Minute()); } } } // Check for close below upper Orange line for Sell signal if (Close[1] < high.2.Buffer[1] && Close[2] >= high.2.Buffer[2]) { AlertOK = false; if (useCCI) { if (cci= mean.Buffer[1]) && (Close[1] < mean.Buffer[2])) ||((Close[0] <= mean.Buffer[1]) && (Close[1] > mean.Buffer[2]))) { if ((prevtimeYellow != Time[0])) { prevtimeYellow = Time[0]; if (SoundAlert) PlaySound(YellowSoundFile); if (EmailAlert) SendMail("PRD First Close on " + Symbol() + " " + Period() + " Minute Chart", " Yellow Line @ Hour " + Hour() + " Minute " + Minute()); if (PopUpAlert) Alert(Symbol()," PRD Yellow Line @ Hour ",Hour()," Minute ",Minute()); } } } //+------------------------------------------------------------------+