本文将深入探讨基于拉盖尔变换的相对强弱指标(RSI)优化策略。这种策略利用先进的数学工具——拉盖尔变换——来增强RSI指标的灵敏度,使其更快速地响应市场价格变动。
拉盖尔变换RSI指标通过使用拉盖尔滤波器,可以在较短的数据长度上创建高效的指标。该策略的核心是利用拉盖尔变换对价格序列进行处理,从而得到四个级别的拉盖尔线(xL0, xL1, xL2, xL3)。这些线条根据给定的参数gamma
进行计算,用于分析市场趋势。
策略使用CU(累积上升值)和CD(累积下降值)来确定市场的强弱。CU和CD的计算基于拉盖尔线的相对位置。这个方法使得RSI值能够更快地反映价格变动,从而为交易者提供及时的交易信号。
交易信号是根据RSI值与用户定义的买入和卖出界限(BuyBand和SellBand)相比较来生成的。当RSI值高于买入界限时,策略建议做多;当RSI值低于卖出界限时,策略建议做空。
gamma
、买入界限和卖出界限。gamma
值和买卖界限。综合来看,基于拉盖尔变换的RSI优化策略是一个创新和高效的交易工具。它的主要优势在于快速响应市场变化和参数的高度可定制性。然而,就像任何交易策略一样,它也存在风险,特别是在高波动性的市场环境中。为了最大化这一策略的效果,交易者应该结合其他技术分析工具和进行仔细的参数调整。总体而言,这一策略为寻求短期和中期市场机会的交易者提供了一个有价值的工具。
/*backtest
start: 2022-11-15 00:00:00
end: 2023-11-21 00:00:00
period: 1d
basePeriod: 1h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=2
////////////////////////////////////////////////////////////
// Copyright by HPotter v1.0 01/09/2017
// This is RSI indicator which is more sesitive to price changes.
// It is based upon a modern math tool - Laguerre transform filter.
// With help of Laguerre filter one becomes able to create superior
// indicators using very short data lengths as well. The use of shorter
// data lengths means you can make the indicators more responsive to
// changes in the price.
//
// You can change long to short in the Input Settings
// WARNING:
// - For purpose educate only
// - This script to change bars colors.
////////////////////////////////////////////////////////////
strategy(title="Laguerre-based RSI", shorttitle="Laguerre-RSI")
gamma = input(0.5, minval=-0.1, maxval = 0.9)
BuyBand = input(0.8, step = 0.01)
SellBand = input(0.2, step = 0.01)
reverse = input(false, title="Trade reverse")
hline(BuyBand, color=green, linestyle=line)
hline(SellBand, color=red, linestyle=line)
xL0 = (1-gamma) * close + gamma * nz(xL0[1], 1)
xL1 = - gamma * xL0 + nz(xL0[1], 1) + gamma * nz(xL1[1], 1)
xL2 = - gamma * xL1 + nz(xL1[1], 1) + gamma * nz(xL2[1], 1)
xL3 = - gamma * xL2 + nz(xL2[1], 1) + gamma * nz(xL3[1], 1)
CU = (xL0 >= xL1 ? xL0 - xL1 : 0) + (xL1 >= xL2 ? xL1 - xL2 : 0) + (xL2 >= xL3 ? xL2 - xL3 : 0)
CD = (xL0 >= xL1 ? 0 : xL1 - xL0) + (xL1 >= xL2 ? 0 : xL2 - xL1) + (xL2 >= xL3 ? 0 : xL3 - xL2)
nRes = iff(CU + CD != 0, CU / (CU + CD), 0)
pos = iff(nRes > BuyBand, 1,
iff(nRes < SellBand, -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=red, title="Laguerre-based RSI")