以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://222.73.7.161/bbs/index.asp) -- 公式模型编写问题提交 (http://222.73.7.161/bbs/list.asp?boardid=4) ---- 请帮忙看下我所改的问题出在哪里? (http://222.73.7.161/bbs/dispbbs.asp?boardid=4&id=161132) |
-- 作者:sanmu528 -- 发布时间:2018/1/18 1:02:17 -- 请帮忙看下我所改的问题出在哪里? INPUT:M0(1.5,1,10,1),N2(10,1,50,1); variable:trs:=0; variable:ups:=0; variable:dns:=0; variable:flag=1; variable:flagh=1; variable:changeOfTrs=1; variable:ColorBuffer=1; variable:SuperTrend=1; variable:Support1=1; variable:Resist1=1; variable:SUPERTREND下拐=1; variable:SUPERTREND上拐=1; //--- R001:KLINE(H,O,L,C,1); //--- TR1:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW)); ATR:=MA(TR1,NN); med:=(H+L)/2; ups:=med+atr*M0; dns:=med-atr*M0; trsr1:=ref(trs,1); trsr2:=ref(trs,2); SuperTrendr1:=ref(SuperTrend,1); SuperTrendr2:=ref(SuperTrend,2); upsr1:=ref(ups,1); dnsr1:=ref(dns,1); //--- IF c>upsr1 THEN BEGIN trs=1; IF trsr1=-1 THEN changeOfTrs=1; end else if c |
-- 作者:sanmu528 -- 发布时间:2018/1/18 1:06:02 -- INPUT:M0(1.5,1,10,1),N2(10,1,50,1); variable:trs:=0; variable:ups:=0; variable:dns:=0; variable:flag=1; variable:flagh=1; variable:changeOfTrs=1; variable:ColorBuffer=1; variable:SuperTrend=1; variable:Support1=1; variable:Resist1=1; variable:SUPERTREND下拐=1; variable:SUPERTREND上拐=1; //--- R001:KLINE(H,O,L,C,1); //--- TR1:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW)); ATR:=MA(TR1,NN); med:=(H+L)/2; ups:=med+atr*M0; dns:=med-atr*M0; trsr1:=ref(trs,1); trsr2:=ref(trs,2); SuperTrendr1:=ref(SuperTrend,1); SuperTrendr2:=ref(SuperTrend,2); upsr1:=ref(ups,1); dnsr1:=ref(dns,1); //--- IF c>upsr1 THEN BEGIN trs=1; IF trsr1=-1 THEN changeOfTrs=1; end else if c<dnsr1 THEN BEGIN trs=-1; IF dnsr1=1 THEN changeOfTrs=1; end else if trsr1=1 THEN BEGIN trs=1; changeOfTrs=0; end else if trsr1=-1 THEN BEGIN trs=-1; changeOfTrs=0; end IF trs<0 and trsr1>0 THEN BEGIN flag=1; end else BEGIN flag=0; end IF trs>0 and trsr1<0 THEN BEGIN flagh=1; end else BEGIN flagh=0; end //-- draw the indicator IF trs=1 THEN BEGIN SuperTrend=dns; if changeOfTrs=1 THEN BEGIN SuperTrendr1=SuperTrendr2; changeOfTrs=0; end end else if trs=-1 THEN BEGIN SuperTrend=ups; if changeOfTrs=1 THEN BEGIN SuperTrendr1=SuperTrendr2; changeOfTrs=0; end end //--- Support1:=SuperTrend; Resist1:=SuperTrend; UpTrend:=Support1<C; //--- IF UpTrend THEN BEGIN IF L<Support1 AND C>Support1 THEN BEGIN SUPERTREND上拐=L; END END else BEGIN IF H>Resist1 AND C<Resist1 THEN BEGIN SUPERTREND下拐=H; END END //--- 请帮忙看下我所改的问题出在哪里?调不出两条线出来
|
-- 作者:sanmu528 -- 发布时间:2018/1/18 1:15:19 -- 以下指标是MT5的部分源码,想改成金字塔版的。谢谢,帮我看下上面编码问题出在哪里 input int Periode=10; input double Multiplier=3; input bool Show_Filling=false; // Show as DRAW_FILLING //--- double buyPB[]; double sellPB[]; //--- double SuperTrend[]; double ColorBuffer[]; //--- double Atr[]; double Up[]; double Down[]; double Middle[]; double trend[]; //--- int atrHandle; int changeOfTrend; int flag; int flagh; Middle[i]=(high[i]+low[i])/2; Up[i] = Middle[i] +(Multiplier*Atr[i]); Down[i]= Middle[i] -(Multiplier*Atr[i]); //--- if(close[i]>Up[i-1]) { trend[i]=1; if(trend[i-1]==-1) changeOfTrend=1; } else if(close[i]<Down[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 && Down[i]<Down[i-1]) Down[i]=Down[i-1]; if(trend[i]<0 && Up[i]>Up[i-1]) Up[i]=Up[i-1]; if(flag==1) Up[i]=Middle[i]+(Multiplier*Atr[i]); if(flagh==1) Down[i]=Middle[i]-(Multiplier*Atr[i]); //-- draw the indicator if(trend[i]==1) { SuperTrend[i]=Down[i]; if(changeOfTrend==1) { SuperTrend[i-1]=SuperTrend[i-2]; changeOfTrend=0; } ColorBuffer[i]=0.0; } else if(trend[i]==-1) { SuperTrend[i]=Up[i]; if(changeOfTrend==1) { SuperTrend[i-1]=SuperTrend[i-2]; changeOfTrend=0; } ColorBuffer[i]=1.0; } //--- double Support1= 0; double Resist1 = 0; //--- Support1 = SuperTrend[i]; Resist1 = SuperTrend[i]; //--- bool UpTrend=Support1<close[i]; //--- sellPB[i]=0; buyPB[i]=0; //--- if(UpTrend) { if(low[i]<Support1 && close[i]>Support1) { buyPB[i]=low[i]; } } else { if(high[i]>Resist1 && close[i]<Resist1) { sellPB[i]=high[i]; } } } //--- return value of prev_calculated for next call return(rates_total); } //+---------+ |
-- 作者:FireScript -- 发布时间:2018/1/18 10:28:15 -- MT5我们这边不是很了解,所以没办法很好的处理。举个例子:你翻译一个语言从德语翻译到中文,肯定要对2种语言都有了解才行。我们技术人员肯定如果对MT5了解比较少的话,那对你的帮助就很有限了。 |
-- 作者:sanmu528 -- 发布时间:2018/1/18 11:04:23 -- 老师,你说的我明白了,那能否看下我前面的编码有没有什么逻辑上的问题,请帮忙指出改进,,谢谢 |
-- 作者:sanmu528 -- 发布时间:2018/1/18 11:14:00 -- 以下是我通过文化版自己改进的编码,,在指标里是可以显示红绿已经转向的,,但是转向不是很到位有偏差,所以我现在想参照MT5里的多循环模糊逻辑进去,可出来的编码指标就实现不了红绿和转向 INPUT:M0(1.5,1,10,1),N2(10,1,50,1); variable:trs:=0,ups:=0,dns:=0; R001:KLINE(H,O,L,C,1); TR1:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW)); ATR:=MA(TR1,NN); med:=(H+L)/2; ups:=med+atr*M0; dns:=med-atr*M0; trs:=if(c>ref(ups,1),1,if(c<ref(dns,1),-1,trs)); flag:=trs<0 and ref(trs,1)>0; flagh:=trs>0 and ref(trs,1)<0; dns:=if(trs>0 and dns<ref(dns,1),ref(dns,1),dns); ups:=if(trs<0 and ups>ref(ups,1),ref(ups,1),ups); ups:=if(flag,med+atr*M0,ups); dns:=if(flagh,med-atr*M0,dns); outtrs:=trs; outups:=ups; outdns:=dns; SUPERTREND:=if(outtrs=1,outdns,outups); L1:=REF(UPS,BARSLAST(UPS<=REF(UPS,1))); L2:=LLV(UPS,NN*1.5); LL:=IF(L2!=REF(L2,1) AND L1<REF(L1,1),L1,IF(L1=L2,L1,L2)); S1:=BARSLAST(CROSS(0.5,UPS=LL))+1; S2:=CROSS(COUNT((CROSS(C,LL) OR CROSS(C,REF(LL,2))) AND UPS>LL,S1),0.5); A6:=BARSLAST(S2); B6:=BARSLAST(CROSS(HHV(DNS,A6+1),C)); SUPERTREND上拐:=CROSS(B6,A6); SUPERTREND下拐:=CROSS(A6,B6); SUPERTREND01:IF(B6>A6,HHV(DNS,BARSLAST(SUPERTREND上拐)+1),LLV(UPS,BARSLAST(SUPERTREND下拐)+1)),COLOR996611,LINETHICK2; SUPERTREND02:IF(B6>A6,SUPERTREND01,DRAWNULL),COLORF00099,LINETHICK2; SUPERTREND下标记:DRAWICON(SUPERTREND下拐,SUPERTREND01*1.001,5); SUPERTREND上标记:DRAWICON(SUPERTREND上拐,SUPERTREND02*0.999,4); |
-- 作者:sanmu528 -- 发布时间:2018/1/18 11:16:54 -- 以下是我参照MT5自己改的编码,但就是SUPERTREND线显示数值有很大问题,,所以我不知道问题出在哪里,请帮忙看下,谢谢 INPUT:M0(1.5,1,10,1),N2(10,1,50,1); variable:trs:=0; variable:ups:=0; variable:dns:=0; variable:flag=0; variable:flagh=0; variable:changeOfTrs=0; variable:ColorBuffer=0; variable:Support1=1; variable:Resist1=1; variable:SUPERTREND下拐=1; variable:SUPERTREND上拐=1; //--- R001:KLINE(H,O,L,C,1); //--- TR1:=MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW)); ATR:=MA(TR1,NN); med:=(H+L)/2; ups:=med+atr*M0; dns:=med-atr*M0; trsr1:=ref(trs,1); trsr2:=ref(trs,2); upsr1:=ref(ups,1); dnsr1:=ref(dns,1); //--- IF c>upsr1 THEN BEGIN trs=1; IF trsr1=-1 THEN changeOfTrs=1; end else if c<dnsr1 THEN BEGIN trs=-1; IF trsr1=1 THEN changeOfTrs=1; end else if trsr1=1 THEN BEGIN trs=1; changeOfTrs=0; end else if trsr1=-1 THEN BEGIN trs=-1; changeOfTrs=0; end IF trs<0 and trsr1>0 THEN BEGIN flag=1; end else BEGIN flag=0; end IF trs>0 and trsr1<0 THEN BEGIN flagh=1; end else BEGIN flagh=0; end IF trs>0 and dns<dnsr1 THEN dns=dnsr1; IF trs<0 and ups>upsr1 THEN ups=upsr1; IF flag=1 THEN ups=med+atr*M0; IF flagh=1 THEN dns=med-atr*M0; SUPERTREND:if(TRS=1,dns,ups); |
-- 作者:sanmu528 -- 发布时间:2018/1/18 11:19:28 -- 我对比了下和MT5的以下这段IF else if循环,我看不出我自己以上编的问题出在哪,望帮忙提建议,谢谢 Middle[i]=(high[i]+low[i])/2; Up[i] = Middle[i] +(Multiplier*Atr[i]); Down[i]= Middle[i] -(Multiplier*Atr[i]); //--- if(close[i]>Up[i-1]) { trend[i]=1; if(trend[i-1]==-1) changeOfTrend=1; } else if(close[i]<Down[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 && Down[i]<Down[i-1]) Down[i]=Down[i-1]; if(trend[i]<0 && Up[i]>Up[i-1]) Up[i]=Up[i-1]; if(flag==1) Up[i]=Middle[i]+(Multiplier*Atr[i]); if(flagh==1) Down[i]=Middle[i]-(Multiplier*Atr[i]); //-- draw the indicator if(trend[i]==1) { SuperTrend[i]=Down[i]; if(changeOfTrend==1) { SuperTrend[i-1]=SuperTrend[i-2]; changeOfTrend=0; } ColorBuffer[i]=0.0; } else if(trend[i]==-1) { SuperTrend[i]=Up[i]; if(changeOfTrend==1) { SuperTrend[i-1]=SuperTrend[i-2]; changeOfTrend=0; } ColorBuffer[i]=1.0; }
|
-- 作者:sanmu528 -- 发布时间:2018/1/18 11:20:18 -- 不知道我的前端变量设置是否不对? |
-- 作者:sanmu528 -- 发布时间:2018/1/18 11:22:49 -- 请你分别输入文华改进版和我现在的编码分别比照下,应该需要如何作调整 |