
A estratégia é um sistema de negociação quantitativa baseado na combinação de forma de preço e indicadores técnicos. Ela é executada principalmente através da identificação de rupturas em forma de triângulo, e em combinação com a confirmação de dinâmica do indicador RSI. A estratégia usa o método de regressão linear para construir uma linha de tendência ascendente e descendente, determinando um sinal de negociação através da posição de ruptura de preço e RSI, realizando uma combinação orgânica de análise de forma e análise de dinâmica.
A lógica central da estratégia inclui duas partes principais: reconhecimento de forma triangular e confirmação de dinâmica RSI. Primeiro, o método de regressão linear é usado para calcular os altos e baixos dos últimos N ciclos, construindo uma linha de tendência ascendente para formar um triângulo. Quando o preço quebra a linha de tendência e o RSI é maior que 50, a ação de múltiplos sinais é acionada; Quando o preço quebra a linha de tendência e o RSI é menor que 50, a ação de sinais de vazio é acionada.
A estratégia de ruptura triangular combinada com a dinâmica do RSI é um sistema de negociação quantitativa com estrutura completa e lógica clara. O mecanismo de dupla confirmação de forma e dinâmica aumenta efetivamente a confiabilidade do sinal de negociação. Embora haja algum risco, a estratégia tem um bom valor prático através de medidas razoáveis de otimização de parâmetros e controle de risco.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-04 00:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Triangle Breakout with RSI", overlay=true)
// Input parameters
len = input.int(15, title="Triangle Length")
rsiPeriod = input.int(14, title="RSI Period")
rsiThresholdBuy = input.int(50, title="RSI Threshold for Buy")
rsiThresholdSell = input.int(50, title="RSI Threshold for Sell")
// Calculate the RSI
rsi = ta.rsi(close, rsiPeriod)
// Calculate highest high and lowest low for triangle pattern
highLevel = ta.highest(high, len)
lowLevel = ta.lowest(low, len)
// Create trendlines for the triangle
upperTrend = ta.linreg(high, len, 0)
lowerTrend = ta.linreg(low, len, 0)
// Plot the trendlines on the chart
plot(upperTrend, color=color.green, linewidth=2, title="Upper Trendline")
plot(lowerTrend, color=color.red, linewidth=2, title="Lower Trendline")
// Detect breakout conditions
breakoutUp = close > upperTrend
breakoutDown = close < lowerTrend
// Confirm breakout with RSI
buyCondition = breakoutUp and rsi > rsiThresholdBuy
sellCondition = breakoutDown and rsi < rsiThresholdSell
// Plot breakout signals with confirmation from RSI
plotshape(series=buyCondition, title="Buy Signal", location=location.belowbar, color=color.green, style=shape.labelup, size=size.small)
plotshape(series=sellCondition, title="Sell Signal", location=location.abovebar, color=color.red, style=shape.labeldown, size=size.small)
// Strategy: Buy when triangle breaks upwards and RSI is above 50; Sell when triangle breaks downwards and RSI is below 50
if (buyCondition)
strategy.entry("Buy", strategy.long)
if (sellCondition)
strategy.entry("Sell", strategy.short)
// Plot RSI on the bottom pane
hline(50, "RSI 50 Level", color=color.gray, linestyle=hline.style_dotted)
plot(rsi, color=color.blue, linewidth=2, title="RSI")