
A estratégia é um sistema de negociação de acompanhamento de tendências que combina a linha de dupla média e o indicador RSI aleatório. A estratégia determina a tendência do mercado através de uma média móvel simples de 21 e 55 períodos, usando o RSI aleatório para encontrar os melhores pontos de entrada e saída entre os supermercados e os supermercados, otimizando a negociação de tendências.
A estratégia segue a seguinte lógica central:
A estratégia, combinando indicadores técnicos clássicos, constrói um sistema de negociação de acompanhamento de tendências completo. A estratégia, mantendo-se simples e intuitiva, aumenta a confiabilidade através da confirmação de múltiplos sinais. Com a otimização razoável dos parâmetros e o gerenciamento de risco, a estratégia tem um bom valor prático.
/*backtest
start: 2022-02-11 00:00:00
end: 2025-02-08 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=6
strategy("SMA & Stoch RSI Buy Strategy with K > 80 Exit", overlay=true)
// Input parameters for the SMAs
sma21Length = input(21, title="21 SMA Length")
sma55Length = input(55, title="55 SMA Length")
// Input parameters for the Stochastic RSI
stochRsiLength = input(14, title="Stoch RSI Length")
stochRsiK = input(3, title="Stoch RSI %K Smoothing")
stochRsiD = input(3, title="Stoch RSI %D Smoothing")
// Calculate the SMAs
sma21 = ta.sma(close, sma21Length)
sma55 = ta.sma(close, sma55Length)
// Calculate the Stochastic RSI
rsiValue = ta.rsi(close, stochRsiLength)
stochRsi = ta.stoch(rsiValue, rsiValue, rsiValue, stochRsiLength)
stochRsiKLine = ta.sma(stochRsi, stochRsiK)
stochRsiDLine = ta.sma(stochRsiKLine, stochRsiD)
// Buy signal conditions
smaCondition = sma21 > sma55
stochRsiCondition = ta.crossover(stochRsiKLine, stochRsiDLine) and stochRsiKLine < 20
// Entry condition
buySignal = smaCondition and stochRsiCondition
// Exit condition: Stochastic RSI K > 80 and K crosses below D
exitCondition = ta.crossunder(stochRsiKLine, stochRsiDLine) and stochRsiKLine > 80
// Execute buy order on signal
if (buySignal)
strategy.entry("Buy", strategy.long)
// Exit the trade on the modified exit condition
if (exitCondition)
strategy.close("Buy")
// Plot the SMAs
plot(sma21, color=color.blue, title="21 SMA")
plot(sma55, color=color.red, title="55 SMA")
// Plot Stochastic RSI for reference (not overlayed)
hline(20, "Stoch RSI 20", color=color.gray, linestyle=hline.style_dotted)
hline(80, "Stoch RSI 80", color=color.gray, linestyle=hline.style_dotted)
plot(stochRsiKLine, title="%K Line", color=color.green)
plot(stochRsiDLine, title="%D Line", color=color.red)