//+------------------------------------------------------------------+ //| sCandle_row.mq5 | //| MVS 2019 | //| https://www.mql5.com/ru/users/mvs | //+------------------------------------------------------------------+ #property copyright "https://www.mql5.com/ru/users/mvs" #property copyright "MVS © 2019" #property version "1.00" #property indicator_separate_window #property indicator_buffers 2 #property indicator_plots 2 #property strict //--- plot #property indicator_label1 "U" #property indicator_type1 DRAW_HISTOGRAM #property indicator_color1 clrAqua #property indicator_style1 STYLE_SOLID #property indicator_width1 2 #property indicator_label2 "D" #property indicator_type2 DRAW_HISTOGRAM #property indicator_color2 clrRed #property indicator_style2 STYLE_SOLID #property indicator_width2 2 //--- input parameters input int Candles = 300; // Number of candles input int Size = 50; // Size candle input int ObjFs = 9; // Font size arrow input color tColor = clrTomato; // Color txt //--- indicator buffers double Buffer1[],Buffer2[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers SetIndexBuffer(0,Buffer1,INDICATOR_DATA); ArraySetAsSeries(Buffer1,true); SetIndexBuffer(1,Buffer2,INDICATOR_DATA); ArraySetAsSeries(Buffer2,true); IndicatorSetInteger(INDICATOR_DIGITS,0); IndicatorSetString(INDICATOR_SHORTNAME,"Candles:"); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- delete graphics ObjectsDeleteAll(0,"count_"); ChartRedraw(); //--- } //+------------------------------------------------------------------+ //| 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 res=0; int limit=rates_total-prev_calculated; if(limit==0) return(rates_total); //--- ArraySetAsSeries(high,true); ArraySetAsSeries(low,true); //--- double point=Point(); int Num = limit0; i--) { // -- if(high[i]-low[i]>Size*point) { res++; Buffer1[i]= 1.0; Buffer2[i]= 0.0; } else { Buffer2[i]= 1.0; Buffer1[i]= 0.0; } } Buffer1[0]= 0.0; Buffer2[0]= 0.0; CreateLabel("count_b","Больше критерия: "+string(res)+" свечей",tColor,15,30,CORNER_LEFT_LOWER,ObjFs); CreateLabel("count_s","Меньше критерия: "+(string)(Num-res)+" свечей",tColor,15,15,CORNER_LEFT_LOWER,ObjFs); //--- return value of prev_calculated for next call return(rates_total); } //+----------------------------------------------------------------------------+ void CreateLabel(string nm, string tx, color cl, int xd, int yd, int cr=0, int fs=8) { if(ObjectFind(0, nm)<0) { ObjectCreate(0, nm, OBJ_LABEL, 0, 0, 0); ObjectSetInteger(0, nm, OBJPROP_XDISTANCE, xd); ObjectSetInteger(0, nm, OBJPROP_YDISTANCE, yd); ObjectSetInteger(0, nm, OBJPROP_CORNER, cr); ObjectSetInteger(0, nm, OBJPROP_ANCHOR, ANCHOR_LEFT_LOWER); ObjectSetInteger(0, nm, OBJPROP_FONTSIZE, fs); ObjectSetInteger(0, nm, OBJPROP_BACK, false); ObjectSetInteger(0, nm, OBJPROP_HIDDEN, false); ObjectSetInteger(0, nm, OBJPROP_SELECTABLE, false); ObjectSetString (0, nm, OBJPROP_TEXT, tx); ObjectSetInteger(0, nm, OBJPROP_COLOR, cl); } } //+----------------------------------------------------------------------------+