这个是提取50ETF模型的下单器。原模型开空单的话就买入沽期权,但是怎样空单都转变不了下多单,这里怎么改?
Globalvariable:hold=drawnull;
//蓝色部分改为你自己的模型
ppp2:=stkindi('SH016','50ETF.ppp',0,1,0);
ppp800101:=1*ppp2;
order:=ppp800101-holding;
if order>0 then begin
pc:=min(abs(min(holding,0)),order);
kc:=order-pc;
sellshort(pc>0,pc,thisclose);
buy(kc>0,kc,thisclose);
end
if order<0 then begin
pc:=min(max(holding,0),abs(order));
kc:=abs(order)-pc;
sell(pc>0,pc,thisclose);
buyshort(kc>0,kc,thisclose);
end
不是很明白您问题,是ppp这个引用过来的数值没有数据吗
把holding输出下,是不是平仓的时候没有全平掉?
源模型有这么一句 ppp:=holding;用来获取信号的输出没有问题,就是要输出为开空仓的信号转化为开多仓的动作
调过来而已明白不
就是期货里面的开空相当于期权里面买入沽嘛
你把这个策略加载到沽的合约上去就可以了,么有问题的代码
我做沽也是做买方。所以要把50etf的模型开空信号变成沽的开多(买方)信号,明白不?
Globalvariable:hold=drawnull;
//蓝色部分改为你自己的模型
ppp2:=stkindi('SH016','50ETF.ppp',0,1,0);
ppp800101:=1*ppp2;
order:=ppp800101-holding;
if order>0 then begin
pc:=min(abs(min(holding,0)),order);
kc:=order-pc; buy(kc>0,kc,thisclose);
end
if order<0 then begin
pc:=min(max(holding,0),abs(order));
kc:=abs(order)-pc;
sell(pc>0,pc,thisclose);
end
你代码里已经有buy了,就是买方了,把策略加载到具体自己选择好的某个沽合约上执行就行了