10) 追踪止赢功能(按回调比例)
input:NS(5,1,100,1);{
回调比例}
tt0:=time<145000;
tt2:=time>145700;//收盘时间
SELLSHORT(tt0 and BP and 持仓<0,持仓,market);
SELLSHORT(tt0 and 持仓<0,持仓,Stopr, LLV(L,ENTERBARS)*(1+NS/100));
BUY(tt0 and BK and 持仓=0,20%,market);
SELL(tt0 and SP and 持仓>0,持仓,market);
SELL(tt0 and 持仓>0,持仓,Stopr, HHV(H,ENTERBARS)*(1-NS/100));
BUYSHORT(tt0 and SK and 持仓=0,20%,market);
这是程序帮助中对追踪止盈的一个范例,在没有加入这里的内容时,我的软件一切正常。加入这部分内容后,发现开仓后就立即平仓的特别多。而且在K线下面基本上每个都有一个三角形,是什么原因?
移动止损的例子,论坛有。希望能有追踪止盈的范例
VARIABLE: aspect=0; //初始化假定做多头
VARIABLE: stopprice=0;//止损价格变量
VARIABLE: stopnum =NS*mindiff; //止损价差
if barpos = 0 then
stopprice := h - stopnum;
if aspect = 0 then
begin
//多头处理
if h <= stopprice then
begin
//多反空
aspect:= 1;
stopprice := l+stopnum;
end
//处理移动的底部
if h - stopnum > stopprice then
stopprice := h-stopnum;
end
if aspect = 1 then
begin
//空头处理
if l >= stopprice then
begin
//空反多
aspect:= 0;
stopprice := h-stopnum;
end
//处理移动的底部
if l+ stopnum < stopprice then
stopprice := L+stopnum;
老师,仿照移动止损的例子,做了一个移动止盈的,好像测试有效。请老师指点--价格大于stopprice空头止赢