平仓信号出现白箭头,是什么原因?
平仓逻辑清晰:1,持仓enterbars>1 ,持仓周期大于3周期收盘价平仓;
2,止盈h>=enterprice+p2/1000*enterprice
l>=enterprice-p2/1000*enterprice
最高价或最低价达到指定价平仓
3,止损l<=enterprice-p1/1000*enterprice
h>=enterprice+p1/1000*enterprice
最低价或最高价达到指定价平仓
if holding>0 then begin
if enterbars>1 then begin
sell(1,holding,limitr,close);
//sell(1,holding,marketr);
myexitprice:=0;
end
if h>=enterprice+p2/1000*enterprice then begin
myexitprice:=enterprice+p2/1000*enterprice;
//sell(1,holding,marketr);
sell(1,holding,limitr,myexitprice);
myexitprice:=0;
end
if l<=enterprice-p1/1000*enterprice then begin
myexitprice:=enterprice-p1/1000*enterprice;
//sell(1,holding,marketr);
sell(1,holding,limitr,myexitprice);
myexitprice:=0;
end
end
//盈亏计算
if holding<0 then begin
if enterbars>1 then begin
sellshort(1,holding,limitr,close);
//sellshort(1,holding,marketr);
myexitprice:=0;
end
if l>=enterprice-p2/1000*enterprice then begin
myexitprice:=enterprice-p2/1000*enterprice;
//sellshort(1,holding,marketr);
sellshort(1,holding,limitr,myexitprice);
myexitprice:=0;
end
if h>=enterprice+p1/1000*enterprice then begin
myexitprice:=enterprice+p1/1000*enterprice;
//sellshort(1,holding,marketr);
sellshort(1,holding,limitr,myexitprice);
myexitprice:=0;
end
end
平仓有白色箭头说明平仓时的价格超过了k线范围,不易成交
用IGNORECHECKPRICE来处理,使用方法看函数说明
楼主 跳空 导致 价格 不在你想的价格,成交不了啊,要考虑实际些 跳空
以下是引用jinzhe在2016-11-16 9:36:17的发言:
平仓有白色箭头说明平仓时的价格超过了k线范围,不易成交
用IGNORECHECKPRICE来处理,使用方法看函数说明
首先白色箭头的机制是这样的。
然后就回去检查下为什么空价格却超过了k线范围
l>=enterprice-p2/1000*enterprice
h>=enterprice+p1/1000*enterprice
平空条件是这两个,其中第一个,除非L恰好等于enterprice-p2/1000*enterprice ,不然enterprice-p2/1000*enterprice 的价格必然是比L低的,所以,白色箭头这个不合理的价格出现的
所以这一段这样改:
if l>=enterprice-p2/1000*enterprice then begin
myexitprice:=enterprice-p2/1000*enterprice;
//sellshort(1,holding,marketr);
sellshort(1,holding,limitr,L);
myexitprice:=0;
end