Fan v1-3 AA MTF TT.mq4
Fan v1-3 AA MTF TT.mq4 FOREX MetaTrader4 Indicators Download
Fan v1-3 AA MTF TT.mq4 download link will appear after 20 seconds.
Fan v1-3 AA MTF TT.mq4 Programming source code.
#property indicator_separate_window #property indicator_buffers 6 //------ #property indicator_color1 clrLime #property indicator_color2 clrGreen #property indicator_color3 clrYellow #property indicator_color4 clrDarkOrange #property indicator_color5 clrSlateBlue #property indicator_color6 clrOrchid //Magenta //Red //------ //#property indicator_width1 2 //#property indicator_width2 2 //#property indicator_width3 2 //#property indicator_width4 2 #property indicator_width5 0 #property indicator_width6 0 //------ #property indicator_style1 STYLE_DOT #property indicator_style2 STYLE_DASH #property indicator_style3 STYLE_DOT #property indicator_style4 STYLE_DASH #property indicator_style5 STYLE_DOT #property indicator_style6 STYLE_SOLID //------ //#property indicator_level1 0 //#property indicator_level2 -100 //#property indicator_level3 100 #property indicator_levelcolor clrDarkSlateGray //SlateBlue //Silver // #property indicator_levelwidth 0 #property indicator_levelstyle STYLE_DOT //-------------------------------------------------------------------- //-------------------------------------------------------------------- enum showAR { HideArrows, INSIDE, CENTER, OUTSIDE }; //enum showAR { aDoNotCALC, HideArrows, aOnCHART, aOnINDIK }; enum showCD { HideThis, DOTS, LINE, HISTO }; //-------------------------------------------------------------------- //-------------------------------------------------------------------- extern int History = 4567; //288=D1/M5 //576=D2/M5; //864=D3/M5; //1152=D4/M5; //1440=D5/M5; extern ENUM_TIMEFRAMES TimeFrame = PERIOD_CURRENT; extern int Period1 = 1; extern int Period2 = 5; //25; extern int Period3 = 10; //50; extern int Period4 = 15; //75; extern int Period5 = 20; //100; extern int Period6 = 25; //150; extern int Period7 = 30; //200; extern ENUM_MA_METHOD MAMode = MODE_LWMA; //MODE_SMMA; extern ENUM_APPLIED_PRICE MAPrice = PRICE_CLOSE; extern int FilterLevel = 45; extern showAR ShowArrows = OUTSIDE; //IN extern int ARROWBAR = 0; //На каком баре рисовать Стрелку: =0 - рисовать на текущем (до закрытия - может исчезнуть) extern int ArrGap = 3; //Дистанция от High/Low свечи extern color ColorBUY = clrLimeGreen, //LightCyan, //White, //Aqua, // //DarkTurquoise, //FireBrick, //Aqua, // ColorSEL = clrDarkOrange; //Magenta; //Red; //Gold; // //HotPink; //SlateBlue; //DodgerBlue; //Lavender; //Gold; // extern int CodeBUY = 233, CodeSEL = 234, ArrSize = 1; extern string SoundFile = "alert2.wav"; //"expert.wav"; //"stops.wav" //"alert2.wav" //"news.wav"; // extern int SIGNALBAR = 1; extern bool AlertsMessage = true, //false, AlertsSound = true, //false, AlertsEmail = false, AlertsMobile = false; extern showCD ShowIndex = LINE; //HISTO; //DOTS; //LINE; // extern int Size = 2; extern int DotCode = 159; //167; // //-------------------------------------------------------------------- //-------------------------------------------------------------------- double Buffer1[], Buffer2[]; double Buffer3[], Buffer4[], Buffer5[]; double DeltaFan[], trend[], FLAG[]; int MAX, ARB, SGB; string PREF; datetime TimeBar=0; //-------------------------------------------------------------------- //-------------------------------------------------------------------- int init() { TimeFrame = fmax(TimeFrame,_Period); //TFK = TimeFrame/_Period; //if (TimeFrame!=0) TimeFrame = nextTF(TimeFrame); //--- Period1 = fmax(Period1,1); Period2 = fmax(Period2,1); Period3 = fmax(Period3,1); Period4 = fmax(Period4,1); Period5 = fmax(Period5,1); Period6 = fmax(Period6,1); Period7 = fmax(Period7,1); MAX = Period1 + fmax(fmax(Period2,Period3),fmax(fmax(Period4,Period5),fmax(Period6,Period7))); ARB = ARROWBAR*TimeFrame/_Period; SGB = SIGNALBAR*TimeFrame/_Period; //------ //------ IndicatorBuffers(8); IndicatorDigits(0); //Digits); if (Digits==3 || Digits==5) IndicatorDigits(Digits-1); //------ 8 распределенных буфера индикатора //enum showCD { HideThis, DOTS, LINE, HISTO }; int HST = (ShowIndex==0) ? DRAW_NONE : (ShowIndex==1) ? DRAW_ARROW : (ShowIndex==2) ? DRAW_LINE : DRAW_HISTOGRAM; SetIndexBuffer(0,Buffer1); SetIndexStyle(0,HST,EMPTY,Size); SetIndexArrow(0,DotCode); SetIndexBuffer(1,Buffer2); SetIndexStyle(1,HST,EMPTY,Size); SetIndexArrow(1,DotCode); SetIndexBuffer(2,Buffer3); SetIndexStyle(2,HST,EMPTY,Size); SetIndexArrow(2,DotCode); SetIndexBuffer(3,Buffer4); SetIndexStyle(3,HST,EMPTY,Size); SetIndexArrow(3,DotCode); int LNT = (ShowIndex==1) ? DRAW_LINE : DRAW_NONE; SetIndexBuffer(4,DeltaFan); SetIndexStyle(4,LNT); //--- SetIndexBuffer(5,Buffer5); SetIndexStyle(5,DRAW_LINE); //------ 3 дополнительных буфера индикатора, используются для подсчета SetIndexBuffer(6,trend); SetIndexStyle(6,DRAW_NONE); SetIndexBuffer(7,FLAG); SetIndexStyle(7,DRAW_NONE); //------ настройка параметров отрисовки уровней SetLevelValue(0,0); SetLevelValue(1,FilterLevel); SetLevelValue(2,-FilterLevel); //------ отображение в DataWindow SetIndexLabel(0,stringMTF(TimeFrame)+": Веер раскрыт/расширяется"); //fan opened and expanded SetIndexLabel(1,stringMTF(TimeFrame)+": Веер раскрыт/сужается"); //fan discovered and narrows SetIndexLabel(2,stringMTF(TimeFrame)+": Веер переплетен/расширяется"); //fan intertwined and expanding SetIndexLabel(3,stringMTF(TimeFrame)+": Веер переплетен/сужается"); //fan binding and shrinking SetIndexLabel(4,stringMTF(TimeFrame)+": Дельта МА6 - МА1"); //ma6-ma1 delta SetIndexLabel(5,stringMTF(TimeFrame)+": Взвешенное изменение цены"); //weighted price change //------ "короткое имя" для DataWindow и подокна индикатора + и/или "уникальное имя индикатора" ///WindowExpertName()+ IndicatorShortName("[C--] "+ stringMTF(TimeFrame)+": Fan v1 MTF TT ["+(string)Period1+"-"+(string)Period2+"-"+(string)Period3+"-"+(string)Period4+"-"+(string)Period5+"-"+(string)Period6+"-"+(string)Period7+"] "); //--- PREF = stringMTF(TimeFrame)+": Fan'TT ["+(string)Period1+"-"+(string)Period2+"-"+(string)Period3+"-"+(string)Period4+"-"+(string)Period5+"-"+(string)Period6+"-"+(string)Period7+"] "; //-------------------------------------------------------------------- //-------------------------------------------------------------------- //------ return(0); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- ///void OnDeinit(const int reason) { ObjectsDeleteAll(0,PREF,-1,-1); } int deinit() { ALL_OBJ_DELETE(); Comment(""); return(0); } //+++======================================================================+++ void ALL_OBJ_DELETE() { string name; for (int s=ObjectsTotal()-1; s>=0; s--) { name=ObjectName(s); if (StringSubstr(name,0,StringLen(PREF))==PREF) ObjectDelete(name); } } //+++======================================================================+++ datetime LastBarOpenTime=0; //------ bool NewBarTF(int period) { datetime BarOpenTime=iTime(NULL,period,0); if (BarOpenTime!=LastBarOpenTime) { LastBarOpenTime=BarOpenTime; return (true); } else return (false); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- int start() { double DeltaMA1, DeltaMA2, DeltaMA3, DeltaMA4, DeltaMA5, DeltaMA6; double Ma1, Ma2, Ma3, Ma4, Ma5, Ma6, Ma7, DL; //, DeltaFan; //--- int i, y, CountedBars=IndicatorCounted(); if (CountedBars<0) return(-1); //Стандарт+Tankk-Вариант!!! if (CountedBars>0) CountedBars--; int limit=fmin(Bars-CountedBars,Bars-2); //+MAX*10*TFK if (History>MAX) { limit=fmin(History+MAX,Bars-2); ALL_OBJ_DELETE(); } //limit+=MAX; Comment(limit); //--- for (i=0; i<8; i++) { SetIndexEmptyValue(i,0.0); //--- значение 0 отображаться не будет if (History>MAX) SetIndexDrawBegin(i,Bars-History); //--- пропуск отрисовки первых баров if (History<=MAX) SetIndexDrawBegin(i,MAX*1); } //--- пропуск отрисовки первых баров //------------------------------------------------------------------ //------------------------------------------------------------------ for (i=limit; i>=0; i--) //for (i=0; iMa3 && Ma3>Ma4 && Ma4>Ma5 && Ma5>Ma6 && Ma6>Ma7) || (Ma2 DL && DeltaFan[i] > 0) || (DeltaFan[i] < DL && DeltaFan[i] < 0) ) trend[i] = 888; //Buffer1[i] = DeltaFan[i]; else trend[i] = -888; //Buffer2[i] = DeltaFan[i]; } //--- else { if ( (DeltaFan[i] > DL && DeltaFan[i] > 0) || (DeltaFan[i] < DL && DeltaFan[i] < 0) ) trend[i] = 444; //Buffer3[i] = DeltaFan[i]; else trend[i] = -444; //Buffer4[i] = DeltaFan[i]; } //--- //--- int FB = (ShowIndex==2) ? 1 : 0; //фальш-бар для фальшивой раскраски ;-)) //--- if (trend[i] == 888) { Buffer1[i]=DeltaFan[i]; if (trend[i+FB]<0 || trend[i+FB]== 444) { Buffer2[i]=0; Buffer3[i]=0; Buffer4[i]=0; Buffer1[i+FB]=DeltaFan[i+FB]; } } if (trend[i] == -888) { Buffer2[i]=DeltaFan[i]; if (trend[i+FB]>0 || trend[i+FB]== -444) { Buffer1[i]=0; Buffer3[i]=0; Buffer4[i]=0; Buffer2[i+FB]=DeltaFan[i+FB]; } } //--- if (trend[i] == 444) { Buffer3[i]=DeltaFan[i]; if (trend[i+FB]<0 || trend[i+FB]== 888) { Buffer1[i]=0; Buffer2[i]=0; Buffer4[i]=0; Buffer3[i+FB]=DeltaFan[i+FB]; } } if (trend[i] == -444) { Buffer4[i]=DeltaFan[i]; if (trend[i+FB]>0 || trend[i+FB]== -888) { Buffer1[i]=0; Buffer2[i]=0; Buffer3[i]=0; Buffer4[i+FB]=DeltaFan[i+FB]; } } //--- //--- if (Buffer5[i+ARB] > DeltaFan[i+ARB] && Buffer5[i+1+ARB] <= DeltaFan[i+1+ARB] && DeltaFan[i+1+ARB] <= -FilterLevel) { FLAG[i] = 888; DrawARROW(i, false, "ArrUP'"); } if (Buffer5[i+ARB] < DeltaFan[i+ARB] && Buffer5[i+1+ARB] >= DeltaFan[i+1+ARB] && DeltaFan[i+1+ARB] >= FilterLevel) { FLAG[i] = -888; DrawARROW(i, true, "ArrDN'"); } //------------------------------------------------------------------ } //*конец цикла* for (i=0; i > "+_Symbol+", "+stringMTF(_Period)+" >> Arrow UP >> BUY"; string messageDN = WindowExpertName()+" << "+_Symbol+", "+stringMTF(_Period)+" << Arrow DN << SELL"; //------ if (TimeBar!=Time[0] && FLAG[SGB] > 0) { if (AlertsMessage) Alert(messageUP); if (AlertsEmail) SendMail(_Symbol,messageUP); if (AlertsMobile) SendNotification(messageUP); if (AlertsSound) PlaySound(SoundFile); //"stops.wav" //"news.wav" TimeBar=Time[0]; } //return(0); //------ else if (TimeBar!=Time[0] && FLAG[SGB] < 0) { if (AlertsMessage) Alert(messageDN); if (AlertsEmail) SendMail(_Symbol,messageDN); if (AlertsMobile) SendNotification(messageDN); if (AlertsSound) PlaySound(SoundFile); //"stops.wav" //"news.wav" TimeBar=Time[0]; } //return(0); } ///*конец* АЛЕРТОВ для всех..... //------------------------------------------------------------------ //------------------------------------------------------------------ //------ return(0); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- bool DrawARROW(int i, bool DOWN, string Name) //, int ARRCOD, int ARRSIZE) ///, double gap, color ARRCOLOR) { if (ShowArrows==0) return(false); //------ //int DGTS = Digits; if (Digits==3 || Digits==5) DGTS-=1; string objName = PREF+Name+(string)i; //TimeToStr(Time[i],TIME_MINUTES)+"_"+DoubleToStr(Close[i],DGTS); //double Gap = 2.0*iATR(NULL,0,20,z)/4.0; double gap=ArrGap*_Point; if (Digits==3 || Digits==5) gap*=10; //--- // имя для Стрелки if (!ObjectCreate(0,objName,OBJ_ARROW, 0, Time[i], 0)) return(false); //--- // создать стрелку по заданным координатам //ObjectSetInteger(0,objName,OBJPROP_ARROWCODE, ARRCOD); // код стрелки //ObjectSetInteger(0,objName,OBJPROP_ANCHOR, ANCHOR_CENTER); // угол привязки стрелки //ObjectSetInteger(0,objName,OBJPROP_COLOR, ARRCOLOR); // цвет стрелки ObjectSetInteger(0,objName,OBJPROP_STYLE, STYLE_SOLID); // стиль окаймляющей линии ObjectSetInteger(0,objName,OBJPROP_WIDTH, ArrSize); // размер стрелки ObjectSetInteger(0,objName,OBJPROP_BACK, false); // на заднем плане ObjectSetInteger(0,objName,OBJPROP_SELECTABLE, false); // объект можно выделять ObjectSetInteger(0,objName,OBJPROP_SELECTED, false); // выделить для перемещений ObjectSetInteger(0,objName,OBJPROP_HIDDEN, true); // скрыт в списке объектов ObjectSetInteger(0,objName,OBJPROP_ZORDER, 0); // приоритет на нажатие мышью //------ enum showAR { HideArrows, aINSIDE, aCENTER, aOUTSIDE }; double HIGH=High[i]+gap; if (ShowArrows==2) HIGH=(High[i]+Low[i])/2; if (ShowArrows==1) HIGH=Low[i] -gap; double LOW =Low[i] -gap; if (ShowArrows==2) LOW =(High[i]+Low[i])/2; if (ShowArrows==1) LOW =High[i]+gap; //------ if (DOWN) { ObjectSetDouble(0,objName,OBJPROP_PRICE1, HIGH); ObjectSetInteger(0,objName,OBJPROP_ARROWCODE, CodeSEL); ObjectSetInteger(0,objName,OBJPROP_ANCHOR, ANCHOR_BOTTOM); ObjectSetInteger(0,objName,OBJPROP_COLOR, ColorSEL); ObjectSetText(objName, "setup for SELL", 10, "Verdana", clrRed); } //------ if (!DOWN) { ObjectSetDouble(0,objName,OBJPROP_PRICE1, LOW); ObjectSetInteger(0,objName,OBJPROP_ARROWCODE, CodeBUY); ObjectSetInteger(0,objName,OBJPROP_ANCHOR, ANCHOR_TOP); ObjectSetInteger(0,objName,OBJPROP_COLOR, ColorBUY); ObjectSetText(objName, "setup for BUY", 10, "Verdana", clrWhite); } //------ return(true); } //-------------------------------------------------------------------- //-------------------------------------------------------------------- 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!"); } //------------------------------------------------------------------ //------------------------------------------------------------------ int nextTF(int per) { if (per > 43200) return(0); if (per > 10080) return(43200); if (per > 1440) return(10080); if (per > 240) return(1440); if (per > 60) return(240); if (per > 30) return(60); if (per > 15) return(30); if (per > 5) return(15); if (per > 1) return(5); //--- return(0); } //================================================================== //==================================================================