利用"两种不同的Rsi计算方法(RSI_With_RSI)"设计进出量化策略程式码
链接地址:[url=http://www.qhlt.cn/thread-149735-1-1.html]http://www.qhlt.cn/thread-149735-1-1.html[/url];RSI_With_RSI (Strategy)[code]
Input:slowrsilen(17),quickrsilen(5),slowmalen(40),quickmalen(10),rsibuylevel(60),rsiselllevel(40);
var:oktotrade(False),slowrsi(0),quickrsi(0),slowma(0),quickma(0),slowrsitrenddir(0);
slowrsi = RSI(close,slowrsilen);
quickrsi = RSI(close,quickrsilen);
slowma = Average(close,slowmalen);
quickma = Average(close,quickmalen);
if slowrsi crosses above rsibuylevel then slowrsitrenddir = 1
else if slowrsi crosses below rsiselllevel then slowrsitrenddir = -1;
once(currentbar = 1*slowrsilen) oktotrade =True;
if oktotrade then begin
{entries}
if slowrsi crosses above rsibuylevel and Close > slowma then buy("srsi le") next bar at market;
if quickrsi crosses above rsibuylevel and Close > quickma and slowrsitrenddir = -1 then buy("qrsi le") next bar at market;
{exits}
if slowrsi crosses below rsiselllevel or Close < slowma then sell("srsi lx") from entry("srsi le") next bar at market;
if quickrsi crosses below rsiselllevel or Close < quickma then sell("qrsi lx") from entry("qrsi le") next bar at market;
end;
[/code] 运行效果:
[img]http://p.algo2.net/2024/0106/cd03151610edf.png[/img]
[img]http://p.algo2.net/2024/0106/fa9231c2addf1.png[/img]
[img]http://p.algo2.net/2024/0106/81ceed2f03fc4.png[/img]
[img]http://p.algo2.net/2024/0106/d454a4303bd4a.png[/img]
[img]http://p.algo2.net/2024/0106/6624975d3e50c.png[/img]
[img]http://p.algo2.net/2024/0106/f2c715b73870e.png[/img] 不错
页:
[1]