论坛全局菜单下方 - TICKMILL 285X70论坛全局菜单下方 - ThinkMarkets285X70论坛全局菜单下方 - 荔枝返现285X70论坛全局菜单下方 -  icmarkets285X70
查看:952回复:2
草龙
注册时间2004-12-17
[MT4指标]Extrapolator指标
楼主发表于:2014-03-19 17:30只看该作者倒序浏览
1楼 电梯直达
电梯直达
主图指标 mt4指标类型:趋势指标 是否能用在mt4手机版上:否 是否含有未来函数:无 //+--------------------------------------------------------------------------------------+ //| Extrapolator.mq4 | //| Copyright ? 2008, gpwr | //| [email protected] | //+--------------------------------------------------------------------------------------+ #property copyright "Copyright ? 2008, gpwr" #property indicator_chart_window #property indicator_buffers 2 #property indicator_color1 Blue #property indicator_color2 Red #property indicator_width1 2 #property indicator_width2 2 //Global constants #define pi 3.141592653589793238462643383279502884197169399375105820974944592 //Input parameters extern int Method =1; //Extrapolation method extern int LastBar =30; //Last bar in the past data extern int PastBars =300; //Number of past bars extern double LPOrder =0.6; //Order of linear prediction model; 0 to 1 //LPOrder*PastBars specifies the number of prediction coefficients a[1..LPOrder*PastBars] where a[0]=1 extern int FutBars =100; //Number of bars to predict; for LP is set at PastBars-Order-1 extern int HarmNo =20; //Number of frequencies for Mathod 1; HarmNo=0 computes PastBars harmonics extern double FreqTOL =0.0001;//Tolerance of frequency calculation for Method 1 //FreqTOL > 0.001 may not converge extern int BurgWin =0; //Windowing function for Weighted Burg Method; 0=no window 1=Hamming 2=Parabolic //Indicator buffers double pv; double fv; //Global variables double ETA,INFTY,SMNO; int np,nf,lb,no,it; int init() { lb=LastBar; np=PastBars; no=LPOrder*PastBars; nf=FutBars; if(Method>1) nf=np-no-1; if(HarmNo==0) HarmNo=np; IndicatorBuffers(4); SetIndexBuffer(0,pv); SetIndexBuffer(1,fv); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2); SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2); SetIndexShift(0,-lb);//past data vector 0..np-1; 0 corresponds to bar=lb SetIndexShift(1,nf-lb);//future data vector i=0..nf; nf corresponds to bar=lb IndicatorShortName("Extrapolator"); return(0); } int deinit(){return(0);} int start() { ArrayInitialize(pv,EMPTY_VALUE); ArrayInitialize(fv,EMPTY_VALUE); //Find average of past values double av=0.0; for(int i=0;i=1;i--) a=a[i-1]; } //Calculate linear predictions if(Method>1) { for(int n=no;nFreqTOL) { a=b; z[1]=Open[1+lb]-pv[1]+a*z[0]; num=z[0]*z[1]; den=z[0]*z[0]; for(int i=2;i1) r=1.0; if(r<-1.0) r=-1.0; } else { for(i=k;i=k;i--) { tmp=df; df+=r*db[i-1]; db=db[i-1]+r*tmp; } } } //+-------------------------------------------------------------------------+ double win(int i, int k, int n, int w) { if(w==0) return(1.0); if(w==1) return(0.54-0.46*MathCos(pi*(2.0*(i-k)+1.0)/(n-k))); if(w==2) return(6.0*(i-k+1.0)*(n-i)/(n-k)/(n-k+1.0)/(n-k+2.0)); } //+-------------------------------------------------------------------------+ void HNBurg(double x, int p, double& a) { int n=ArraySize(x); double df,db; ArrayResize(df,n); ArrayResize(db,n); int i,k,kh,ki; double w,tmp,num,den,r; for(i=0;i1) r=1.0; if(r<-1.0) r=-1.0; } else { w=0.0; for(i=1;i=k;i--) { tmp=df; df+=r*db[i-1]; db=db[i-1]+r*tmp; } } } //+-------------------------------------------------------------------------+ void Geom(double x, int p, double& a) { int n=ArraySize(x); double df,db; ArrayResize(df,n); ArrayResize(db,n); int i,k,kh,ki; double tmp,num,denf,denb,r; for(i=0;i=k;i--) { tmp=df; df+=r*db[i-1]; db=db[i-1]+r*tmp; } } } //+-------------------------------------------------------------------------+ /* Modified Covariance method from Marple's book. It solves e[j]=y[j]+SUM(a*y[j-i-1],i=0...m-1), j=0..n-1 for a by the least-squares minimization of e[j] in both directions of j. The code substitues y[j] with x[n-1-j] because, in the provided data, x[0] is the latest data point. */ void MCov(double x, int ip, double& a, bool& stop) { //Initialization int n=ArraySize(x); double c,d,r,v; ArrayResize(c,ip+1); ArrayResize(d,ip+1); ArrayResize(r,ip); int k,m,mk; double r1,r2,r3,r4,r5,delta,gamma,lambda,theta,psi,xi; double save1,save2,save3,save4,c1,c2,c3,c4,ef,eb; r1=0.0; for(k=1;k0) { for(k=1;k<=m;k++) { theta+=x[k]*d[k]; psi+=x[k]*c[k]; xi+=x[n-1-k]*d[k]; r[k-1]-=(x[m]*x[m-k]+x[n-1-m]*x[n-1-m+k]); save1+=r[k-1]*a[m-k]; } } //order update of a c1=-save1/v; a[m]=c1; v*=(1.0-c1*c1); if(m>0) { for(k=0;k<(m+1)/2;k++) { mk=m-k-1; save1=a[k]; a[k]=save1+c1*a[mk]; if(k!=mk) a[mk]+=c1*save1; } } if(m==ip-1) { v*=(0.5/(n-1-m)); break; } //time update of c,d,gamma,delta, and lambda r1=1.0/(delta*gamma-lambda*lambda); c1=(theta*lambda+psi*delta)*r1; c2=(psi*lambda+theta*gamma)*r1; c3=(xi*lambda+theta*delta)*r1; c4=(theta*lambda+xi*gamma)*r1; for(k=0;k<=m/2;k++) { mk=m-k; save1=c[k]; save2=d[k]; save3=c[mk]; save4=d[mk]; c[k]+=(c1*save3+c2*save4); d[k]+=(c3*save3+c4*save4); if(k!=mk) { c[mk]+=(c1*save1+c2*save2); d[mk]+=(c3*save1+c4*save2); } } r2=psi*psi; r3=theta*theta; r4=xi*xi; r5=gamma-(r2*delta+r3*gamma+2.0*psi*lambda*theta)*r1; r2=delta-(r3*delta+r4*gamma+2.*theta*lambda*xi)*r1; gamma=r5; delta=r2; lambda+=(c3*psi+c4*theta); if(v<=0.0) { Print("Error: negative or zero variance in MCov"); stop=true; return; } if(delta<=0.0 || delta>1.0 || gamma<=0.0 || gamma>1.0) { Print("Error: delta and gamma are outside (0,1) in MCov"); stop=true; return; } //time update of a; order updates of c,d,gamma,delta, and lambda r1=1.0/v; r2=1.0/(delta*gamma-lambda*lambda); ef=x[n-m-2]; eb=x[m+1]; for(k=0;k<=m;k++) { ef+=a[k]*x[n-1-m+k]; eb+=a[k]*x[m-k]; } c1=eb*r1; c2=ef*r1; c3=(eb*delta+ef*lambda)*r2; c4=(ef*gamma+eb*lambda)*r2; for(k=m;k>=0;k--) { save1=a[k]; a[k]=save1+c3*c[k]+c4*d[k]; c[k+1]=c[k]+c1*save1; d[k+1]=d[k]+c2*save1; } c[0]=c1; d[0]=c2; r3=eb*eb; r4=ef*ef; v-=(r3*delta+r4*gamma+2.0*ef*eb*lambda)*r2; delta-=r4*r1; gamma-=r3*r1; lambda+=ef*eb*r1; if(v<=0.0) { Print("Error: negative or zero variance in MCov"); stop=true; return(0); } if(delta<=0.0 || delta>1.0 || gamma<=0.0 || gamma>1.0) { Print("Error: delta and gamma are outside (0,1) in MCov"); stop=true; return(0); } } //for(m=ip;m>=1;m--) a[m]=a[m-1]; //a[0]=1.0; } Extrapolator.jpgExtrapolator.jpg
TK29帖子1楼右侧xm竖版广告90-240
个性签名

