//+------------------------------------------------------------------+ //| Elder_Impulse_System.mq5 | //| Copyright 2018, MetaQuotes Software Corp. | //| https://mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2018, MetaQuotes Software Corp." #property link "https://mql5.com" #property version "1.00" #property description "Elder Impulse System indicator" #property indicator_separate_window #property indicator_buffers 5 #property indicator_plots 3 //--- plot UP #property indicator_label1 "EIS Up" #property indicator_type1 DRAW_ARROW #property indicator_color1 clrGreen #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- plot DN #property indicator_label2 "EIS Down" #property indicator_type2 DRAW_ARROW #property indicator_color2 clrRed #property indicator_style2 STYLE_SOLID #property indicator_width2 1 //--- plot NL #property indicator_label3 "EIS Neutral" #property indicator_type3 DRAW_ARROW #property indicator_color3 clrDarkGray #property indicator_style3 STYLE_SOLID #property indicator_width3 1 //--- input parameters input uint InpPeriodEMA = 13; // EMA period input uint InpPeriodFast = 12; // MACD fast EMA period input uint InpPeriodSlow = 26; // MACD slow EMA period //--- defines #define COUNT (3) //--- indicator buffers double BufferUP[]; double BufferDN[]; double BufferNL[]; double BufferEMA[]; double BufferMACD[]; //--- global variables string prefix; int wnd; int period_ema; int period_fma; int period_sma; int period_max; int handle_ema; int handle_macd; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- set global variables prefix=MQLInfoString(MQL_PROGRAM_NAME)+"_"; wnd=ChartWindowFind(); period_fma=int(InpPeriodFast<1 ? 1 : InpPeriodFast); period_sma=int(InpPeriodSlow==period_fma ? period_fma+1 : InpPeriodSlow<1 ? 1 : InpPeriodSlow); period_ema=int(InpPeriodEMA<1 ? 1 : InpPeriodEMA); period_max=fmax(period_ema,fmax(period_fma,period_sma)); //--- SizeByScale(); Descriptions(); //--- indicator buffers mapping SetIndexBuffer(0,BufferUP,INDICATOR_DATA); SetIndexBuffer(1,BufferDN,INDICATOR_DATA); SetIndexBuffer(2,BufferNL,INDICATOR_DATA); SetIndexBuffer(3,BufferEMA,INDICATOR_CALCULATIONS); SetIndexBuffer(4,BufferMACD,INDICATOR_CALCULATIONS); //--- setting a code from the Wingdings charset as the property of PLOT_ARROW for(int i=0; i1) { limit=rates_total-2; ArrayInitialize(BufferUP,EMPTY_VALUE); ArrayInitialize(BufferDN,EMPTY_VALUE); ArrayInitialize(BufferNL,EMPTY_VALUE); ArrayInitialize(BufferEMA,0); ArrayInitialize(BufferMACD,0); } //--- Подготовка данных int count=(limit>1 ? rates_total : 1),copied=0; copied=CopyBuffer(handle_ema,0,0,count,BufferEMA); if(copied!=count) return 0; copied=CopyBuffer(handle_macd,MAIN_LINE,0,count,BufferMACD); if(copied!=count) return 0; //--- Расчёт индикатора for(int i=limit; i>=0 && !IsStopped(); i--) { BufferNL[i]=0.5; BufferUP[i]=BufferDN[i]=EMPTY_VALUE; if(BufferEMA[i]>BufferEMA[i+1] && BufferMACD[i]>BufferMACD[i+1]) { BufferUP[i]=0.5; BufferNL[i]=EMPTY_VALUE; } else BufferUP[i]=EMPTY_VALUE; if(BufferEMA[i]