以文本方式查看主题

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

--  作者:qq代人发帖
--  发布时间:2018/9/17 13:32:48
--  程序化止损止盈单。

程序化止损止盈单。

1、固定止损20点,当价格向有利方向变动50点时,固定止损上移或下移到保本价的位置。

2、当跟踪价格盈利回落50点时设置止盈。


--  作者:FireScript
--  发布时间:2018/9/17 13:58:59
--  
 我仅以多头为例,空头可在理解范例基础上修改即可。

maxProfit:hhv(h,ENTERBARS+2)-AVGENTERPRICE;//最高盈利
currentProfit:c-AVGENTERPRICE;//当前盈利
conds1:AVGENTERPRICE-c>20*MINDIFF and holding>0;//20点固定止损
conds2:maxProfit>=50*MINDIFF and currentProfit<=0 and holding>0;//最高盈利超过50点则止损按照保本价执行
conds3:maxProfit-currentProfit>=50*MINDIFF and currentProfit>0 and holding>0;//最高盈利点回落50点止盈

if cond1 or cond2 or cond3 then sell(holding>0,holding,market);