程序化止损止盈单。
1、固定止损20点,当价格向有利方向变动50点时,固定止损上移或下移到保本价的位置。
2、当跟踪价格盈利回落50点时设置止盈。
我仅以多头为例,空头可在理解范例基础上修改即可。
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);