老师好!
我写了一个系统,可是它只显示开多和平多止多的信号,没有开空和平空的信号,不知道错在哪了?特请教!谢谢!
//交易系统
//开多-------------------------------------------------------------------------------------------------------------
if KDDiBLTJ and holding<=0 then
begin
KD先平空:sellshort(KDDiBLTJ and holding<0,0,market); //按语法要求先平仓再开仓
KDDiBL开多:buy(holding=0,1,market);
StopLow:=BoDuanLLV; //设低点为止损价
end
//开空--------------------------------------------------------------------------------------------------------------
if KDDingBLTJ and holding>=0 then
begin
KD先平多:sell(KDDingBLTJ and holding>0,0,market);//按语法要求先平仓再开仓
KDDIngBL开空:buyshort(holding=0,1,market);
StopHigh:=BoDuanHHV; //设高点为止损价
end
//跟踪止损-----------------------------------------------------------------------------------------------------------------
//多单
if holding>0 and KcrossD then StopLow:=BoDuanLLV; //若再金叉,止损价跟踪波段最低价
//注意不能将下句平仓语句放在上面一段begin-end中,因为金叉时未必下破止损,下破止损时可能已叉多时。上段只是用金叉来确定止损点
if l<StopLow then 止损平多:sell(holding>0,0,market);//跌破止损
if h>UpperEst then 布林极值平多: sell(holding>0,0,market);//布林平多赢
//空单
if holding<0 and DcrossK then StopHigh:=BoDuanHHV;//若再死叉,止损价跟踪波段最低价
//注意不能将下句平仓语句放在上面一段begin-end中,因为死叉时未必上破止损,上破止损时可能已死叉多时。上段只是用死叉来确定止损高点
if h>StopHigh then 止损平空:sellshort(holding<0,0,market);
if l<LowerEst then 布林极值平空: sellshort(holding<0,0,market);//布林平空赢