Diese Strategie ist ein umfassendes Handelssystem, das mehrere technische Indikatoren einschließlich Bollinger Bands, Fibonacci Retracement, MACD und RSI kombiniert. Die Strategie erfasst Handelschancen unter verschiedenen Marktbedingungen durch Multi-Indikator-Koordination und wendet die maximale Profit-Take-Profit-Methode zur Risikokontrolle an. Das System hat ein modulares Design mit flexiblen Indikatorparametern, das eine starke Anpassungsfähigkeit und Praktikabilität bietet.
Die Strategie verwendet vier Haupttechnische Indikatoren, um Handelssignale zu erzeugen: 1. Bollinger-Band-Signale: Preisbruch unterhalb des unteren Bandes erzeugt lange Signale, Bruch über dem oberen Band erzeugt kurze Signale 2. Fibonacci-Signale: Der Preis im Bereich von 0-23,6% erzeugt lange Signale, im Bereich von 61,8-100% erzeugt kurze Signale 3. MACD-Signale: Das Überqueren der MACD-Linie über der Signallinie erzeugt lange Signale, das Überqueren darunter erzeugt kurze Signale 4. RSI-Signale: RSI unter dem überverkauften Niveau erzeugt lange Signale, über dem überkauften Niveau erzeugt kurze Signale Der Handel beginnt, wenn ein Indikator ein Signal erzeugt. Die Strategie wendet auch eine maximale Profit-Take-Profit-Methode an, die automatisch Positionen schließt, wenn vorgegebene Gewinnziele oder Stop-Loss-Level erreicht werden.
Diese Strategie erreicht die Handelseffizienz, während sie durch die Multi-Indikator-Koordination die Stabilität aufrechterhält. Trotz bestimmter Risiken hat sie durch eine angemessene Risikokontrolle und kontinuierliche Optimierung einen praktischen Wert.
/*backtest start: 2024-12-04 00:00:00 end: 2024-12-11 00:00:00 period: 2h basePeriod: 2h exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=5 strategy("Demo GPT Bollinger, Fibonacci, MACD & RSI with Max Profit Exit", overlay=true) // === User Inputs for Bollinger Bands === length_bb = input.int(20, minval=1, title="Bollinger Bands Length") maType_bb = input.string("SMA", title="Bollinger Bands MA Type", options=["SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"]) src_bb = input(close, title="Bollinger Bands Source") mult_bb = input.float(2.0, minval=0.001, maxval=50, title="Bollinger Bands StdDev") offset_bb = input.int(0, title="Bollinger Bands Offset", minval=-500, maxval=500) // === User Inputs for Fibonacci Levels === lookback_fib = input.int(50, minval=1, title="Fibonacci Lookback Period") // === User Inputs for MACD === macd_fast = input.int(12, minval=1, title="MACD Fast Length") macd_slow = input.int(26, minval=1, title="MACD Slow Length") macd_signal = input.int(9, minval=1, title="MACD Signal Length") // === User Inputs for RSI === rsi_length = input.int(14, title="RSI Length") rsi_overbought = input.int(70, title="RSI Overbought Level") rsi_oversold = input.int(30, title="RSI Oversold Level") // === Start and End Date Inputs === start_date = input(timestamp("2023-01-01 00:00:00"), title="Start Date") end_date = input(timestamp("2069-12-31 23:59:59"), title="End Date") // === Moving Average Function === ma(source, length, _type) => switch _type "SMA" => 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) // === Bollinger Bands Calculation === basis_bb = ma(src_bb, length_bb, maType_bb) dev_bb = mult_bb * ta.stdev(src_bb, length_bb) upper_bb = basis_bb + dev_bb lower_bb = basis_bb - dev_bb // === Fibonacci Levels Calculation === highest_price = ta.highest(high, lookback_fib) lowest_price = ta.lowest(low, lookback_fib) fib_0 = lowest_price fib_23 = lowest_price + 0.236 * (highest_price - lowest_price) fib_38 = lowest_price + 0.382 * (highest_price - lowest_price) fib_50 = lowest_price + 0.5 * (highest_price - lowest_price) fib_61 = lowest_price + 0.618 * (highest_price - lowest_price) fib_100 = highest_price // === MACD Calculation === [macd_line, signal_line, _] = ta.macd(close, macd_fast, macd_slow, macd_signal) // === RSI Calculation === rsi = ta.rsi(close, rsi_length) // === Plotting for Reference === plot(basis_bb, "Bollinger Basis", color=color.blue, offset=offset_bb) p1_bb = plot(upper_bb, "Bollinger Upper", color=color.red, offset=offset_bb) p2_bb = plot(lower_bb, "Bollinger Lower", color=color.green, offset=offset_bb) fill(p1_bb, p2_bb, title="Bollinger Bands Background", color=color.rgb(33, 150, 243, 95)) plot(fib_0, "Fib 0%", color=color.gray) plot(fib_23, "Fib 23.6%", color=color.yellow) plot(fib_38, "Fib 38.2%", color=color.orange) plot(fib_50, "Fib 50%", color=color.blue) plot(fib_61, "Fib 61.8%", color=color.green) plot(fib_100, "Fib 100%", color=color.red) hline(0, "MACD Zero Line", color=color.gray) plot(macd_line, "MACD Line", color=color.blue) plot(signal_line, "Signal Line", color=color.orange) hline(rsi_overbought, "RSI Overbought", color=color.red) hline(rsi_oversold, "RSI Oversold", color=color.green) plot(rsi, "RSI", color=color.blue) // === Combined Trading Logic === // Bollinger Bands Signals long_bb = ta.crossover(close, lower_bb) short_bb = ta.crossunder(close, upper_bb) // Fibonacci Signals long_fib = close <= fib_23 and close >= fib_0 short_fib = close >= fib_61 and close <= fib_100 // MACD Signals long_macd = ta.crossover(macd_line, signal_line) short_macd = ta.crossunder(macd_line, signal_line) // RSI Signals long_rsi = rsi < rsi_oversold short_rsi = rsi > rsi_overbought // Combined Long and Short Conditions long_condition = (long_bb or long_fib or long_macd or long_rsi) short_condition = (short_bb or short_fib or short_macd or short_rsi) // === Max Profit Exit Logic === // Define the maximum profit exit percentage take_profit_percentage = input.float(5.0, title="Take Profit (%)", minval=0.1, maxval=100) / 100 stop_loss_percentage = input.float(2.0, title="Stop Loss (%)", minval=0.1, maxval=100) / 100 // Track the highest price during the trade var float max_profit_price = na if (strategy.opentrades > 0) max_profit_price := na(max_profit_price) ? strategy.opentrades.entry_price(0) : math.max(max_profit_price, high) // Calculate the take profit and stop loss levels based on the max profit price take_profit_level = max_profit_price * (1 + take_profit_percentage) stop_loss_level = max_profit_price * (1 - stop_loss_percentage) // Exit the trade if the take profit or stop loss level is hit if (strategy.opentrades > 0) if (close >= take_profit_level) strategy.exit("Take Profit", from_entry="Long", limit=take_profit_level) if (close <= stop_loss_level) strategy.exit("Stop Loss", from_entry="Long", stop=stop_loss_level) if (strategy.opentrades > 0) if (close <= take_profit_level) strategy.exit("Take Profit", from_entry="Short", limit=take_profit_level) if (close >= stop_loss_level) strategy.exit("Stop Loss", from_entry="Short", stop=stop_loss_level) // === Execute Trades === if (long_condition) strategy.entry("Long", strategy.long, when=not na(long_condition)) if (short_condition) strategy.entry("Short", strategy.short, when=not na(short_condition))