麦语言的编程思维实在转不过来,请老师帮我改下 [文华财经]
- 咨询内容:
for (i = Bars; i >= 0; i--) { TrendUp[i] = EMPTY_VALUE; TrendDown[i] = EMPTY_VALUE; atr = iATR(NULL, 0, Nbr_Periods, i); medianPrice = (High[i]+Low[i])/2; up[i]=medianPrice+(Multiplier*atr); dn[i]=medianPrice-(Multiplier*atr); trend[i]=1; if (Close[i]>up[i+1]) { trend[i]=1; if (trend[i+1] == -1) changeOfTrend = 1; } else if (Close[i]<dn[i+1]) { trend[i]=-1; if (trend[i+1] == 1) changeOfTrend = 1; } else if (trend[i+1]==1) { trend[i]=1; changeOfTrend = 0; } else if (trend[i+1]==-1) { trend[i]=-1; changeOfTrend = 0; }
if (trend[i]<0 && trend[i+1]>0) { flag=1; } else { flag=0; } if (trend[i]>0 && trend[i+1]<0) { flagh=1; } else { flagh=0; } if (trend[i]>0 && dn[i]<dn[i+1]) dn[i]=dn[i+1]; if (trend[i]<0 && up[i]>up[i+1]) up[i]=up[i+1]; if (flag==1) up[i]=medianPrice+(Multiplier*atr); if (flagh==1) dn[i]=medianPrice-(Multiplier*atr); //-- Draw the indicator if (trend[i]==1) { TrendUp[i]=dn[i]; if (changeOfTrend == 1) { TrendUp[i+1] = TrendDown[i+1]; changeOfTrend = 0; } } else if (trend[i]==-1) { TrendDown[i]=up[i]; if (changeOfTrend == 1) { TrendDown[i+1] = TrendUp[i+1]; changeOfTrend = 0; } } }然后在主图上画出TrendDown, TrendUp两条线 - 文华技术人员:
查看了一下您的源码,代码是不完整的,缺少变量Multiplier定义部分。
您的公式是MT4指标吧。请提供下完整源码,以便我们为您修改。
- 文华客服:
这个不影响就一个变量
double TrendUp[], TrendDown[];int changeOfTrend;extern int Nbr_Periods = 10;extern double Multiplier = 2;int init() {//---- indicators SetIndexBuffer(0, TrendUp); SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 3); SetIndexLabel(0, "Trend Up"); SetIndexBuffer(1, TrendDown); SetIndexStyle(1, DRAW_LINE, STYLE_SOLID, 3); SetIndexLabel(1, "Trend Down");//---- return(0); }
int start() { int limit, i, flag, flagh, trend[5000]; double up[5000], dn[5000], medianPrice, atr; int counted_bars = IndicatorCounted();//---- check for possible errors if(counted_bars < 0) return(-1);//---- last counted bar will be recounted if(counted_bars > 0) counted_bars--; limit=Bars-counted_bars;for (i = Bars; i >= 0; i--) { TrendUp[i] = EMPTY_VALUE; TrendDown[i] = EMPTY_VALUE; atr = iATR(NULL, 0, Nbr_Periods, i); medianPrice = (High[i]+Low[i])/2; up[i]=medianPrice+(Multiplier*atr); dn[i]=medianPrice-(Multiplier*atr); trend[i]=1; if (Close[i]>up[i+1]) { trend[i]=1; if (trend[i+1] == -1) changeOfTrend = 1; } else if (Close[i]<dn[i+1]) { trend[i]=-1; if (trend[i+1] == 1) changeOfTrend = 1; } else if (trend[i+1]==1) { trend[i]=1; changeOfTrend = 0; } else if (trend[i+1]==-1) { trend[i]=-1; changeOfTrend = 0; }
if (trend[i]<0 && trend[i+1]>0) { flag=1; } else { flag=0; } if (trend[i]>0 && trend[i+1]<0) { flagh=1; } else { flagh=0; } if (trend[i]>0 && dn[i]<dn[i+1]) dn[i]=dn[i+1]; if (trend[i]<0 && up[i]>up[i+1]) up[i]=up[i+1]; if (flag==1) up[i]=medianPrice+(Multiplier*atr); if (flagh==1) dn[i]=medianPrice-(Multiplier*atr); //-- Draw the indicator if (trend[i]==1) { TrendUp[i]=dn[i]; if (changeOfTrend == 1) { TrendUp[i+1] = TrendDown[i+1]; changeOfTrend = 0; } } else if (trend[i]==-1) { TrendDown[i]=up[i]; if (changeOfTrend == 1) { TrendDown[i+1] = TrendUp[i+1]; changeOfTrend = 0; } } }然后在主图上画出TrendDown, TrendUp两条线
- 网友回复:
我们研究一下,MT4改写需要一些时间。改写好后会第一时间为您回复。
- 网友回复: 老师,您好,我的程序改好没有?
有思路,想编写各种指标公式,程序化交易模型,选股公式,预警公式的朋友
可联系技术人员 QQ: 511411198 进行 有偿 编写!(不贵!点击查看价格!)
相关文章
-
没有相关内容