【Gann_S9】找到潜在的趋势转折点
指标名称:Gann_S9版本:MT4 ver. 2.01
Gann_S9是基于改进型ZigZag的趋势分析工具,通过自动绘制支撑/阻力线和甘氏角度线,帮助交易者识别潜在的趋势转折点。指标包含以下主要功能:
[*]智能绘制ZigZag折线
[*]自动生成支撑/阻力位
[*]绘制甘氏角度线
[*]标记关键价格水平
1. 核心功能
[*]ZigZag折线:自动标记显著的高低点
[*]支撑/阻力线:蓝色:支撑位红色:阻力位
[*]角度线:以基准点为中心展开的扇形线
2. 参数调整建议
参数组推荐值效果说明
ZigZagDepth=21, Deviation=5平衡灵敏度和稳定性
角度线angle=22.5°, kol_lev=8显示8条不同角度线
样式Width=2, Style=0使用粗实线提高可视性
3. 交易信号解读
[*]趋势确认:当价格突破多条角度线时
[*]反转信号:ZigZag出现新折点 + 角度线群集
[*]支撑阻力:水平线密集区为关键价位
参数:部分代码展示:
[*]
//+------------------------------------------------------------------+//| Gann_S9.mq4 |//+------------------------------------------------------------------+//| Copyright © 2009-2024, www.QChaos.com |//| https://www.qchaos.com/ |//+------------------------------------------------------------------+#property copyright "Copyright © 量化混沌, www.qchaos.com"#property link "https://www.qchaos.com"#property version "2.01"#property strict#property indicator_chart_window#property indicator_buffers1#property indicator_color1 AliceBlue#property strict#property indicator_width1 0#property indicator_style1 2//----//---基本参数extern doubleangle_up = 22.5;// 上升角度基数(度)extern doubleangle_dn = 22.5;// 下降角度基数(度)extern int Width = 0; // 线宽extern int Style = 2; // 线型(0-实线,1-虚线等)extern int kol_lev = 8; // 角度线数量extern color ResistanceColor = Tomato;// 阻力颜色extern color SupportColor = DodgerBlue;// 支撑颜色
color 颜色;//---ZigZag参数extern int ExtDepth=21; // 折线深度(柱数)extern int ExtDeviation=5; // 最小偏差点数extern int ExtBackstep=3; // 回退步数//---其他参数extern color Level_0 = LightSteelBlue;// 基准线颜色extern bool lev_V = true;// 显示垂直线extern color Level_V = LightSteelBlue;// 垂直线颜色extern int Complect = 0; // 线组编号
//----//----double ZigZagBuffer[];int timeFirstBar=0;int flag;bool work=true;double vel_prev;//+------------------------------------------------------------------+//| ZigZag initialization function |//+------------------------------------------------------------------+int init(){//---- SetIndexBuffer(0,ZigZagBuffer); SetIndexStyle(0,DRAW_SECTION,2); SetIndexEmptyValue(0,0.0);
IndicatorShortName("ZigZag("+ExtDepth+","+ExtDeviation+","+ExtBackstep+")");//---- return(0);}//+------------------------------------------------------------------+//| deinit |//+------------------------------------------------------------------+int deinit(){//---- ObjDel(); Comment("");//---- return(0);}//+------------------------------------------------------------------+//|ZigZag iteration function |//+------------------------------------------------------------------+int start(){//----+ 检查柱数是否足够用于正确计算指标 if(Bars-1<ExtDepth) return(0);//----+ 为未计算柱引入整型内存变量 static int time2,time3,time4;//----+ 为未计算柱引入浮点型变量 staticdouble ZigZag2,ZigZag3,ZigZag4;//----+ 引入整型变量用于未计算柱并获取已计算柱 int MaxBar,limit,supr2_bar,supr3_bar,supr4_bar,counted_bars=IndicatorCounted();//---- 错误检查 if(counted_bars<0) return(-1);//---- 最后一个已计算柱需要重新计算 if(counted_bars>0) counted_bars--;
//----+ 变量声明 int index, shift, back,lasthighpos,lastlowpos; double val,res,TempBuffer; double curlow,curhigh,lasthigh,lastlow;
int metka=0; // =0 - 第一个ZZ转折前 =1 - 寻找最大值标记 =2 - 寻找最小值标记
//---- 定义最旧柱的编号 MaxBar=Bars-ExtDepth;//---- 定义循环起始柱编号 if(counted_bars==0 || Bars-counted_bars>2) { limit=MaxBar; } else { //---- supr2_bar=iBarShift(NULL,0,time2,TRUE); supr3_bar=iBarShift(NULL,0,time3,TRUE); supr4_bar=iBarShift(NULL,0,time4,TRUE); //---- limit=supr3_bar; if((supr2_bar<0)||(supr3_bar<0)||(supr4_bar<0)) { limit=MaxBar; } }
if(limit>=MaxBar || timeFirstBar!=Time) { timeFirstBar=Time; limit=MaxBar; }
if(limit==MaxBar) ArrayResize(TempBuffer,Bars); else ArrayResize(TempBuffer,limit+ExtBackstep+1);
//----+-------------------------------------------------+ for(shift=limit; shift>=0; shift--) { //--- Low val=Low; if(val==lastlow) val=0.0; else { lastlow=val; if((Low-val)>(ExtDeviation*Point)) val=0.0; else { for(back=1; back<=ExtBackstep; back++) { res=ZigZagBuffer; if((res!=0)&&(res>val)) ZigZagBuffer=0.0; } } } if(Low==val) { ZigZagBuffer=val; //if (ExtLabel==1) la=val; } else ZigZagBuffer=0.0;
//--- High val=High; if(val==lasthigh) val=0.0; else { lasthigh=val; if((val-High)>(ExtDeviation*Point)) val=0.0; else { for(back=1; back<=ExtBackstep; back++) { res=TempBuffer; if((res!=0)&&(res<val)) TempBuffer=0.0; } } } if(High==val) { TempBuffer=val; //if (ExtLabel==1) ha=val; } else TempBuffer=0.0; }// final cutting lasthigh=-1; lasthighpos=-1; lastlow= -1; lastlowpos= -1;//----+-------------------------------------------------+
for(shift=limit; shift>=0; shift--) { curlow=ZigZagBuffer; curhigh=TempBuffer; if((curlow==0)&&(curhigh==0)) continue; //--- if(curhigh!=0) { if(lasthigh>0) { if(lasthigh<curhigh) TempBuffer=0; else TempBuffer=0; } //--- if(lasthigh<curhigh || lasthigh<0) { lasthigh=curhigh; lasthighpos=shift; } lastlow=-1; } //---- if(curlow!=0) { if(lastlow>0) { if(lastlow>curlow) ZigZagBuffer=0; else ZigZagBuffer=0; } //--- if((curlow<lastlow)||(lastlow<0)) { lastlow=curlow; lastlowpos=shift; } lasthigh=-1; } }//----+-------------------------------------------------+ for(shift=limit; shift>=0; shift--) { res=TempBuffer; if(res!=0.0) ZigZagBuffer=res; }
int i=0,j=0; res=0; for(shift=0; i<3; shift++) { if(ZigZagBuffer>0) { i++; if(i==1 && ZigZagBuffer==High) { j=shift; res=ZigZagBuffer; } if(i==2 && res>0 && ZigZagBuffer==High) { if(ZigZagBuffer>=ZigZagBuffer) ZigZagBuffer=0; else ZigZagBuffer=0; res=0; i=0; j=0; shift=0; } } }
if(limit<MaxBar) { ZigZagBuffer=ZigZag2; ZigZagBuffer=ZigZag3; ZigZagBuffer=ZigZag4; for(int qqq=supr4_bar-1; qqq>supr3_bar; qqq--) ZigZagBuffer=0; for(int ggg=supr3_bar-1; ggg>supr2_bar; ggg--) ZigZagBuffer=0; }//+---+============================================+
double vel1, vel2, vel3, vel4; int bar1, bar2, bar3, bar4; int count; if(limit==MaxBar) supr4_bar=MaxBar; for(int bar=supr4_bar; bar>=0; bar--) { if(ZigZagBuffer!=0) { count++; vel4=vel3; bar4=bar3; vel3=vel2; bar3=bar2; vel2=vel1; bar2=bar1; vel1=ZigZagBuffer; bar1=bar; ObjDel(); if(count<3) continue; if((vel3<vel2)&&(vel2<vel1)) { ZigZagBuffer=0; bar=bar3+1; } if((vel3>vel2)&&(vel2>vel1)) { ZigZagBuffer=0; bar=bar3+1; } if((vel2==vel1)&&(vel1!=0)) { ZigZagBuffer=0; bar=bar3+1; } } }
time2=Time; time3=Time; time4=Time; ZigZag2=vel2; ZigZag3=vel3; ZigZag4=vel4;
这个和波浪尺有点相似,但这个还没那么好 不太懂,但谢谢分享,支持一下。 好复杂,看不懂,但谢谢分享
页:
[1]