这个程序不知错在哪里,编译通过了,图上显示出来重复开仓,请老师改正,谢谢
源码
————————————————————
input:m(26,1,100,1),n(2,0.1,99,0.1);
MID:ma(close,m);
UPPER:MID + N * std(close,m);
LOWER:MID - N * std(close,m);
//交易条件
开多:=c>=upper and holding=0;
开空:=lower>=c and holding=0;
平多:=mid>=c and holding>0;
平空:=c>=mid and holding<0;
variable:MAXC=500000;//maxc是权益最大值
MAXC:=hhv(asset,180);//180个周期内权益最大值
if asset > MAXC then
MAXC:=asset;
if asset<maxc*0.9 and CASH(0)>maxc*0.8 THEN PosNum:=asset*0.03/600 ;//当平仓资金权益从最高点回撤大于10%小于20%,开仓比例为本金的3%/600元;
else if
asset<maxc*0.8 and asset>maxc*0.7 THEN PosNum:=asset*0.015/600 ;//当平仓资金权益从最高点回撤大于20%小于30%,仓位使用为本金的1.5%/600元;
else if
asset<maxc*0.7 and asset>maxc*0.6 THEN PosNum:=asset*0.0075/600 ;//当平仓资金权益从最高点回撤大于30%小于40%,仓位使用为本金的0.75%/600元;
else if
else PosNum:=asset*0.03/600;//正常情况(平仓资金权益从最高点回撤小于10%),开仓比例为本金的3%/600元;
仓位:=PosNum;
//交易系统
buy(开多,仓位,MARKET);
buyshort(开空,仓位,MARKET);
sell(平多,0,MARKET);
sellshort(平空,0,MARKET);
盈亏:asset-500000,noaxis,colorred,linethick2;
——————————————————————————
[此贴子已经被作者于2016-8-11 16:43:47编辑过]
并且轨道上轨UPPER也无法显示
此主题相关图片如下:145d5497-aa07-4a71-8664-82efd6307190.jpg

[此贴子已经被作者于2016-8-12 8:45:05编辑过]
input:m(26,1,100,1),n(2,0.1,99,0.1);
MID : MA(CLOSE,M);
UPPER: MID + N*STD(CLOSE,M);
LOWER: MID - N*STD(CLOSE,M);
//交易条件
开多:=c>=upper and holding=0;
开空:=lower>=c and holding=0;
平多:=mid>=c and holding>0;
平空:=c>=mid and holding<0;
variable:MAXC=500000;//maxc是权益最大值
MAXC:=hhv(asset,180);//180个周期内权益最大值
if asset > MAXC then
MAXC:=asset;
if asset<maxc*0.9 and CASH(0)>maxc*0.8 THEN PosNum:=asset*0.03/600 ;//当平仓资金权益从最高点回撤大于10%小于20%,开仓比例为本金的3%/600元;
if asset<maxc*0.8 and asset>maxc*0.7 THEN PosNum:=asset*0.015/600 ;//当平仓资金权益从最高点回撤大于20%小于30%,仓位使用为本金的1.5%/600元;
if asset<maxc*0.7 and asset>maxc*0.6 THEN PosNum:=asset*0.0075/600 ;//当平仓资金权益从最高点回撤大于30%小于40%,仓位使用为本金的0.75%/600元;
if asset>maxc*0.9 then PosNum:=asset*0.03/600;//正常情况(平仓资金权益从最高点回撤小于10%),开仓比例为本金的3%/600元;
仓位:=PosNum;
//交易系统
buy(开多,仓位,MARKET);
buyshort(开空,仓位,MARKET);
sell(平多,0,MARKET);
sellshort(平空,0,MARKET);
盈亏:asset-500000,noaxis,colorred,linethick2;
后面的esle不当使用影响到了前面,所以我做了对应的修改