以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  公式模型编写问题提交  (http://weistock.com/bbs/list.asp?boardid=4)
----  大家帮忙看看,止损语句没起作用  (http://weistock.com/bbs/dispbbs.asp?boardid=4&id=13290)

--  作者:DarthYoda
--  发布时间:2012/7/25 12:13:35
--  我的一个策略
只用在测试中,但不管用,麻烦大家指点一下,谢谢

if holding=0 and 开多 then buy(1,1,thisclose);
if L<enterprice-30*mindiff then sell(holding>0,0,enterprice-30*mindiff);//30跳止损
if holding>0 and 平多 then sell(1,1,thisclose);

if holding=0 and 开空 then buyshort(1,1,thisclose);
if H>enterprice+30*mindiff then sellshort(holding<0,0,enterprice+30*mindiff);//止损
if holding<0 and 平空 then sellshort(1,1,thisclose);
--  作者:jinzhe
--  发布时间:2012/7/25 13:21:03
--  

sell(holding>0,0,enterprice-30*mindiff);

改成

sell(holding>0,0,limitr,enterprice-30*mindiff);


--  作者:阿火
--  发布时间:2012/7/25 13:22:49
--  

if L<enterprice-30*mindiff then sell(holding>0,0,limitr,min(o,enterprice-30*mindiff));//30跳止损
if holding>0 and 平多 then sell(1,1,thisclose);

if holding=0 and 开多 then buy(1,1,thisclose);


if H>enterprice+30*mindiff then sellshort(holding<0,0,limitr,max(o,enterprice+30*mindiff));//止损
if holding<0 and 平空 then sellshort(1,1,thisclose);
if holding=0 and 开空 then buyshort(1,1,thisclose);


--  作者:DarthYoda
--  发布时间:2012/7/25 18:11:31
--  
以下是引用jinzhe在2012-7-25 13:21:03的发言:

sell(holding>0,0,enterprice-30*mindiff);

改成

sell(holding>0,0,limitr,enterprice-30*mindiff);

多谢,试过了,可用
--  作者:DarthYoda
--  发布时间:2012/7/25 18:13:07
--  
以下是引用阿火在2012-7-25 13:22:49的发言:

if L<enterprice-30*mindiff then sell(holding>0,0,limitr,min(o,enterprice-30*mindiff));//30跳止损
if holding>0 and 平多 then sell(1,1,thisclose);

if holding=0 and 开多 then buy(1,1,thisclose);


if H>enterprice+30*mindiff then sellshort(holding<0,0,limitr,max(o,enterprice+30*mindiff));//止损
if holding<0 and 平空 then sellshort(1,1,thisclose);
if holding=0 and 开空 then buyshort(1,1,thisclose);

多谢,这个也可用,但是有一点不解,上面几个语句难道不要逻辑顺序吗? 我读下来怎么是反的啊?但是结果对
--  作者:阿火
--  发布时间:2012/7/26 8:51:21
--  

你的顺序是错误的

 

开空的位置是在close ,此时K线已经走完。接下来再用low来判断是否止损,就错了,具有隐性未来函数。

所以,要等到下一根才判断止损,放到开仓语句的前面也是这个作用

[此贴子已经被作者于2012-7-26 8:51:50编辑过]

--  作者:阿火
--  发布时间:2012/7/26 8:54:22
--  

另外,如果单单这样写

sell(holding>0,0,limitr,enterprice-30*mindiff);

 

也有点问题。如果触发止损的K线跳空低开触发止损后一路下行,此时以enterprice-30*mindiff下单是无法成交的。所以需要和K线的open做个比较


--  作者:DarthYoda
--  发布时间:2012/7/26 13:32:21
--  
 非常感谢阿火,明白了
--  作者:DarthYoda
--  发布时间:2012/7/29 22:51:29
--  
以下是引用阿火在2012-7-26 8:51:21的发言:

你的顺序是错误的

 

开空的位置是在close ,此时K线已经走完。接下来再用low来判断是否止损,就错了,具有隐性未来函数。

所以,要等到下一根才判断止损,放到开仓语句的前面也是这个作用

[此贴子已经被作者于2012-7-26 8:51:50编辑过]
老大帮我看看,升级2.90以后成未来函数了?
--  作者:DarthYoda
--  发布时间:2012/7/29 23:03:55
--  
不好意思,是我搞错了