以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://www.weistock.com/bbs/index.asp) -- 公式模型编写问题提交 (http://www.weistock.com/bbs/list.asp?boardid=4) ---- [求助]如何编写以下语句 (http://www.weistock.com/bbs/dispbbs.asp?boardid=4&id=80900) |
-- 作者:zhuangjyuan -- 发布时间:2015/7/14 10:31:51 -- [求助]如何编写以下语句 模型大概如下, 收盘价跌破MA60,则按收盘价开空 如果价格收回MA60,则按收盘价止损平空; 做多则相反; 如果被止损,则从被止损K线算起,20个周期不再开仓,等20个周期后在按开仓条件判断开仓 请问这个该如何编写,谢谢!!
|
-- 作者:jinzhe -- 发布时间:2015/7/14 10:36:13 -- variable:n=0; ma60:ma(c,60); if holding=0 and cross(ma60,c) and n=0 then begin buyshort(1,1,limitr,close); n:=1; end
if holding=0 and cross(c,ma60) and n=0 then begin buy(1,1,limitr,close); n:=1; end
if cross(c,ma60) then sellshort(1,0,limitr,close);
if cross(ma60,c) then sell(1,0,limitr,lcose);
if holding=0 and cross(c,ma60) and n=1 and exitbars>20 then buy(1,1,limitr,close);
if holding=0 and cross(ma60,c) and n=1 and exitbars>20 then buyshort(1,1,limitr,close); |