请老师修改成触发多单条件
STICKLINE(CROSS(CLOSE,多) AND REF(N2<N1,1) AND CLOSE>=OPEN,OPEN,CLOSE,10,1),COLORFF00FF;
STICKLINE(CROSS(CLOSE,多) AND REF(N2<N1,1) AND CLOSE>=OPEN,LOW,MIN(OPEN,CLOSE),1,1),COLORFF00FF;
STICKLINE(CROSS(CLOSE,多) AND REF(N2<N1,1) AND CLOSE>=OPEN,HIGH,MAX(OPEN,CLOSE),1,1),COLORFF00FF;
STICKLINE(CROSS(CLOSE,多) AND REF(N2<N1,1) AND CLOSE<OPEN,OPEN,CLOSE,10,1),COLORFF00FF;
STICKLINE(CROSS(CLOSE,多) AND REF(N2<N1,1) AND CLOSE<OPEN,LOW,MIN(OPEN,CLOSE),1,1),COLORFF00FF;
STICKLINE(CROSS(CLOSE,多) AND REF(N2<N1,1) AND CLOSE<OPEN,HIGH,MAX(OPEN,CLOSE),1,1),COLORFF00FF;
1.代码不完整。
“CROSS(CLOSE,多) ”这里“多”这个变量缺乏定义。
2.“触发多单条件”是指画柱线条件改成下单条件?
1.STICKLINE(CROSS(CLOSE,IF(BS=0,CURRDN,REF(CURRDN,BS)) AND REF(N2<N1,1) AND CLOSE>=OPEN,OPEN,CLOSE,10,1),COLORFF00FF;
2.是的,画柱线条件改成下单条件
如果只是单纯改成下单是没问题的。
开多条件:CROSS(CLOSE,多) AND REF(N2<N1,1) AND CLOSE>=OPEN;
buy(开多条件,1,market);
未定义的部分,你自行填充进去就行了。
另外因为你没有平仓条件,加载数据太多时候可能因为模型虚拟资金不足会出不了信号。最好能完整的有开仓条件,也有平仓条件。
开多条件:CROSS(CLOSE,多) AND REF(N2<N1,1) AND CLOSE>=OPEN;
开空条件:CROSS(空,CLOSE) AND REF(N1<N2,1) AND CLOSE>=OPEN;
开空的同时平多单,开多的的同时开空单 应该怎么实现?
反手得话。就这样做:
if 平多开空 then
begin
sell(holding>0,holding,market);
buyshort(holding=0,1,market);
END
平空开多也是类似的。
谢谢老师,试了一下,不知那里出问题了,没实现,请您帮忙改成完整的,新手上路,请多指教
平空开多:CROSS(CLOSE,多) AND REF(N2<N1,1) AND CLOSE>=OPEN;
平多开空:CROSS(空,CLOSE) AND REF(N1<N2,1) AND CLOSE>=OPEN;
if 平多开空 then
begin
sell(holding>0,holding,market);
buyshort(holding=0,1,market);
END
if 平空开多 then
begin
sellshort(holding<0,holding,market);
buy(holding=0,1,market);
END
平空开多:STICKLINE(CROSS(CLOSE,多) AND REF(N2<n1,1) and="AND" close="CLOSE" >=OPEN,OPEN,CLOSE,10,1),COLORFF00FF;
平多开空:STICKLINE(CROSS(空,CLOSE) AND REF(N1<n2,1) and="AND" close="CLOSE" >=OPEN,OPEN,CLOSE,10,1),COLORYELLOW;
老师您昨天帮忙改的如下,贴上去之后实现不了程序化,问题出在那里?
平空开多:CROSS(CLOSE,多) AND REF(N2<n1,1) and="AND" close="CLOSE" >=OPEN;
平多开空:CROSS(空,CLOSE) AND REF(N1<n2,1) and="AND" close="CLOSE" >=OPEN;
if 平多开空 then
begin
sell(holding>0,holding,market);
buyshort(holding=0,1,market);
END
if 平空开多 then
begin
sellshort(holding<0,holding,market);
buy(holding=0,1,market);
END
因为你没有定义好,这个“多” n2,n1不清楚你前面有没有定义。这个我暂时不管
平空开多:CROSS(CLOSE,多) AND REF(N2<n1,1) and="AND" close="CLOSE" >=OPEN;
平多开空:CROSS(空,CLOSE) AND REF(N1<n2,1) and="AND" close="CLOSE" >=OPEN;
但是这后面你想表达啥?表示收盘价大于开盘价吗?