//+------------------------------------------------------------------+ //| long_candles.mq5 | //| long_candles Copyright 2016, fxborg | //| http://fxborg-labo.hateblo.jp/ | //+------------------------------------------------------------------+ #include #property copyright "Copyright 2016, fxborg" #property link "http://fxborg-labo.hateblo.jp/" #property version "1.05" #property indicator_buffers 28 #property indicator_plots 21 #property indicator_separate_window #property indicator_minimum 0 #property indicator_maximum 100 #property indicator_type1 DRAW_COLOR_CANDLES #property indicator_color1 clrDodgerBlue,clrRed #property indicator_width1 1 //+------------------------------------------------------------------+ //--- input parameters input double InpBodyS = 0.33; input double InpBodyM = 0.75; input double InpBodyL = 1.5; input double InpBodyXL = 3; input double InpHigeS = 0.1; input double InpHigeM = 0.2; input double InpHigeL = 0.3; input double InpHigeXL = 0.6; double AtrAlpha=0.99; //---- will be used as indicator buffers double ATR[]; double BAR[]; double LWC[]; // long wite candle double LBC[]; // long black candle double LWC2[]; // long wite candle double LBC2[]; // long black candle static const double EV = EMPTY_VALUE; double OPEN[]; double HIGH[]; double LOW[]; double CLOSE[]; double COLOR[]; CMyCandle MyCandle; //---- declaration of global variables int min_rates_total=5; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //---- Initialization of variables of data calculation starting point //--- indicator buffers int i=0; SetIndexBuffer(i++,OPEN,INDICATOR_DATA); SetIndexBuffer(i++,HIGH,INDICATOR_DATA); SetIndexBuffer(i++,LOW,INDICATOR_DATA); SetIndexBuffer(i++,CLOSE,INDICATOR_DATA); SetIndexBuffer(i++,COLOR,INDICATOR_COLOR_INDEX); SetIndexBuffer(i++,BAR,INDICATOR_CALCULATIONS); SetIndexBuffer(i++,ATR,INDICATOR_CALCULATIONS); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetDouble(3,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetDouble(4,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetDouble(5,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetDouble(6,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetDouble(7,PLOT_EMPTY_VALUE,EMPTY_VALUE); //--- MyCandle.Init(InpBodyS,InpBodyM,InpBodyL,InpBodyXL,InpHigeS,InpHigeM,InpHigeL,InpHigeXL); //--- //--- 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 first; if(rates_total<=min_rates_total) return(0); //--- //+----------------------------------------------------+ //|Set Median Buffeer | //+----------------------------------------------------+ int begin_pos=min_rates_total; first=begin_pos; if(first