//---------------------------------------------------------- // //---------------------------------------------------------- #property copyright "mladen" #property link "www.forex-tsd.com" #property indicator_separate_window #property indicator_buffers 5 #property indicator_color1 LimeGreen #property indicator_color2 Red #property indicator_color3 Red #property indicator_color4 LimeGreen #property indicator_color5 DarkOrange #property indicator_width1 2 #property indicator_width3 2 #property indicator_width5 2 #property indicator_level1 -1.0 #property indicator_level2 1.0 #property indicator_level3 -2.0 #property indicator_level4 2.0 #property indicator_minimum -3.5 #property indicator_maximum 3.5 // // // // // extern int FishPeriod = 8; extern int FishPrice = PRICE_CLOSE; extern bool alertsOn = true; extern bool alertsOnCurrent = true; extern bool alertsMessage = true; extern bool alertsSound = false; extern bool alertsEmail = false; // // // // // double buffer1[]; double buffer2[]; double buffer3[]; double buffer4[]; double buffer5[]; double Prices[]; double Values[]; double trend[]; //---------------------------------------------------------- // //---------------------------------------------------------- // // // // // int init() { IndicatorBuffers(8); SetIndexBuffer(0,buffer1); SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexBuffer(1,buffer2); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexBuffer(2,buffer3); SetIndexStyle(2,DRAW_HISTOGRAM); SetIndexBuffer(3,buffer4); SetIndexStyle(3,DRAW_HISTOGRAM); SetIndexBuffer(4,buffer5); SetIndexBuffer(5,Prices); SetIndexBuffer(6,Values); SetIndexBuffer(7,trend); IndicatorShortName("Ehlers\' Fisher transform ("+FishPeriod+")"); return(0); } //---------------------------------------------------------- // //---------------------------------------------------------- // // // // // int start() { int counted_bars=IndicatorCounted(); int i,limit; if(counted_bars < 0) return(-1); if(counted_bars > 0) counted_bars--; limit = MathMin(Bars-counted_bars,Bars-1); // // // // // for(i=limit; i>=0; i--) { Prices[i] = iMA(NULL,0,1,0,MODE_EMA,FishPrice,i); // // // // // double MaxH = Prices[ArrayMaximum(Prices,FishPeriod,i)]; double MinL = Prices[ArrayMinimum(Prices,FishPeriod,i)]; if (MaxH!=MinL) Values[i] = 0.33*2*((Prices[i]-MinL)/(MaxH-MinL)-0.5)+0.67*Values[i+1]; else Values[i] = 0.00; Values[i] = MathMin(MathMax(Values[i],-0.999),0.999); buffer5[i] = 0.5*MathLog((1+Values[i])/(1-Values[i]))+0.5*buffer5[i+1]; // // // // // trend[i] = trend[i+1]; buffer1[i] = EMPTY_VALUE; buffer2[i] = EMPTY_VALUE; buffer3[i] = EMPTY_VALUE; buffer4[i] = EMPTY_VALUE; if (buffer5[i]>0) trend[i] = 1; if (buffer5[i]<0) trend[i] = -1; if (trend[i]==-1) { if (buffer5[i]buffer5[i+1]) buffer4[i]=buffer5[i]; } if(trend[i]==1) { if (buffer5[i]buffer5[i+1]) buffer1[i]=buffer5[i]; } } manageAlerts(); return(0); } //---------------------------------------------------------- // //---------------------------------------------------------- // // // // // void manageAlerts() { if (alertsOn) { if (alertsOnCurrent) int whichBar = 0; else whichBar = 1; if (trend[whichBar] != trend[whichBar+1]) { if (trend[whichBar] == 1) doAlert(whichBar,"up"); if (trend[whichBar] ==-1) doAlert(whichBar,"down"); } } } // // // // // void doAlert(int forBar, string doWhat) { static string previousAlert="nothing"; static datetime previousTime; string message; if (previousAlert != doWhat || previousTime != Time[forBar]) { previousAlert = doWhat; previousTime = Time[forBar]; // // // // // message = StringConcatenate(Symbol()," at ",TimeToStr(TimeLocal(),TIME_SECONDS),"Fishert transform crossed zero line "+doWhat); if (alertsMessage) Alert(message); if (alertsEmail) SendMail(StringConcatenate(Symbol(),"Ehler\'s fisher transform"),message); if (alertsSound) PlaySound("alert2.wav"); } }