//+------------------------------------------------------------------+ //| Trend Reversal.mq4 | //| * | //| * | //+------------------------------------------------------------------+ #property copyright "Integer" #property link "http://dmffx.com" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 DeepSkyBlue #property indicator_color2 Red //---- buffers double buy[]; double sell[]; double wb[]; double ws[]; double ld[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(5); SetIndexStyle(0,DRAW_ARROW); SetIndexArrow(0,233); SetIndexBuffer(0,buy); SetIndexEmptyValue(0,0.0); SetIndexStyle(1,DRAW_ARROW); SetIndexArrow(1,234); SetIndexBuffer(1,sell); SetIndexEmptyValue(1,0.0); SetIndexBuffer(2,wb); SetIndexBuffer(3,ws); SetIndexBuffer(4,ld); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit=Bars-IndicatorCounted(); for(int i=limit-1;i>=0;i--){ wb[i]=wb[i+1]; ws[i]=ws[i+1]; ld[i]=ld[i+1]; buy[i]=0; sell[i]=0; if(ws[i]>0){ if(Close[i]0){ if(Close[i]>wb[i]){ if(ld[i]==-1)buy[i]=Low[i]-Point*5; wb[i]=0; ld[i]=1; } } if(iHighest(NULL,0,MODE_HIGH,3,i)==i+1){ ws[i]=MathMin(Low[i],Low[i+1]); } else{ if(ws[i]>0){ if(Close[i]0){ if(Close[i]>wb[i]){ if(ld[i]==-1)buy[i]=Low[i]-Point*5; wb[i]=0; ld[i]=1; } } } } return(0); } //+------------------------------------------------------------------+