//+------------------------------------------------------------------+ //| Insid_Outside_Bar.mq5 | //| Copyright 2018, MetaQuotes Software Corp. | //| https://www.mql5.com/ru/users/s22aa | //+------------------------------------------------------------------+ #property copyright "Copyright 2018, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 2 #property indicator_type1 DRAW_ARROW #property indicator_type2 DRAW_ARROW #property indicator_color1 clrRed #property indicator_color2 clrBlue #property indicator_width1 2 #property indicator_width2 2 //--- input parameters input int ArrowShift=0; // Отступ точек от свечи, по высоте. //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ enum Indicator { Insid=0,// Insid_Bar Outside=1, // Outside_Bar Insid3=2, // Матрёшка Insid4=3, // Матрёшка+ Insid5=4 // Матрёшка++ }; input Indicator Insid_Outside_Bar=Insid; double BuffUp[]; double BuffDn[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { SetIndexBuffer(0,BuffUp,INDICATOR_DATA); SetIndexBuffer(1,BuffDn,INDICATOR_DATA); IndicatorSetString(INDICATOR_SHORTNAME,"Insid_Bar2"); IndicatorSetInteger(INDICATOR_DIGITS,_Digits); PlotIndexSetInteger(0,PLOT_ARROW,159); PlotIndexSetInteger(1,PLOT_ARROW,159); PlotIndexSetInteger(0,PLOT_ARROW_SHIFT,ArrowShift); PlotIndexSetInteger(1,PLOT_ARROW_SHIFT,-ArrowShift); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,EMPTY_VALUE); return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ 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[]) { int i,ii,limit; if(rates_total<3) return(0); if(prev_calculated<4) { limit=3; } else limit=rates_total-3; for(i=limit; i=low[i-1]) { ii=i-1; BuffUp[ii]=high[ii]; BuffDn[ii]=low[ii]; Comment("BuffUp: ",BuffUp[i],"\n", "BuffDn: ",BuffDn[i]); } break; case Outside: if(high[i]>=high[i-1] && low[i]<=low[i-1]) { BuffUp[i]=high[i]; BuffDn[i]=low[i]; Comment("BuffUp: ",BuffUp[i],"\n", "BuffDn: ",BuffDn[i]); } break; case Insid3: if(high[i]<=high[i-1] && high[i-1]<=high[i-2] && low[i]>=low[i-1] && low[i-1]>=low[i-2]) { ii=i-2; BuffUp[ii]=high[ii]; BuffDn[ii]=low[ii]; Comment("BuffUp: ",BuffUp[i],"\n", "BuffDn: ",BuffDn[i]); } break; case Insid4: if(high[i-1]<=high[i-2] && high[i]<=high[i-2] && low[i-1]>=low[i-2] && low[i]>=low[i-2]) { ii=i-2; BuffUp[ii]=high[ii]; BuffDn[ii]=low[ii]; Comment("BuffUp: ",BuffUp[i],"\n", "BuffDn: ",BuffDn[i]); } break; case Insid5: if(high[i]<=high[i-2] && high[i]<=high[i-1] && low[i]>=low[i-2] && low[i]>=low[i-2]) { ii=i-2; BuffUp[ii]=high[ii]; BuffDn[ii]=low[ii]; Comment("BuffUp: ",BuffUp[i],"\n", "BuffDn: ",BuffDn[i]); } } return(rates_total); } //+------------------------------------------------------------------+