本文主要是介绍MT4软件---江恩理论指标斐波那契扇形划线顶底公式源码,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
想要找一些外汇MT4的指标,附有源码,交易的时候可以辅助,编写指标的时候可以参考学习,想改善的时候,可以编辑。
江恩理论认为股票、期货等金融投资市场,也存在着宇宙中的自然规则,市场的价格运行趋势不是杂乱的,而是可通过数学方法预测的。它的实质就是在看似无序的市场中建立了严格的交易秩序,可以用来发现何时价格会发生回调和将回调到什么价位。
斐波那契扇形线可以为你提供支撑位和阻力位以及时间因数,找到回撤位和突破位,还可以预测到未来行情的移动趋势,同时也能把多个分析系统的技术功能全部实现。但是,斐波那契扇形线能够绘制一系列带角度的趋势线而不是平行的“阶梯线”。
在使用中需要注意的是,斐波那契扇形线不能应用于小周期。因为在小周期图表中,测试出来的准确度较差,最好使用1天,周,月以上的周期图形来进行测量。
根据江恩,价格变动发生在可预测的几何周期中。通过这种价格行为产生的角度作为价格图表上的支撑或阻力。建议在15分钟或以上周期使用,效果会更好。
45 度倾斜的趋势是可持续的,而且会持续更长时间。
做多:
价格收于45度上方;价格收于菲波纳奇扇形61.8水平线上方
做空:
价格收于45度下方;价格收于菲波纳奇扇形61.8水平线下方
江恩理论斐波那契扇形划线顶底指标源码
下方分享的技术指标为副图分析公式源码,适用于MT4软件,是根据常见的方式改写。仅作为策略思路拓展,不建议直接用于货币兑、黄金、原油等外汇投资实盘中(投资有风险,入市须谨慎)。
交易员可以根据艾云策略所提供的指标源码,结合平时的交易经验进行改编,形成自己的交易策略。
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 AliceBlue
#property indicator_width1 0
#property indicator_style1 2
//----
extern double angle_up = 22.5;
extern double angle_dn = 22.5;
extern int Width = 0;
extern int Style = 2;
extern int kol_lev = 8;
extern color ResistanceColor = Tomato;
extern color SupportColor = DodgerBlue;
extern color Level_0 = LightSteelBlue;
extern bool lev_V = true;
extern color Level_V = LightSteelBlue;
extern int Complect = 0;
color öâåò_óðîâíÿ;
extern int ExtDepth=21;
extern int ExtDeviation=5;
extern int ExtBackstep=3;
//----
//----
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;
//----+ Ââåäåíèå ïåðåìåííûõ ñ ïëàâàþùåé òî÷êîé äëÿ ïåðåñ÷¸òà èíäèêàòîðà òîëüêî íà íåïîäñ÷èòàííûõ áàðàõ
static double 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[1];
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[Bars-1])
{timeFirstBar=Time[Bars-1];limit=MaxBar; }
//----
//---- èçìåíåíèå ðàçìåðà âðåìåííîãî áóôåðà
if (limit==MaxBar) ArrayResize(TempBuffer,Bars); else ArrayResize(TempBuffer,limit+ExtBackstep+1);
//----±------------------------------------------------+
//----+ íà÷àëî ïåðâîãî áîëüøîãî öèêëà
for(shift=limit; shift>=0; shift–)
{//--- Lowval=Low[Lowest(NULL,0,MODE_LOW,ExtDepth,shift)];if(val==lastlow) val=0.0;else { lastlow=val; if((Low[shift]-val)>(ExtDeviation*Point)) val=0.0;else{for(back=1; back<=ExtBackstep; back++){res=ZigZagBuffer[shift+back];if((res!=0)&&(res>val)) ZigZagBuffer[shift+back]=0.0; }}}if (Low[shift]==val){ZigZagBuffer[shift]=val; //if (ExtLabel==1) la[shift]=val;}else ZigZagBuffer[shift]=0.0;//--- Highval=High[Highest(NULL,0,MODE_HIGH,ExtDepth,shift)];if(val==lasthigh) val=0.0;else {lasthigh=val;if((val-High[shift])>(ExtDeviation*Point)) val=0.0;else{for(back=1; back<=ExtBackstep; back++){res=TempBuffer[shift+back]; if((res!=0)&&(res<val)) TempBuffer[shift+back]=0.0; } }}if (High[shift]==val){TempBuffer[shift]=val; //if (ExtLabel==1) ha[shift]=val;}else TempBuffer[shift]=0.0;}
//----+ êîíåö ïåðâîãî áîëüøîãî öèêëà
// final cutting
lasthigh=-1; lasthighpos=-1;lastlow= -1; lastlowpos= -1;
//----±------------------------------------------------+
//----+ íà÷àëî âòîðîãî áîëüøîãî öèêëà
for(shift=limit; shift>=0; shift–)
{curlow=ZigZagBuffer[shift];curhigh=TempBuffer[shift];if((curlow==0)&&(curhigh==0)) continue;//---if(curhigh!=0){if(lasthigh>0) {if(lasthigh<curhigh) TempBuffer[lasthighpos]=0;else TempBuffer[shift]=0;}//---if(lasthigh<curhigh || lasthigh<0){lasthigh=curhigh;lasthighpos=shift;}lastlow=-1;}//----if(curlow!=0){if(lastlow>0){if(lastlow>curlow) ZigZagBuffer[lastlowpos]=0;else ZigZagBuffer[shift]=0;}//---if((curlow<lastlow)||(lastlow<0)){lastlow=curlow;lastlowpos=shift;} lasthigh=-1;}}
//----+ êîíåö âòîðîãî áîëüøîãî öèêëà
//----±------------------------------------------------+
//----+ íà÷àëî òðåòüåãî öèêëà
for(shift=limit; shift>=0; shift–)
{res=TempBuffer[shift];if(res!=0.0) ZigZagBuffer[shift]=res;}//----+ êîíåö òðåòüåãî öèêëà
// Ïðîâåðêà ïåðâîãî ëó÷à
int i=0,j=0;
res=0;
for (shift=0;i<3;shift++)
{if (ZigZagBuffer[shift]>0){i++;if (i==1 && ZigZagBuffer[shift]==High[shift]){j=shift;res=ZigZagBuffer[shift];}if (i==2 && res>0 && ZigZagBuffer[shift]==High[shift]){if (ZigZagBuffer[shift]>=ZigZagBuffer[j]) ZigZagBuffer[j]=0; else ZigZagBuffer[shift]=0;res=0;i=0;j=0;shift=0;}}}
//±-- Âîññòàíîâëåíèå çíà÷åíèé èíäèêàòîðíîãî áóôôåðà, êîòîðûå ìîãëè áûòü óòåðÿíû
if (limit<MaxBar)
{ZigZagBuffer[supr2_bar]=ZigZag2; ZigZagBuffer[supr3_bar]=ZigZag3; ZigZagBuffer[supr4_bar]=ZigZag4; for(int qqq=supr4_bar-1; qqq>supr3_bar; qqq--)ZigZagBuffer[qqq]=0; for(int ggg=supr3_bar-1; ggg>supr2_bar; ggg--)ZigZagBuffer[ggg]=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[bar]!=0){count++;vel4=vel3;bar4=bar3;vel3=vel2;bar3=bar2;vel2=vel1;bar2=bar1;vel1=ZigZagBuffer[bar];bar1=bar;ObjDel();if (count<3)continue; if ((vel3<vel2)&&(vel2<vel1)){ZigZagBuffer[bar2]=0;bar=bar3+1;}if ((vel3>vel2)&&(vel2>vel1)){ZigZagBuffer[bar2]=0;bar=bar3+1;}if ((vel2==vel1)&&(vel1!=0 )){ZigZagBuffer[bar1]=0;bar=bar3+1;}}}
//±-- çàïîìèíàíèå âðåìåíè òð¸õ ïîñëåäíèõ ïåðåãèáîâ Çèãçàãà è çíà÷åíèé èíäèêàòîðà â ýòèõ òî÷êàõ
time2=Time[bar2];
time3=Time[bar3];
time4=Time[bar4];
ZigZag2=vel2;
ZigZag3=vel3;
ZigZag4=vel4;
if(bar1>=2)
{
if(Low[bar1]==vel1)
{
flag=1;
for(i = 1; i <= kol_lev; i++ )
{
PlotLine(“lev “+bar1+””+Complect+“_”+i,vel1,bar1,bar1,0,angle_up*i, flag);
}
}
else
{
flag=-1;
for(i = 1; i <= kol_lev; i++ )
{
PlotLine(“lev “+bar1+””+Complect+“_”+i,vel1,bar1,bar1,0,angle_dn*i, flag);
}
}
PlotLineM(“lev “+bar1+””+Complect+“_”,vel1,bar1,bar1,0,flag);
}
//±–
if(Low[bar2]==vel2)
{
flag=1;
for(i = 1; i <= kol_lev; i++ )
{
PlotLine(“lev “+bar2+””+Complect+“_”+i,vel2,bar2,bar1,1,angle_up*i, flag);
}
}
else
{
flag=-1;
for(i = 1; i <= kol_lev; i++ )
{
PlotLine(“lev “+bar2+””+Complect+“_”+i,vel2,bar2,bar1,1,angle_dn*i, flag);
}
}
PlotLineM(“lev “+bar2+””+Complect+“_”,vel2,bar2,bar1,1,flag);
//±–
if(Low[bar3]==vel3)
{
flag=1;
for(i = 1; i <= kol_lev; i++ )
{
PlotLine(“lev “+bar3+””+Complect+“_”+i,vel3,bar3,bar2,1,angle_up*i, flag);
}
}
else
{
flag=-1;
for(i = 1; i <= kol_lev; i++ )
{
PlotLine(“lev “+bar3+””+Complect+“_”+i,vel3,bar3,bar2,1,angle_dn*i, flag);
}
}
PlotLineM(“lev “+bar3+””+Complect+“_”,vel3,bar3,bar2,1,flag);
//±–
if(Low[bar4]==vel4)
{
flag=1;
for(i = 1; i <= kol_lev; i++ )
{
PlotLine(“lev “+bar4+””+Complect+“_”+i,vel4,bar4,bar3,1,angle_up*i, flag);
}
}
else
{
flag=-1;
for(i = 1; i <= kol_lev; i++ )
{
PlotLine(“lev “+bar4+””+Complect+“_”+i,vel4,bar4,bar3,1,angle_dn*i, flag);
}
}
PlotLineM(“lev “+bar4+””+Complect+“_”,vel4,bar4,bar3,1,flag);
return(0);
}
//—+ ±--------------------------------------------------------------------+
void PlotLineM(string name,double Price1,int Date1,int Date2,int lev0,int âåðõ_âíèç)
{
int D2;
double P1;
if(lev0==1)D2=Time[Date2];elseD2=Time[0]+50*Period()*60;ObjectDelete(name+" 0");ObjectCreate(name+" 0",OBJ_TREND,0,Time[Date1],Price1,D2,Price1); ObjectSet(name+" 0",OBJPROP_COLOR,Level_0);ObjectSet(name+" 0",OBJPROP_STYLE,0);ObjectSet(name+" 0",OBJPROP_WIDTH,1);ObjectSet(name+" 0",OBJPROP_RAY,false);
//—+
if(âåðõ_âíèç==1)P1=Price1-2*Point;else if(âåðõ_âíèç==-1)P1=Price1+4*Point;ObjectDelete(name+" 0txt");ObjectCreate(name+" 0txt", OBJ_TEXT, 0, Time[Date1], P1);ObjectSetText(name+" 0txt", DoubleToStr(Price1,Digits), 8, "Tahoma",Level_0);
//—+
if(lev_V)
{ObjectDelete(name+" V");ObjectCreate(name+" V",OBJ_VLINE,0,Time[Date1],0); ObjectSet(name+" V",OBJPROP_COLOR,Level_V);ObjectSet(name+" V",OBJPROP_STYLE,2);ObjectSet(name+" V",OBJPROP_WIDTH,0);ObjectSet(name+" V",OBJPROP_BACK,true);}
//—+
}
//—+ ±--------------------------------------------------------------------+
void PlotLine(string name,double Price1,int Date1,int Date2,int lev0,double gr,int âåðõ_âíèç)
{
double level,points;
int D2,nBar;
if(Digits5 || Digits3)
points=Point*10;
else
points=Point;
if(âåðõ_âíèç==1){level=MathSqrt(Price1/points)+gr/180;level=MathPow(level,2)*points;öâåò_óðîâíÿ=SupportColor;}elseif(âåðõ_âíèç==-1){level=MathSqrt(Price1/points)-gr/180;level=MathPow(level,2)*points;öâåò_óðîâíÿ=ResistanceColor;} if(lev0==1)D2=Time[Date2];elseD2=Time[0]+50*Period()*60; ObjectDelete(name);ObjectCreate(name,OBJ_TREND,0,Time[Date1],level,D2,level); ObjectSet(name,OBJPROP_COLOR,öâåò_óðîâíÿ);ObjectSet(name,OBJPROP_STYLE,Style);ObjectSet(name,OBJPROP_WIDTH,Width);ObjectSet(name,OBJPROP_RAY,false);
//—
ObjectDelete(name+" txt");
if(lev0==1)
{
nBar=Date1-8;
ObjectCreate(name+" txt", OBJ_TEXT, 0, Time[nBar], level);
}
else
{
ObjectCreate(name+" txt", OBJ_TEXT, 0, Time[0]+8*Period()*60, level);
}
ObjectSetText(name+" txt", DoubleToStr(gr,1)+"° "+DoubleToStr(level,Digits), 8, “Tahoma”,öâåò_óðîâíÿ);
//—
}
//---------------------------------------------------------
void ObjDel()
{
for ( int i = ObjectsTotal() - 1; i >= 0; i – )
{
if ( StringFind( ObjectName(i), “_”, 0 ) == 0 )
{
ObjectDelete( ObjectName(i) );
}
}
}
这篇关于MT4软件---江恩理论指标斐波那契扇形划线顶底公式源码的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!