以文本方式查看主题

-  金字塔客服中心 - 专业程序化交易软件提供商  (http://weistock.com/bbs/index.asp)
--  策略编写求助区  (http://weistock.com/bbs/list.asp?boardid=11)
----  编程需要帮助  (http://weistock.com/bbs/dispbbs.asp?boardid=11&id=7030)

--  作者:zbxtony
--  发布时间:2011/6/29 13:52:13
--  编程需要帮助
请问,如果价格上涨2%就做多,之后价格从最高价格下跌2%就平多单开空单,开空单后价格从最低价格上涨2%就平空单开多单,连续在市,也就是2%转向系统,这个策略可以编写成程序化交易模型吗,如果可以,请帮助编写,谢谢。

--  作者:jinzhe
--  发布时间:2011/6/29 15:31:05
--  

variable :n=0;
o1:=valuewhen((date<>ref(date,1)),o); //今日开盘价
if enterbars=-1 and c/o1>=1.02 then begin //第一次开仓 最新价比今日开盘价上涨2%以上时开仓
 buy(1,1,thisclose);
 n:=1;
end

if ref(hhv(h,enterbars),1)/c>=1.02 and n<>1 then begin//最高价格下跌2%就平多开空
 sell(holding>0,0,thisclose);
 buyshort(1,1,thisclose);
end

if c/ref(llv(l,enterbars),1)>=1.02 and n<>1 then begin//最低价格上涨2%就平空开多
 sellshort(holding<0,0,thisclose);
 buy(1,1,thisclose);
end

 

 

写了下,不过过了开盘时间没有测试。希望能够抛砖引玉


--  作者:zbxtony
--  发布时间:2011/6/30 8:39:36
--  

谢谢