//+------------------------------------------------------------------+ //| candle_pattern.mq5 | //| candle_pattern 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_chart_window #property indicator_type1 DRAW_COLOR_CANDLES #property indicator_color1 clrDodgerBlue,clrRed #property indicator_width1 1 //+------------------------------------------------------------------+ //--- input parameters input double InpScaleRate = 1.0; input int InpEMAPeriod=12; //EMA Period double EmaAlpha=2.0/(InpEMAPeriod+1.0); double AtrAlpha=0.98; //---- will be used as indicator buffers double ATR[]; double EMA[]; 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[]; double BALANCE[]; double SIZE[]; double BODY[]; CMyCandle MyCandle; CMyCandlePattern MyCandlePattern; //---- 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++,BODY,INDICATOR_DATA); SetIndexBuffer(i++,BALANCE,INDICATOR_DATA); SetIndexBuffer(i++,SIZE,INDICATOR_DATA); SetIndexBuffer(i++,BAR,INDICATOR_CALCULATIONS); SetIndexBuffer(i++,ATR,INDICATOR_CALCULATIONS); SetIndexBuffer(i++,EMA,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(InpScaleRate); MyCandlePattern.Init(InpScaleRate); //--- //--- 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=o)?0:1; }