老师,我要写一个股票后台程序化,内容如下:
1、持仓股票涨3%卖出50%仓位;
2、卖出后检测,股票从最高价回落2.5%以上卖出100%仓位;
请帮助编写,谢谢!
if c>=tenterprice*0.03 then tsell(1,50%,mkt),pertrader;
if c<=hhv(h,tenterbars+1) and tenterbars<>-1 then tsell(1,100%,mkt),pertrader;
老师:
1、股票涨3%是以昨日收盘价计算涨3%卖出50%仓位
卖出后检测股票从最高价回落2.5%卖出可用仓位100%,指从今日最高价回落2.5%
if c>=ref(c,todaybar)*0.03 then tsell(1,50%,mkt),pertrader;
if c<=hhv(h,todaybar) then tsell(1,100%,mkt),pertrader;
老师:你写的是序列模式还是逐K线模式?
是不是可以这样写:
//持仓股票以昨天收盘价计算涨3%卖出50%仓位:
if c>=ref(c,1)*1.03 then tsell(1,50%,mkt),pertrader;
//卖出后以今天最高价计算,回落2.5%卖出剩余仓位的100%:
if c<=hhv(h,todaybar)*0.975 then tsell(1,100%,mkt),pertrader;
还是应该写成是
if c<=h*0.975 then tsell(1,100%,mkt),pertrader;
1序列
2你的写法只能是用在日线上,我的还可以用在分钟周期上
回落平仓更正
//卖出后以今天最高价计算,回落2.5%卖出剩余仓位的100%:
if c<=(HIGH - C)/REF(C,1))
*0.975 then tsell(1,100%,mkt),pertrader;
if c>=ref(c,todaybar)*1.03 then tsell(1,50%,mkt),pertrader;
if c<=hhv(h,todaybar) *0.975 then tsell(1,100%,mkt),pertrader; |
[此贴子已经被作者于2017-1-16 10:29:35编辑过]