XPMA CBA MTF TT.mq4
XPMA CBA MTF TT.mq4 FOREX MetaTrader4 Indicators Download
XPMA CBA MTF TT.mq4 download link will appear after 20 seconds.
XPMA CBA MTF TT.mq4 Programming source code.
//+------------------------------------------------------------------+ //| xpMA BDv15_02_13.mq4 | //+------------------------------------------------------------------+ #property description "XPMA = triple smoothed Moving Average." //CBA = Colored Bars + Alerts #property description " " #property description "Indicator is repainting in MTF-mode." //Индикатор НЕ перерисовывается в режиме MTF если RePaintMTF=false!!!" //"НЕ перерисовывается! в режиме MTF." #property description "AlertBar corrected for MTF-mode." //ARROWBAR и SIGNALBAR скорректированы для MTF." #property description " " //* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * " #property version "1.93" //из "1.11" //#property strict #property indicator_chart_window #property indicator_buffers 7 //--- #property indicator_color1 clrMediumSeaGreen //SlateGray //LightSteelBlue //clrPowderBlue //clrLightCyan //White //RoyalBlue #property indicator_color2 clrMediumVioletRed //DarkViolet //MediumOrchid //MediumPurple //Crimson //Red #property indicator_color3 clrMediumSeaGreen //SlateGray //LightSteelBlue //clrPowderBlue //clrLightCyan //White //RoyalBlue #property indicator_color4 clrMediumVioletRed //DarkViolet //MediumOrchid //clrOrchid //MediumPurple //Crimson //Red //--- #property indicator_color5 clrGold #property indicator_color6 clrLime //LimeGreen #property indicator_color7 clrMagenta //--- #property indicator_width1 3 #property indicator_width2 3 #property indicator_width3 0 #property indicator_width4 0 //--- #property indicator_width5 2 #property indicator_width6 2 #property indicator_width7 2 //--- #property indicator_style1 STYLE_SOLID #property indicator_style2 STYLE_SOLID #property indicator_style3 STYLE_SOLID #property indicator_style4 STYLE_SOLID //--- #property indicator_style5 STYLE_DASH #property indicator_style6 STYLE_DASH #property indicator_style7 STYLE_DASH //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ extern ENUM_TIMEFRAMES TimeFrame = PERIOD_CURRENT; extern int MAPeriod1 = 12; extern int MAPeriod2 = 12; extern int MAPeriod3 = 1; extern ENUM_MA_METHOD Mode1 = MODE_LWMA; extern ENUM_MA_METHOD Mode2 = MODE_LWMA; extern ENUM_APPLIED_PRICE Price1 = PRICE_CLOSE; //extern int Width = 2; extern bool ShowLine = true; extern bool ShowBars = true; extern int AlertBar = 1; //На каком Баре сигналить extern bool AlertsMessage = true, //false, AlertsSound = true, //false, AlertsEmail = false, AlertsMobile = false; extern string SoundFile = "alert2.wav"; //"news.wav"; //"stops.wav" //"expert.wav" //Звук сигнала (исполняемый файл) прописан здесь //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ double MDOPEN[], MDCLOSE[], MDLOW[], MDHIGH[]; int MAX, TFK; double XPMA[], DNColor[], UPColor[], Temp[]; datetime TimeBar=0; //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ int init() { TimeFrame = fmax(TimeFrame,_Period); TFK = TimeFrame/_Period; AlertBar *= TFK; //--- MAPeriod1 = fmax(MAPeriod1,1); MAPeriod2 = fmax(MAPeriod2*TFK,1*TFK); MAPeriod3 = fmax(MAPeriod3*TFK,1*TFK); MAX = MAPeriod1+MAPeriod2+MAPeriod3; //--- IndicatorBuffers(8); IndicatorDigits(Digits); //(Digits-Digits%2); //if (Digits%2==1) IndicatorDigits(Digits-1); //--- SetIndexBuffer(0,MDOPEN); SetIndexStyle(0,DRAW_HISTOGRAM); SetIndexLabel(0,stringMTF(TimeFrame)+": OPEN"); //StringSubstr(EnumToString(TimeFrame),7)+": SetIndexBuffer(1,MDCLOSE); SetIndexStyle(1,DRAW_HISTOGRAM); SetIndexLabel(1,"CLOSE"); //["+DoubleToStr(Percent,1)+"+"+(string)Plus+"]"); SetIndexBuffer(2,MDLOW); SetIndexStyle(2,DRAW_HISTOGRAM); SetIndexLabel(2,stringMTF(TimeFrame)+": LOW"); SetIndexBuffer(3,MDHIGH); SetIndexStyle(3,DRAW_HISTOGRAM); SetIndexLabel(3,"HIGH"); //["+DoubleToStr(Percent,1)+"+"+(string)Plus+"]"); //--- int LNT = ShowLine ? DRAW_LINE : DRAW_NONE; SetIndexBuffer(4,XPMA); SetIndexStyle(4,LNT /*,EMPTY,Width*/); SetIndexLabel(4,stringMTF(TimeFrame)+": XPMA ["+(string)MAPeriod1+">"+(string)MAPeriod2+">"+(string)MAPeriod3+"]"); //0,"XP Moving Average"); SetIndexBuffer(5,UPColor); SetIndexStyle(5,LNT /*,EMPTY,Width*/); SetIndexLabel(5,"ColorUP"); SetIndexBuffer(6,DNColor); SetIndexStyle(6,LNT /*,EMPTY,Width*/); SetIndexLabel(6,"ColorDN"); SetIndexBuffer(7,Temp); SetIndexStyle(7,DRAW_NONE); //--- IndicatorShortName(stringMTF(TimeFrame)+": XPMA TT ["+(string)MAPeriod1+">"+(string)MAPeriod2+">"+(string)MAPeriod3+"]"); //---//---// return(0); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ int deinit() { Comment(""); return(0); } //+------------------------------------------------------------------+ datetime dtmPrevTime; //--- bool blnNewBar(int TF) { if (dtmPrevTime==iTime(NULL,TF,0)) return(false); dtmPrevTime=iTime(NULL,TF,0); return(true); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ int start() { if (IsConnected()) { if (!blnNewBar(1)) return(0); } int CountedBars=IndicatorCounted(); if (CountedBars<0) return(-1); //Стандарт+Tankk+Вариант!!! if (CountedBars>0) CountedBars--; int limit=Bars-CountedBars-1; //fmin(Bars-CountedBars-1,Bars-2); //+MAX*10*TFK //Comment(limit); //------ for (int i=0; i<8; i++) { SetIndexEmptyValue(i,EMPTY_VALUE); //--- значение 0 отображаться не будет SetIndexDrawBegin(i,MAX*1); } //--- пропуск отрисовки первых баров //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ for (i=limit; i>=0; i--) //for (i=0; i<=limit; i++) // { int y = iBarShift(NULL,TimeFrame,Time[i],false); Temp[i]=EMPTY_VALUE; Temp[i] = iMA(NULL,TimeFrame,MAPeriod1,0,Mode1,Price1,y); } //--- for (i=limit; i>=0; i--) //for (i=0; i<=limit; i++) // { XPMA[i]=EMPTY_VALUE; XPMA[i] = iMAOnArray(Temp,0,MAPeriod2,0,Mode2,i); //-- double dMA=0; for (int k=i+1; k<=i+MAPeriod3; k++) dMA += XPMA[k]; dMA = dMA/MAPeriod3; //--- UPColor[i]=EMPTY_VALUE; DNColor[i]=EMPTY_VALUE; MDCLOSE[i]=EMPTY_VALUE; MDOPEN[i]=EMPTY_VALUE; MDHIGH[i]=EMPTY_VALUE; MDLOW[i]=EMPTY_VALUE; //--- if (XPMA[i] > dMA) { UPColor[i] = XPMA[i]; if (ShowBars) { MDLOW[i] = fmax(Low[i],High[i]); MDHIGH[i] = fmin(Low[i],High[i]); MDOPEN[i] = fmax(Open[i],Close[i]); MDCLOSE[i] = fmin(Open[i],Close[i]); } } if (XPMA[i] < dMA) { DNColor[i] = XPMA[i]; if (ShowBars) { MDLOW[i] = fmin(Low[i],High[i]); MDHIGH[i] = fmax(Low[i],High[i]); MDOPEN[i] = fmin(Open[i],Close[i]); MDCLOSE[i] = fmax(Open[i],Close[i]); } } } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ if (AlertsMessage || AlertsEmail || AlertsMobile || AlertsSound) { string messageUP = "XPMA CBA TT: "+_Symbol+", "+stringMTF(_Period)+" >> Signal UP >> BUY"; //BearsBulls Alerts MTF TT string messageDN = "XPMA CBA TT: "+_Symbol+", "+stringMTF(_Period)+" << Signal DN << SELL"; //BearsBulls Alerts MTF TT //--- if (TimeBar!=Time[0] && UPColor[AlertBar]!=EMPTY_VALUE && UPColor[1+AlertBar]==EMPTY_VALUE) { if (AlertsMessage) Alert(messageUP); if (AlertsEmail) SendMail(_Symbol,messageUP); if (AlertsMobile) SendNotification(messageUP); if (AlertsSound) PlaySound(SoundFile); //"stops.wav" //"news.wav" //звук сигнала на SELL TimeBar=Time[0]; //return(0); } //--- else if (TimeBar!=Time[0] && DNColor[AlertBar]!=EMPTY_VALUE && DNColor[1+AlertBar]==EMPTY_VALUE) { if (AlertsMessage) Alert(messageDN); if (AlertsEmail) SendMail(_Symbol,messageDN); if (AlertsMobile) SendNotification(messageDN); if (AlertsSound) PlaySound(SoundFile); //"stops.wav" //"news.wav" //звук сигнала на BUY TimeBar=Time[0]; //return(0); } } //---//---// return(0); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+ string stringMTF(int perMTF) { if (perMTF==0) perMTF=_Period; if (perMTF==1) return("M1"); if (perMTF==5) return("M5"); if (perMTF==15) return("M15"); if (perMTF==30) return("M30"); if (perMTF==60) return("H1"); if (perMTF==240) return("H4"); if (perMTF==1440) return("D1"); if (perMTF==10080) return("W1"); if (perMTF==43200) return("MN1"); if (perMTF== 2 || 3 || 4 || 6 || 7 || 8 || 9 || /// нестандартные периоды для грфиков Renko 10 || 11 || 12 || 13 || 14 || 16 || 17 || 18) return("M"+(string)_Period); //------ return("Period error!"); //("Ошибка периода"); } //+------------------------------------------------------------------+ //+------------------------------------------------------------------+