//+------------------------------------------------------------------+ //| Guppy Multiple Moving Averages.mq4 | //| Copyright 2015, Dmitriy Kudryashov. | //| https://www.mql5.com/ru/users/dlim0n4ik.dk | //+------------------------------------------------------------------+ //https://www.forex-tsd.com/forum/trading-systems/1811242-new-indicator #property copyright "Copyright 2015, Dmitriy Kudryashov." #property link "https://www.mql5.com/ru/users/dlim0n4ik.dk" #property version "1.00" #property description "============ " #property description " " #property description "upgrade MMcMA " #property description " " #property description " * poruchik * 11.01.17" #property strict #property indicator_chart_window #property indicator_buffers 11 #property indicator_plots 11 /* Версия 1.00 - Реализация индикатора по стратегии Дерила Гуппи (Daryl Guppy). Версия 2.00 - Реализовано переключение вида отображения ЛИНИИ или СТРЕЛКИ; - Добавлена возможность включение и выключение Main Moving Average. */ //--- plot fMA0 #property indicator_label1 "fMA0" #property indicator_type1 DRAW_LINE #property indicator_color1 clrLime #property indicator_style1 STYLE_SOLID #property indicator_width1 2 //--- plot fMA1 #property indicator_label2 "fMA1" #property indicator_type2 DRAW_LINE #property indicator_color2 clrAqua #property indicator_style2 STYLE_SOLID #property indicator_width2 2 //--- plot fMA2 #property indicator_label3 "fMA2" #property indicator_type3 DRAW_LINE #property indicator_color3 clrMagenta #property indicator_style3 STYLE_SOLID #property indicator_width3 2 //--- plot fMA3 #property indicator_label4 "fMA3" #property indicator_type4 DRAW_LINE #property indicator_color4 clrBlue #property indicator_style4 STYLE_SOLID #property indicator_width4 4 //--- plot fMA4 #property indicator_label5 "fMA4" #property indicator_type5 DRAW_LINE #property indicator_color5 clrDeepSkyBlue #property indicator_style5 STYLE_SOLID #property indicator_width5 2 //--- plot fMA5 #property indicator_label6 "fMA5" #property indicator_type6 DRAW_LINE #property indicator_color6 clrYellow #property indicator_style6 STYLE_SOLID #property indicator_width6 2 //--- plot sMA0 #property indicator_label7 "sMA0" #property indicator_type7 DRAW_LINE #property indicator_color7 clrRed #property indicator_style7 STYLE_SOLID #property indicator_width7 2 //--- plot sMA1 #property indicator_label8 "sMA1" #property indicator_type8 DRAW_LINE #property indicator_color8 clrWhite #property indicator_style8 STYLE_SOLID #property indicator_width8 2 ////// //--- plot sMA2 //--- plot BUY #property indicator_label9 "BUY" #property indicator_type9 DRAW_ARROW #property indicator_color9 clrRed #property indicator_style9 STYLE_SOLID #property indicator_width9 1 //--- plot SELL #property indicator_label10 "SELL" #property indicator_type10 DRAW_ARROW #property indicator_color10 clrBlue #property indicator_style10 STYLE_SOLID #property indicator_width10 1 enum ENUM_DISPLAY_STYLE {Line = 0, Arrow = 1}; input ENUM_DISPLAY_STYLE DiS = 0; input bool UseMainMA = false; //--- indicator buffers double fMA0Buffer[]; double fMA1Buffer[]; double fMA2Buffer[]; double fMA3Buffer[]; double fMA4Buffer[]; double fMA5Buffer[]; double sMA0Buffer[]; double sMA1Buffer[]; double mMABuffer[]; double BUYBuffer[]; double SELLBuffer[]; //--- Буферы напраления тренда Fast Moving Average bool fastTrendUP=FALSE; bool fastTrendDOWN=FALSE; //--- Буферы напраления тренда Slow Moving Average bool slowTrendUP=FALSE; bool slowTrendDOWN=FALSE; int Cont = 0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,fMA0Buffer); SetIndexBuffer(1,fMA1Buffer); SetIndexBuffer(2,fMA2Buffer); SetIndexBuffer(3,fMA3Buffer); SetIndexBuffer(4,fMA4Buffer); SetIndexBuffer(5,fMA5Buffer); SetIndexBuffer(6,sMA0Buffer); SetIndexBuffer(7,sMA1Buffer); SetIndexStyle(8, DRAW_ARROW, EMPTY); SetIndexArrow(8, SYMBOL_ARROWUP); SetIndexBuffer(8, BUYBuffer); SetIndexStyle(9, DRAW_ARROW, EMPTY); SetIndexArrow(9, SYMBOL_ARROWDOWN); SetIndexBuffer(9, SELLBuffer); //--- setting a code from the Wingdings charset as the property of PLOT_ARROW PlotIndexSetInteger(8,PLOT_ARROW,233); PlotIndexSetInteger(9,PLOT_ARROW,234); //--- 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; int limit=rates_total-prev_calculated; for(i=0; i fMA1 > fMA2 > fMA3 > fMA4 > fMA5) { fastTrendUP = TRUE; fastTrendDOWN = FALSE; } if(fMA0 < fMA1 < fMA2 < fMA3 < fMA4 < fMA5) { fastTrendUP = FALSE; fastTrendDOWN = TRUE; } //-------------------------------------------------------------------- //--- Условия определения тренда по Slow Moving Average -------------- if(sMA0 > sMA1 ) { slowTrendUP = TRUE; slowTrendDOWN = FALSE; } if(sMA0 < sMA1 ) { slowTrendUP = FALSE; slowTrendDOWN = TRUE; } //-------------------------------------------------------------------- if(fastTrendUP == TRUE && slowTrendUP == TRUE && Cont != 1) { SELLBuffer[i]=High[i]+(5*Point); //Стрелка ВВЕРХ Cont = 1; } else { if(fastTrendDOWN == TRUE && slowTrendDOWN == TRUE && Cont !=2) { BUYBuffer[i]=Low[i]-(5*Point); //Стрелка ВНИЗ Cont = 2; } } } } return(rates_total); } //+------------------------------------------------------------------+