K线走完模式下。可否实现限价止盈止损。
比如盈利200点以后,回撤到只有50点盈利的时候止盈。到50点的时候马上止盈,而不是等K线结束。
软件自带的止赢止损功能就可以实现吧
是想实现固定点位的分级止盈。软件功能只能固定一个点位。
比如 止盈1:盈利到200点,然后回撤到盈利50点。立即止盈。
止盈2:盈利到500点,回撤到盈利200点。立即止盈。
止盈3:盈利到800点,回撤到盈利500点。立即止盈。
哪位大侠如果能帮忙写一下更加感激不尽。
自己写了一下。好像实现不了。不管是LIMITR,还是MARKET,都是以最优价和市价成交的吧?也就是说,只要到目标点位,因为一定优于回撤止盈价,所以就止盈了,实现不了回撤止盈。是这样么?
只能再向各位大侠请教了。
空头部分如下:
if holding<0 and l<=lprice then begin
lprice:=l;
end
if holding<0 then begin
if enterprice-lprice>200 then begin
空止盈1: sellshort(1,holding,limitr,enterprice-50);
KZY1:=0;
end
if enterprice-lprice>500 then begin
空止盈2: sellshort(1,holding,limitr,enterprice-200);
KZY1:=0;
end
if enterprice-lprice>800 then begin
空止盈3: sellshort(1,holding,limitr,enterprice-500);
KZY1:=0;
end
end
是不是因为您的lprice没有定义全局变量的原因
您尝试下添加以下代码
variable:lprice=o;
To rushtaotao大侠:
在策略最前面已经声明了全局变量了。
另外,看了火哥写的那个,感觉火哥的可以实现是通过提高止损位实现的。求证。
variable: lprice=0, KZY1=0;
if cond then begin
buyshort();
lprice:=l;
KZY1:=1;
end
if enterprice-lprice>200 AND KZY1=1 then begin
空止盈1: sellshort(HOLDING<0,holding,limitr,enterprice-50);
KZY1:=0;
end
if enterprice-lprice>500 AND KZY1=1 then begin
空止盈2: sellshort(HOLDING<0,holding,limitr,enterprice-200);
KZY1:=0;
end
if enterprice-lprice>800 AND KZY1=1 then begin
空止盈3: sellshort(HOLDING<0,holding,limitr,enterprice-500);
KZY1:=0;
end
end