- //+------------------------------------------------------------------+//| ZIGFIBO_V5 .mq4 |//| Copyright © 2009-2024, www.QChaos.com |//| https://www.qchaos.com/ |//+------------------------------------------------------------------+#property indicator_chart_window#property indicator_buffers 1
- //------------------------------------------// 参数分组:指标计算设置//------------------------------------------extern string ______________0______________ = "指标计算所用柱数设置"; // 分组标题extern int nBArrowSize = 618; // 指标计算柱数
- extern string ______________1______________ = "ZigZag计算柱数设置"; // 分组标题extern int ZigZagBars = 6; // 普通周期ZigZag计算柱数
- //------------------------------------------// 参数分组:ZigZag图形设置//------------------------------------------extern string ______________2______________ = "M1周期ZigZag设置"; // 分组标题extern int ZigZagBarsM1 = 15; // M1周期专用值(其他周期用6)extern int LineZigZagWidth = 2; // ZigZag线宽度extern color LineZigZagColor = Blue; // ZigZag线颜色extern int ArrowSize = 2; // 箭头大小extern int LineWidth = 5; // 信号线宽度extern color LineColorSell = Magenta; // 卖出信号颜色extern color LineColorBuy = Green; // 买入信号颜色extern color LineColorStopLoss = Red; // 止损线颜色
- //------------------------------------------// 参数分组:斐波那契扩展设置//------------------------------------------extern string ______________3______________ = "斐波那契扩展参数"; // 分组标题extern color ExtFiboExpansionColor = Olive; // 斐波那契线颜色extern int ExtExpansionStyle = 2; // 斐波那契线型(0-4)extern int ExtExpansionWidth = 0; // 斐波那契线宽extern bool FiboExp = true; // 启用斐波那契扩展extern bool ShowArrow = true; // 显示交易箭头extern bool ShowHLine = true; // 显示水平线
- //------------------------------------------// 参数分组:监控面板设置//------------------------------------------extern string ______________4______________ = "监控面板参数"; // 分组标题extern color Clock_Color = DarkBlue; // 信息显示颜色extern string Corner_Placement = "1为右上角 3为右下角"; // 位置说明extern int Corner = 1; // 面板位置(1/3)extern int FontSize = 10; // 字体大小extern int XDISTANCE = 30; // 水平偏移量extern int YDISTANCE = 30; // 垂直偏移量string objname = "Spread&Bar"; // 对象名称
- //------------------------------------------// 参数分组:音叉线设置//------------------------------------------extern string ______________5______________ = "音叉线参数"; // 分组标题extern bool Pitchwork1 = true; // 启用音叉线类型1extern bool Pitchwork2 = true; // 启用音叉线类型2extern int PitchWorkstyle = 2; // 音叉线1样式extern int PitchWorksWIDTH = 1; // 音叉线1宽度extern color clrPitchWorkBuy = Green; // 买入音叉颜色extern color clrPitchWorkSell = Red; // 卖出音叉颜色extern int PitchWorkstyle2 = 1; // 音叉线2样式extern int PitchWorksWIDTH2 = 2; // 音叉线2宽度extern color clrPitchWorkBuy2 = Green; // 买入音叉2颜色extern color clrPitchWorkSell2 = Red; // 卖出音叉2颜色
- //------------------------------------------// 参数分组:趋势线设置//------------------------------------------extern string ______________6______________ = "支撑阻力线参数"; // 分组标题extern bool TreandLines1 = true; // 启用趋势线1extern int TreandLinesStyle1 = 3; // 趋势线1样式extern int TreandLines1WIDTH = 3; // 趋势线1宽度extern color TreandLines1clr = clrTeal; // 趋势线1颜色extern bool TreandLines2 = true; // 启用趋势线2extern int TreandLinesStyle2 = 3; // 趋势线2样式extern int TreandLines2WIDTH = 3; // 趋势线2宽度extern color TreandLines2clr = clrPurple; // 趋势线2颜色
- //+------------------------------------------------------------------+// 全局变量声明double SetArrowUp[],SetArrowDn[],EMB[];int shift;//+------------------------------------------------------------------+//+------------------------------------------------------------------+int init() { SetIndexStyle(0,1,DRAW_SECTION,LineZigZagWidth,LineZigZagColor); SetIndexBuffer(0,EMB); SetIndexEmptyValue(0,0.0);//---- ObjectCreate(objname, OBJ_LABEL, 0, 0, 0); ObjectSet(objname, OBJPROP_CORNER, Corner); ObjectSet(objname, OBJPROP_XDISTANCE, XDISTANCE); ObjectSet(objname, OBJPROP_YDISTANCE, YDISTANCE);//---- return(0); }//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+int deinit() { ObjectDelete("Buy"); ObjectDelete("Sell"); ObjectDelete("Buy Line"); ObjectDelete("Sell Line"); ObjectDelete("StopLoss Buy"); ObjectDelete("StopLoss Sell"); ObjectDelete("Fibo1"); ObjectDelete("Fibo2"); ObjectDelete("PitchWorksBuy"); ObjectDelete("PitchWorksSell"); ObjectDelete("PitchWorksBuy2"); ObjectDelete("PitchWorksSell2"); ObjectDelete("TreandLines1"); ObjectDelete("TreandLines2"); ObjectDelete(objname); Comment(""); return(0); }//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+int start() { if(Period()==1) ZigZagBars = ZigZagBarsM1; int WF,SW,ND,i,ZZU,ZZD,PP,T1,T2,T3,T4,T5; double LL,HH,BeHigh,BeLow; double UNIT[10000][3];
- double vbid = MarketInfo(Symbol(), MODE_BID); double vask = MarketInfo(Symbol(), MODE_ASK); double vpoint = MarketInfo(Symbol(), MODE_POINT); int vdigits = (int)MarketInfo(Symbol(),MODE_DIGITS); int vspread = (int)MarketInfo(Symbol(),MODE_SPREAD); int koeff;
- if(vdigits==0) koeff = 1; if(vdigits==1) koeff = 10; if(vdigits==2) koeff = 100; if(vdigits==3) koeff = 1000; if(vdigits==4) koeff = 10000; if(vdigits==5) koeff = 100000; if(vdigits==6) koeff = 1000000;
- SW = 0; WF = 0; ND = 0; BeHigh = High [nBArrowSize]; BeLow = Low [nBArrowSize]; ZZU = nBArrowSize; ZZD = nBArrowSize;
- //Time to bar expiry int m,s;
- m=Time[0]+Period()*60-CurTime(); s=m%60; m=(m-s)/60;
- string _sp="",_m="",_s=""; if(vspread<10) _sp=".."; else if(vspread<100) _sp="."; if(m<10) _m="0"; if(s<10) _s="0";
- for(shift=nBArrowSize; shift>=0; shift--) { LL = 100000; HH = -100000; for(i=shift+ZigZagBars; i>=shift+1; i--) { if(Low< LL) { LL=Low; }; if(High>HH) { HH=High; }; }; if(Low[shift]<LL && High[shift]>HH) { WF=2; if(SW==1) { ZZU=shift+1; }; if(SW==-1) { ZZD=shift+1; }; } else { if(Low[shift]<LL) { WF=-1; }; if(High[shift]>HH) { WF=1; }; }; if(WF!=SW && SW!=0) { if(WF==2) { WF=-SW; BeHigh = High[shift]; BeLow = Low[shift]; }; ND=ND+1; if(WF==1) { UNIT[ND][1]=ZZD; UNIT[ND][2]=BeLow; }; if(WF==-1) { UNIT[ND][1]=ZZU; UNIT[ND][2]=BeHigh; }; BeHigh = High[shift]; BeLow = Low[shift]; }; if(WF==1) { if(High[shift]>=BeHigh) { BeHigh=High[shift]; ZZU=shift; }; }; if(WF==-1) { if(Low[shift]<=BeLow) { BeLow=Low[shift]; ZZD=shift; }; }; SW=WF; };
- for(i=1; i<=ND; i++) { PP = StrToInteger(DoubleToStr(UNIT [1],0)); T1 = StrToInteger(DoubleToStr(UNIT [1],0)); T2 = StrToInteger(DoubleToStr(UNIT[i-1] [1],0)); T3 = StrToInteger(DoubleToStr(UNIT[i-2] [1],0)); T4 = StrToInteger(DoubleToStr(UNIT[i-3] [1],0)); T5 = StrToInteger(DoubleToStr(UNIT[i-4] [1],0));
- EMB[PP] = UNIT[2];
- double s1 = UNIT[i ][2]; double s2 = UNIT[i-1][2]; double s3 = UNIT[i-2][2]; double s4 = UNIT[i-3][2]; double s5 = UNIT[i-4][2]; double dif100 = MathAbs(s1-s2)*100; double difPoints = MathAbs(s1-s2); double proc14 = dif100*0.146; double proc76 = dif100*0.764; double dif14 = difPoints*0.146; double dif76 = difPoints*0.764; double STLoss; double TMedPrice = 0.0; int TBarPrice = 0; };
- if(TreandLines1) { ObjectCreate(0,"TreandLines1",OBJ_TREND,0,Time[T3],s3,Time[T1],s1); ObjectSetInteger(0,"TreandLines1",OBJPROP_COLOR,TreandLines1clr); ObjectSetInteger(0,"TreandLines1",OBJPROP_STYLE,TreandLinesStyle1); ObjectSetInteger(0,"TreandLines1",OBJPROP_WIDTH,TreandLines1WIDTH); ObjectSetInteger(0,"TreandLines1",OBJPROP_BACK,true); ObjectSetInteger(0,"TreandLines1",OBJPROP_RAY_RIGHT,true); };
- if(TreandLines2) { ObjectCreate(0,"TreandLines2",OBJ_TREND,0,Time[T4],s4,Time[T2],s2); ObjectSetInteger(0,"TreandLines2",OBJPROP_COLOR,TreandLines2clr); ObjectSetInteger(0,"TreandLines2",OBJPROP_STYLE,TreandLinesStyle2); ObjectSetInteger(0,"TreandLines2",OBJPROP_WIDTH,TreandLines2WIDTH); ObjectSetInteger(0,"TreandLines2",OBJPROP_BACK,true); ObjectSetInteger(0,"TreandLines2",OBJPROP_RAY_RIGHT,true); };
- for(shift=0; shift<nBArrowSize; shift++) { if(s1<s2) {
- if(ShowArrow) SetArrow(225, LineColorBuy, "Buy", Time[T1-3], BeLow, ArrowSize); if(ShowHLine) SetHLine(LineColorBuy, "Buy Line", BeLow, 0, LineWidth); if(ShowHLine) SetHLine(LineColorStopLoss, "StopLoss Buy", s1, 0, LineWidth);
- ObjectDelete("Sell Line"); ObjectDelete("Sell"); ObjectDelete("StopLoss Sell");
- STLoss = MathAbs(s1-BeLow)*koeff; TMedPrice = NormalizeDouble(s3+(MathAbs(s2-s3)*0.5),Digits); TBarPrice = ((T3-T2)*0.5)+T2;
- //Comment ( " TMedPrice = ", TMedPrice, " \n", // " T2 = ", T2, " \n", // " T3 = ", T3, " \n", // " TBarPrice = ", TBarPrice , " \n" //);
- if(Pitchwork1) { ObjectCreate(0,"PitchWorksBuy",OBJ_PITCHFORK,0,Time[TBarPrice],TMedPrice,Time[T1],s1,Time[T2],s2); ObjectSetInteger(0,"PitchWorksBuy",OBJPROP_COLOR,clrPitchWorkBuy); ObjectSetInteger(0,"PitchWorksBuy",OBJPROP_WIDTH,PitchWorksWIDTH); ObjectSetInteger(0,"PitchWorksBuy",OBJPROP_STYLE,PitchWorkstyle); };
复制代码