何种情况下会出现?图表上没有信号,模型实际去发出了下单指令?而另一次,图表有信号,该下发指令的时候,模型却没有发出?
有没有其他用户发生这个情况?
我这模型后面的下单模块用了很久了,第一次出现这种情况.
请帮忙看看这段代码有问题么?执行了很久,第一次出错:
//买开执行
if condkd and cond00 then
begin
if holding<0 then SELLSHORT(1,unit,market),ORDERQUEUE;//平空
if holding=0 then
begin
buy(1,unit,market),ORDERQUEUE;//开多
bkpp:=AVGENTERPRICE;
end
end
//计算多头止损点
zsjg1:=bkpp-bkpp*(lspd/1000);//绝对止损价格
zsjg2:=底;
zsjg3:=if(enterbars>1,hhv(ref(c,1),enterbars)-bkpp*wind/1000,zsjg1);
if holding>0 then 多头止:max(max(zsjg1,zsjg2),zsjg3); //多头离场线
//多单止损
if holding>0 then
begin
if close<多头止 then 多止:SELL(1,unit,market),ORDERQUEUE;//平多
end
//盈利平多:
if cond3 and holding>0 and enterbars>=1 and close > bkpp then
begin
SELL(1,unit,market),ORDERQUEUE;//平多
end
//卖开执行
if condkk and cond00 then
begin
if holding>0 then SELL(1,unit,market),ORDERQUEUE;//平多
if holding=0 then
begin
buySHORT(1,unit,market),ORDERQUEUE;//开空
skpp:=AVGENTERPRICE;
end
end
//计算空头止损点
zsjgk1:=skpp+skpp*(lspk/1000);//绝对止损价格
zsjgk2:=顶;
zsjgk3:=if(enterbars>1,llv(ref(c,1),enterbars)+skpp*wink/1000,zsjgk1);
if holding<0 then 空头止:min(min(zsjgk1,zsjgk2),zsjgk3); //画空头离场线
//空单止损
if holding<0 then
begin
if close>空头止 then 空止:SELLSHORT(1,unit,market),ORDERQUEUE;//平空
end
//盈利平空:
if holding<0 and condpk and enterbars>=1 and close< skpp then
begin
SELLSHORT(1,unit,market),ORDERQUEUE;//平空
end
满足买开条件时,检查了holding<0和=0的情况,用不用再检查holding>0的情况?还是前两个不满足自动就算第三个?
有日志吗?
公式从上往下计算,条件满足就执行,不满足就不执行
以前没出过这种问题,一直没记日志。
不过,如果是代码有问题,也应该是图表信号和实际下单指令一致,要错都错,要对都对。不应该出现指令与图表不符的情况吧?
Tholding检查实际持仓这个函数能否用在图表交易里面?
今天的情况是图表没信号,但模型先下了一手空单。Holding函数自然是无法知道实际仓位的,还是按照仓位为零来处理的,又下了一手。
最好能记录下日志,有了日志协助分析比凭空猜想要靠谱多了
Tholding检查实际持仓这个函数能否用在图表交易里面?