//+------------------------------------------------------------------+ //| MR_v1_01.mq5 | //| mean reversion v1.01 Copyright 2016, fxborg | //| http://fxborg-labo.hateblo.jp/ | //+------------------------------------------------------------------+ #property copyright "Copyright 2016, fxborg" #property link "http://fxborg-labo.hateblo.jp/" #property version "1.01" #property indicator_chart_window #property indicator_buffers 6 #property indicator_plots 6 #property indicator_type1 DRAW_ARROW #property indicator_color1 clrDeepPink #property indicator_width1 2 #property indicator_type2 DRAW_ARROW #property indicator_color2 clrAqua #property indicator_width2 2 #property indicator_type3 DRAW_LINE #property indicator_color3 Goldenrod #property indicator_width3 2 #property indicator_type4 DRAW_LINE #property indicator_color4 Goldenrod #property indicator_width4 2 #property indicator_type5 DRAW_LINE #property indicator_color5 clrRed #property indicator_width5 2 #property indicator_type6 DRAW_LINE #property indicator_color6 clrRed #property indicator_width6 2 //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ input int InpPeriod1=50; // Z-Score Period(Inner) input int InpPeriod2=250; // Z-Score Period(Outer) input double InpLevel1=2.0; // Level(Inner) input double InpLevel2=2.5; // Level(Outer) input int MaxMinSize=20; double UP[]; double DN[]; double BB1H[]; double BB1L[]; double BB2H[]; double BB2L[]; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ int OnInit() { SetIndexBuffer(0,UP,INDICATOR_DATA); SetIndexBuffer(1,DN,INDICATOR_DATA); SetIndexBuffer(2,BB1H,INDICATOR_DATA); SetIndexBuffer(3,BB1L,INDICATOR_DATA); SetIndexBuffer(4,BB2H,INDICATOR_DATA); SetIndexBuffer(5,BB2L,INDICATOR_DATA); PlotIndexSetInteger(0,PLOT_ARROW,218); PlotIndexSetInteger(1,PLOT_ARROW,217); PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,-20); PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,20); 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); iclose[i] && hi>close[i])UP[i]=high[i]; else UP[i]=EMPTY_VALUE; if(BB1L[i]>close[i] &&BB2L[i]