以文本方式查看主题 - 金字塔客服中心 - 专业程序化交易软件提供商 (http://222.73.7.161/bbs/index.asp) -- 公式模型编写问题提交 (http://222.73.7.161/bbs/list.asp?boardid=4) ---- 公式编写 (http://222.73.7.161/bbs/dispbbs.asp?boardid=4&id=167642) |
-- 作者:llq -- 发布时间:2019/1/11 11:13:04 -- 公式编写 老师好,KD金叉,收盘价在MA40日之上,开多1手,收盘价连续2根K线在MA20之下,平多1手;KD死叉,收盘价在MA40之下,开空1手,收盘价连续2根在MA20之上,平空。每日收盘后不论涨跌全部平仓,这个公式怎么写。谢谢! |
-- 作者:FireScript -- 发布时间:2019/1/11 11:31:30 -- 参考下面的范例: input:n(9,1,100,10),p1(3,2,40,4),p2(3,2,40,4);//参数设置
RSV:=(CLOSE-LLV(LOW,N))/(HHV(HIGH,N)-LLV(LOW,N))*100; K:SMA(RSV,P1,1); D:SMA(K,P2,1); J:3*K-2*D; ma40:ma(c,40);//40周期均线 ma20:ma(c,20); kdjjc:cross(k,d);//kdj金叉 kdjsc:cross(d,k); if count(c<ma20,2)=2 then sell(holding>0,holding,market);//平多 if c>ma40 and kdjjc then begin buy(holding=0,1,MARKET); end if count(c>ma20,2)=2 then sellshort(holding<0,holding,market);//平空 if c<ma40 and kdjsc then begin buyshort(holding=0,1,MARKET); end if time=CLOSETIME(0) then //收盘平仓,日线以上周期无效。 begin sell(holding>0,holding,market); sellshort(holding<0,holding,market); end |