阅尽天下指标
搬砖开始,始于2014

广告
TK30+TK31帖子一樓廣告
TK30+TK31帖子一樓廣告
Pzxzx
注册时间2017-08-06
zhapeng
注册时间2020-12-12
发表于:2021-01-08 00:39只看该作者
3楼
aaaaaaaaaaaaaaaaaa
个性签名

韬客社区www.talkfx.co

广告
论坛谏言--外汇交易不应是你投资的全部,交易外汇也不应是你生活的全部

本站免责声明:

1、本站所有广告及宣传信息均与韬客无关,如需投资请依法自行决定是否投资、斟酌资金安全及交易亏损风险;

2、韬客是独立的、仅为投资者提供交流的平台,网友发布信息不代表韬客的观点与意思表示,所有因网友发布的信息而造成的任何法律后果、风险与责任,均与韬客无关;

3、金融交易存在极高法律风险,未必适合所有投资者,请不要轻信任何高额投资收益的诱导而贸然投资;投资保证金交易导致的损失可能超过您投入的资金和预期。请您考虑自身的投资经验及风险承担能力,进行合法、理性投资;

4、所有投资者的交易帐户应仅限本人使用,不应交由第三方操作,对于任何接受第三方喊单、操盘、理财等操作的投资和交易,由此导致的任何风险、亏损及责任由投资者个人自行承担;

5、韬客不隶属于任何券商平台,亦不受任何第三方控制,韬客不邀约客户投资任何保证金交易,不接触亦不涉及投资者的任何资金及账户信息,不代理任何交易操盘行为,不向客户推荐任何券商平台,亦不存在其他任何推荐行为。投资者应自行选择券商平台,券商平台的任何行为均与韬客无关。投资者注册及使用韬客即表示其接受和认可上述声明,并自行承担法律风险。

版权所有:韬客外汇论坛 www.talkfx.com 联络我们:[email protected]