//+----------------------------------------------------------+ //| Ehlers fisher transform.mq4 | //| mladen | //+----------------------------------------------------------+ #property copyright "mladen" #property link "mladenfx@gmail.com" #property indicator_separate_window #property indicator_buffers 5 #property indicator_color1 clrMaroon #property indicator_color2 clrLime #property indicator_color3 clrOrangeRed #property indicator_color4 clrOrangeRed #property indicator_color5 clrNONE //#property indicator_width1 3 //#property indicator_width2 3 //#property indicator_width3 3 #property indicator_style5 STYLE_DOT #property indicator_levelcolor 1776411 #property indicator_levelstyle 0 //#property strict // // // // // input int period = 2; // Transform period input ENUM_APPLIED_PRICE PriceType_h = PRICE_HIGH; // Price to use input ENUM_APPLIED_PRICE PriceType_l = PRICE_LOW; // Price to use input bool Price_reversal = false; input int Ma = 2; input ENUM_MA_METHOD ma_mode = MODE_EMA; input double Weight = 0.6; // Smoothing weight //input double coefficient_ft = 1; //input double StickLevel = 1.0; //input double AdditionalLevel = 1.0; input bool fast_1 = false; input bool fast_2 = true; //input bool fast_ft_1 = true; //input bool fast_ft_2 = true; // // // // // int prv; //double Bft[]; double buffer1[]; double buffer2[]; double buffer3[]; double buffer4[]; double Prices_h[]; double Prices_l[]; double Values1[]; double Cross[]; //double Bs[]; //double Values2[]; //+----------------------------------------------------------+ //| | //+----------------------------------------------------------+ // // // // // int init() { IndicatorBuffers(11); //SetIndexBuffer(0,Bft); SetIndexBuffer(1,buffer1); SetIndexBuffer(2,buffer2); SetIndexBuffer(3,buffer3); SetIndexBuffer(4,buffer4); SetIndexBuffer(5,Prices_h); SetIndexBuffer(6,Prices_l); SetIndexBuffer(7,Values1); SetIndexBuffer(8,Cross); //SetIndexBuffer(9,Bs); //SetIndexBuffer(10,Values2); //IndicatorShortName("Ehlers\' Fisher transform ("+(string)period+")"); IndicatorShortName(NULL); //SetLevelValue(0,StickLevel); //SetLevelValue(1,-StickLevel); //SetLevelValue(2,AdditionalLevel); //SetLevelValue(3,-AdditionalLevel); if(Price_reversal==false){prv=1;}else{prv=-1000000;} return(0); } //+----------------------------------------------------------+ //| | //+----------------------------------------------------------+ // // // // // int start() { int counted_bars=IndicatorCounted(); if(counted_bars < 0) return(-1); if(counted_bars > 0) counted_bars--; int limit = MathMin(Bars-counted_bars,Bars-1); // // // // // double alpha = 2.0/(1.0+Weight); if (Cross[limit]==-1) CleanPoint(limit,buffer2,buffer3); for(int i=limit; i>=0; i--) { Prices_h[i] = iMA(NULL,0,Ma,0,MODE_SMA,PriceType_h,i)*prv; Prices_l[i] = iMA(NULL,0,Ma,0,MODE_SMA,PriceType_l,i)*prv; // // // // // double MaxH = Prices_h[ArrayMaximum(Prices_h,period,i)]; double MinL = Prices_l[ArrayMinimum(Prices_l,period,i)]; if (MaxH!=MinL && ibuffer4[i]) Cross[i]= 1; if (buffer1[i] StickLevel) Bs[i] = period; // if (buffer1[i+1]>=-StickLevel && buffer1[i]<-StickLevel) Bs[i] = period; // // // // // // // // // // // // // MaxH = Prices_h[ArrayMaximum(Prices_h,Bs[i],i)]; // MinL = Prices_l[ArrayMinimum(Prices_l,Bs[i],i)]; // if (MaxH!=MinL && i=Bars-3) return; if ((second[i] != EMPTY_VALUE) && (second[i+1] != EMPTY_VALUE)) second[i+1] = EMPTY_VALUE; else if ((first[i] != EMPTY_VALUE) && (first[i+1] != EMPTY_VALUE) && (first[i+2] == EMPTY_VALUE)) first[i+1] = EMPTY_VALUE; } void PlotPoint(int i,double& first[],double& second[],double& from[]) { if (i>=Bars-2) return; if (first[i+1] == EMPTY_VALUE) if (first[i+2] == EMPTY_VALUE) { first[i] = from[i]; first[i+1] = from[i+1]; second[i] = EMPTY_VALUE; } else { second[i] = from[i]; second[i+1] = from[i+1]; first[i] = EMPTY_VALUE; } else { first[i] = from[i]; second[i] = EMPTY_VALUE; } }