-- 为什么开仓信号是两个?
variable:yuanshi=asset;//初始化原始资金;
TR1 := MAX(MAX((HIGH-LOW),ABS(REF(CLOSE,1)-HIGH)),ABS(REF(CLOSE,1)-LOW));
ATR : =MA(TR1,20);//用atr来设置每次试错的最大成本
up:ref(hhv(h,20),1);//设置20日高点为上轨
down:ref(llv(l,20),1);//设置20日低点为下轨
kd:=cross(close,up);//新开多仓条件
kk:=cross(down,close);//新开空仓条件
duojia:=close>(enterprice+3*atr) and asset>yuanshi;//如果帐面盈利,每间隔3个atr加一次多仓;
kongjia:=close<(enterprice-3*atr) and asset>yuanshi;//如果帐面盈利,每间隔3个atr加一次空仓;
duozhisunprice:=cross(enterprice-atr*1.1,close);//多仓止损条件:反向波动1.1个atr;
kongzhisunprice:=cross(close,enterprice+atr*1.1);//空仓止损条件:反向波动1.1个atr;
duozhisuntime:=(enterbars>=10 and close<enterprice+3*atr);//多仓时间止损:持仓10天未达到3个atr盈利,退出;
kongzhisuntime:=(enterbars>=10 and close>enterprice-3*atr);//空仓时间止损:持仓10天未到3个atr盈利,退出
//duoyingliprice:=cross(close,enterprice+3*atr);
//kongyingliprice:=cross(enterprice-3*atr,close);
buy(kd and holding=0,asset*0.02/(atr*1.1)/multiplier,thisclose);
buy(duojia and holding>0,asset*0.02/(atr*1.1)/multiplier,thisclose);
//sell(duozhisunprice and holding>0,100%,limitr,enterprice-atr*1.1);
sell(duozhisuntime and holding>0,100%,thisclose);
buyshort(kk and holding=0,asset*0.02/(atr*1.1)/multiplier,thisclose);
buyshort(kongjia and holding<0,asset*0.02/(atr*1.1)/multiplier,thisclose);
//sellshort(KONGZHISUNPRICE and holding<0,100%,limitr,enterprice+atr*1.1);
sellshort(kongzhisuntime and holding<0,100%,thisclose);
每次开仓时都开两个,请版主帮忙找找原因,谢谢