以文本方式查看主题

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

--  作者:149406672
--  发布时间:2021/4/20 17:22:06
--  请求编个均线策略
条件1:当60均线向上(当日均线价格>3日前均线价格)

5均线上穿20均线,开多,下穿20均线 平多,

当60均线向下(当日均线价格<3日前均线价格)

5均线下穿20均线,开空,上穿20均线 平空,


资金使用量50%



感谢!!!

--  作者:fly
--  发布时间:2021/4/29 10:29:53
--  
当60均线向上(当日均线价格>3日前均线价格)
本条件,为当前图表上看到的60均线>3周期前的60日均线。

//适用于:图表程序化交易
ma5:ma(c,5);
ma20:ma(c,20);
ma60:ma(c,60);

//平空开多
if ref(ma60,1)>ref(60,4) and cross(ma5,ma20) then 
begin
sellshort(holding<0,holding,market);
    buy(holding=0,50%,market);
end

//平多开空
if ref(ma60,1)<ref(60,4) and cross(ma20,ma5) then 
begin
sell(holding>0,holding,market);
    buyshort(holding=0,50%,market);
end

//平仓
if cross(ma20,ma5) then sell(holding>0,holding,market);
if cross(ma5,ma20) then sellshort(holding<0,holding,market);