
Die Pine Script-Strategie basiert auf dem relativ starken Index RSI und der Standarddifferenz DEV der Preisfluktuation, um den Einstiegspunkt zu beurteilen, indem sie den Preis mit dem oberen und unteren Kurs verglichen wird. Die RSI wird als Hilfsfilter verwendet, um ein Positionseingangssignal zu erzeugen, wenn der Preis den oberen und unteren Kurs erreicht und der RSI die Überkauf-Überverkauf-Bereich erreicht.
Die Strategie, die durch die Kombination von Volatilitätskanal und relativ starken Index, in Bezug auf die RSI-Indikator, während der Preis-Wochel, um die Position zu eröffnen, kann besser zu erfassen, die phasische Trend, die Zeit zu stoppen und zu gewinnen. Die Strategie ist jedoch die Performance der Parameter-Setting ist empfindlich, die für verschiedene Marktumgebung und das Ziel der Vermögenswerte optimiert werden müssen, während die Einführung von anderen Indikatoren zu berücksichtigen, um die Markttrends zu unterstützen, um die Vorteile der Strategie zu nutzen.
/*backtest
start: 2024-05-20 00:00:00
end: 2024-05-27 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Binance","currency":"BTC_USDT"}]
*/
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tmalvao
//@version=5
strategy("Estratégia de Desvio Padrão com RSI", overlay=true, margin_long=100, margin_short=100)
// Parâmetros
length = input.int(20, title="Período do Desvio Padrão")
thresholdEntry = input.float(1.5, title="Limite de Entrada")
thresholdExit = input.float(0.5, title="Limite de Saída")
rsiLength = input.int(14, title="Período do RSI")
rsiOverbought = input.int(70, title="RSI Overbought")
rsiOversold = input.int(30, title="RSI Oversold")
// Cálculo do Desvio Padrão
price = close
stdDev = ta.stdev(price, length)
// Média Móvel Simples
sma = ta.sma(price, length)
// Limites baseados no Desvio Padrão
upperLimit = sma + thresholdEntry * stdDev
lowerLimit = sma - thresholdEntry * stdDev
exitUpperLimit = sma + thresholdExit * stdDev
exitLowerLimit = sma - thresholdExit * stdDev
// Cálculo do RSI
rsi = ta.rsi(price, rsiLength)
// Condições de Entrada com RSI
longCondition = ta.crossover(price, lowerLimit) and rsi < rsiOversold
shortCondition = ta.crossunder(price, upperLimit) and rsi > rsiOverbought
// Condições de Saída com RSI
exitLongCondition = ta.crossunder(price, exitLowerLimit) or rsi > rsiOverbought
exitShortCondition = ta.crossover(price, exitUpperLimit) or rsi < rsiOversold
// Plotar Linhas
plot(upperLimit, color=color.red, title="Limite Superior")
plot(lowerLimit, color=color.green, title="Limite Inferior")
plot(exitUpperLimit, color=color.orange, title="Limite de Saída Superior")
plot(exitLowerLimit, color=color.blue, title="Limite de Saída Inferior")
plot(sma, color=color.gray, title="SMA")
hline(rsiOverbought, "RSI Overbought", color=color.red)
hline(rsiOversold, "RSI Oversold", color=color.green)
plot(rsi, title="RSI", color=color.purple)
// Estratégia de Trade
if (longCondition)
strategy.entry("Long", strategy.long)
if (shortCondition)
strategy.entry("Short", strategy.short)
if (exitLongCondition)
strategy.close("Long")
if (exitShortCondition)
strategy.close("Short")