//+------------------------------------------------------------------+ //| SnR.mq5 | //| SnR Copyright 2016, fxborg | //| http://fxborg-labo.hateblo.jp/ | //+------------------------------------------------------------------+ #property copyright "Copyright 2016, fxborg" #property link "http://fxborg-labo.hateblo.jp/" #property version "1.00" #property indicator_chart_window #property indicator_buffers 3 #property indicator_plots 2 #property indicator_type1 DRAW_ARROW #property indicator_color1 clrRed #property indicator_width1 1 #property indicator_type2 DRAW_ARROW #property indicator_color2 clrDodgerBlue #property indicator_width2 1 //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ input double InpSize1=0.4; // Damashi Size input double InpSize2=1.0; // Modoshi Size input double InpSize3=1.8; // Minimum Range Size input double InpSize4=6.0; // Maximum Range Size input int InpPeriod=30; // Channel Period input int InpLookBack=120; // LookBack double SUP[]; double REG[]; double ATR[]; int AtrPeriod=50; double AtrAlpha=2.0/(AtrPeriod+1.0); //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnInit() { SetIndexBuffer(0,REG,INDICATOR_DATA); SetIndexBuffer(1,SUP,INDICATOR_DATA); SetIndexBuffer(2,ATR,INDICATOR_DATA); PlotIndexSetInteger(0,PLOT_ARROW,158); PlotIndexSetInteger(1,PLOT_ARROW,158); return(0); } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { for(int i=(int)MathMax(prev_calculated-1,0); i up2) { wk[r][UP2] = h0;} if(l0 < dn2) { wk[r][DN2] = l0;} //+-------------------------------------------------+ //| expand //+-------------------------------------------------+ if(flg==-1.0 && c0>dn2+size2) { wk[r][FLG]=0.0; if(up-dn2>size4) { if(dn-dn2>size3 && dn>fmax(h0,c1)) { wk[r][UP]=dn; wk[r][UP2]=dn; } else { double y=h0; for(int j=0;jy) y=wk[r-j][H]; if(upsize2 && wk[r-j][H]size4) { if(up2-up>size3 && upy)break; if(up2-y>size2 && wk[r-j][L]>y+size2) { wk[r][DN]=y; wk[r][DN2]=y; break; } } } } wk[r][UP]=up2; } if(up-dn>(max0-min0)*2.0) { wk[r][UP]=max0; wk[r][UP2]=max0; wk[r][DN]=min0; wk[r][DN2]=min0; } if(h0>up+size1) { wk[r][FLG] = 1.0; } if(l0