
Die Strategie ist ein intelligentes Handelssystem, das auf einem relativ schwachen Index (RSI) basiert und mehrere Moving Averages und Bollinger Bands kombiniert, um durch die Identifizierung von überkauften und überverkauften Marktzonen zu handeln. Der Kern der Strategie ist die Trendbestätigung durch RSI-Break- und Rückschlagsignale in Kombination mit verschiedenen Arten von Moving Averages, um eine effiziente Bandbreite zu erreichen.
Die Strategie verwendet den 14-Zyklus-RSI als Kernindikator, um Handelssignale zu erzeugen, indem sie die Kreuzung von RSI und den beiden Schlüsselniveaus 30⁄70 überwacht. Wenn der RSI aufwärts 30 überschreitet, wird der Markt von einem Überverkauf zu einem Beobachtungsschlag beurteilt und ein Mehrfachsignal ausgelöst.
Die Strategie erfasst Überkauf-Überverkauf-Möglichkeiten im Markt durch den RSI-Indikator, kombiniert mit mehreren technischen Indikatoren zur Signalbestätigung, hat eine bessere Praktikabilität und Zuverlässigkeit. Die Strategie wurde mit voller Berücksichtigung der Risikokontrolle konzipiert und kann an verschiedene Marktumgebungen durch Parameteroptimierung und Indikatorkombinationen angepasst werden.
/*backtest
start: 2019-12-23 08:00:00
end: 2024-12-10 08:00:00
period: 1d
basePeriod: 1d
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy(title="Demo GPT - Relative Strength Index", shorttitle="RSI Strategy", overlay=false, default_qty_type=strategy.percent_of_equity, default_qty_value=100, commission_value=0.1, slippage=3)
// Inputs
rsiLengthInput = input.int(14, minval=1, title="RSI Length", group="RSI Settings")
rsiSourceInput = input.source(close, "Source", group="RSI Settings")
calculateDivergence = input.bool(false, title="Calculate Divergence", group="RSI Settings", tooltip="Calculating divergences is needed in order for divergence alerts to fire.")
// RSI Calculation
change = ta.change(rsiSourceInput)
up = ta.rma(math.max(change, 0), rsiLengthInput)
down = ta.rma(-math.min(change, 0), rsiLengthInput)
rsi = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
// RSI Plots
rsiPlot = plot(rsi, "RSI", color=#7E57C2)
rsiUpperBand = hline(70, "RSI Upper Band", color=#787B86)
midline = hline(50, "RSI Middle Band", color=color.new(#787B86, 50))
rsiLowerBand = hline(30, "RSI Lower Band", color=#787B86)
fill(rsiUpperBand, rsiLowerBand, color=color.rgb(126, 87, 194, 90), title="RSI Background Fill")
plot(50, color=na, editable=false, display=display.none)
// Moving Averages
maTypeInput = input.string("SMA", "Type", options=["None", "SMA", "SMA + Bollinger Bands", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group="Moving Average")
maLengthInput = input.int(14, "Length", group="Moving Average")
bbMultInput = input.float(2.0, "BB StdDev", minval=0.001, maxval=50, step=0.5, group="Moving Average")
enableMA = maTypeInput != "None"
isBB = maTypeInput == "SMA + Bollinger Bands"
// MA Calculation
ma(source, length, MAtype) =>
switch MAtype
"SMA" => ta.sma(source, length)
"SMA + Bollinger Bands" => ta.sma(source, length)
"EMA" => ta.ema(source, length)
"SMMA (RMA)" => ta.rma(source, length)
"WMA" => ta.wma(source, length)
"VWMA" => ta.vwma(source, length)
smoothingMA = enableMA ? ma(rsi, maLengthInput, maTypeInput) : na
smoothingStDev = isBB ? ta.stdev(rsi, maLengthInput) * bbMultInput : na
plot(smoothingMA, "RSI-based MA", color=color.yellow, display=enableMA ? display.all : display.none)
bbUpperBand = plot(smoothingMA + smoothingStDev, title="Upper Bollinger Band", color=color.green, display=isBB ? display.all : display.none)
bbLowerBand = plot(smoothingMA - smoothingStDev, title="Lower Bollinger Band", color=color.green, display=isBB ? display.all : display.none)
fill(bbUpperBand, bbLowerBand, color=isBB ? color.new(color.green, 90) : na, title="Bollinger Bands Background Fill", display=isBB ? display.all : display.none)
// Trade Logic
longCondition = ta.crossover(rsi, 30)
exitCondition = ta.crossunder(rsi, 70)
// Start Date & End Date
startDate = input(timestamp("2018-01-01 00:00"), "Start Date", group="Date Range")
endDate = input(timestamp("2069-12-31 23:59"), "End Date", group="Date Range")
inDateRange = true
// Execute Trades
if (longCondition and inDateRange)
strategy.entry("Long", strategy.long)
if (exitCondition and inDateRange)
strategy.close("Long")