以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  限价止盈止损的问题  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=10921)

--  作者:kingmoonwang
--  发布时间:2012/4/5 17:33:37
--  限价止盈止损的问题

K线走完模式下。可否实现限价止盈止损。

比如盈利200点以后,回撤到只有50点盈利的时候止盈。到50点的时候马上止盈,而不是等K线结束。


--  作者:admin
--  发布时间:2012/4/5 17:56:16
--  

软件自带的止赢止损功能就可以实现吧


--  作者:kingmoonwang
--  发布时间:2012/4/5 18:23:34
--  

是想实现固定点位的分级止盈。软件功能只能固定一个点位。

 

比如 止盈1:盈利到200点,然后回撤到盈利50点。立即止盈。

       止盈2:盈利到500点,回撤到盈利200点。立即止盈。

       止盈3:盈利到800点,回撤到盈利500点。立即止盈。

 

哪位大侠如果能帮忙写一下更加感激不尽。


--  作者:kingmoonwang
--  发布时间:2012/4/5 22:23:27
--  

自己写了一下。好像实现不了。不管是LIMITR,还是MARKET,都是以最优价和市价成交的吧?也就是说,只要到目标点位,因为一定优于回撤止盈价,所以就止盈了,实现不了回撤止盈。是这样么?

 

只能再向各位大侠请教了。

 


--  作者:just
--  发布时间:2012/4/6 9:06:24
--  
参考http://www.weistock.com/bbs/dispbbs.asp?boardid=11&Id=9053 
--  作者:rushtaotao
--  发布时间:2012/4/6 9:08:22
--  
或者你可以把你写的代码发出来哦
--  作者:kingmoonwang
--  发布时间:2012/4/6 9:11:59
--  

空头部分如下:

 

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


--  作者:rushtaotao
--  发布时间:2012/4/6 9:52:15
--  

是不是因为您的lprice没有定义全局变量的原因

您尝试下添加以下代码

variable:lprice=o;

 


--  作者:kingmoonwang
--  发布时间:2012/4/6 10:01:54
--  

To rushtaotao大侠:

 

在策略最前面已经声明了全局变量了。

 

另外,看了火哥写的那个,感觉火哥的可以实现是通过提高止损位实现的。求证。

 


--  作者:just
--  发布时间:2012/4/6 10:33:28
--  

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