
Chiến lược chỉ số động lực tương đối (RMI) là một chiến lược cải tiến dựa trên chỉ số động lực. Chiến lược này đánh giá xem thị trường có đang mua quá mức hay bán quá mức để nắm bắt cơ hội đảo ngược bằng cách tính toán động lực của sự thay đổi giá trong một khoảng thời gian.
Công thức tính toán của chiến lược RMI như sau:
xMom = xPrice - xPrice[Length] //计算Length周期内的价格变动
xMU = 如果xMom >= 0:之前xMU减去xMU/Length加上xMom;否则:之前xMU
xMD = 如果xMom <= 0:之前xMD减去xMD/Length加上xMom的绝对值;否则:0
RM = xMU / xMD
RMI = 100 * (RM / (1 + RM))
Chiến lược này đầu tiên tính toán biến động giá trong chu kỳ Length xMom. Nếu xMom> = 0, giá tăng, xMU tích lũy xMom; Nếu xMom < 0, giá giảm, xMD tích lũy xMom.
Khi RMI cao hơn giá trị thâm hụt của SellZone, nó có nghĩa là mua quá mức, bán tháo; khi RMI thấp hơn giá trị thâm hụt của BuyZone, nó có nghĩa là bán quá mức, mua nhiều hơn.
Có thể giảm rủi ro bằng cách nới lỏng điểm dừng, tối ưu hóa các tham số và kết hợp với các chiến lược xu hướng.
Chiến lược RMI có thể được tối ưu hóa theo các khía cạnh sau:
Chiến lược RMI có thể nắm bắt cơ hội điều chỉnh đường ngắn hiệu quả bằng cách đo biến động giá, thực hiện các hoạt động đảo ngược. Chiến lược RMI nhạy cảm hơn và không bị ảnh hưởng bởi các biến động so với chiến lược RSI. Tuy nhiên, chiến lược này vẫn có nguy cơ bị hoán đổi, cần tối ưu hóa các tham số và sử dụng chiến lược theo xu hướng để có hiệu quả tối đa.
/*backtest
start: 2023-10-02 00:00:00
end: 2023-10-21 00:00:00
period: 2h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 19/10/2017
// The Relative Momentum Index (RMI) was developed by Roger Altman. Impressed
// with the Relative Strength Index's sensitivity to the number of look-back
// periods, yet frustrated with it's inconsistent oscillation between defined
// overbought and oversold levels, Mr. Altman added a momentum component to the RSI.
// As mentioned, the RMI is a variation of the RSI indicator. Instead of counting
// up and down days from close to close as the RSI does, the RMI counts up and down
// days from the close relative to the close x-days ago where x is not necessarily
// 1 as required by the RSI). So as the name of the indicator reflects, "momentum" is
// substituted for "strength".
//
// You can change long to short in the Input Settings
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
strategy(title="Relative Momentum Index", shorttitle="RMI")
xPrice = close
Length = input(20, minval=1)
BuyZone = input(40, minval=1)
SellZone = input(70, minval=1)
reverse = input(false, title="Trade reverse")
// hline(0, color=gray, linestyle=dashed)
// hline(SellZone, color=red, linestyle=line)
// hline(BuyZone, color=green, linestyle=line)
xMom = xPrice - xPrice[Length]
xMU = iff(xMom >= 0, nz(xMU[1], 1) - (nz(xMU[1],1) / Length) + xMom, nz(xMU[1], 1))
xMD = iff(xMom <= 0, nz(xMD[1], 1) - (nz(xMD[1],1) / Length) + abs(xMom), nz(xMD[1], 0))
RM = xMU / xMD
nRes = 100 * (RM / (1+RM))
pos = iff(nRes < BuyZone, 1,
iff(nRes > SellZone, -1, nz(pos[1], 0)))
possig = iff(reverse and pos == 1, -1,
iff(reverse and pos == -1, 1, pos))
if (possig == 1)
strategy.entry("Long", strategy.long)
if (possig == -1)
strategy.entry("Short", strategy.short)
barcolor(possig == -1 ? red: possig == 1 ? green : blue )
plot(nRes, color=blue, title="RMI")