Die Strategie stützt sich hauptsächlich auf zwei Indikatoren, um Ein- und Ausstiegssignale zu bestimmen - die höchste Funktion, die den höchsten Preis über einen bestimmten Zeitraum bestimmt, und die niedrigste Funktion, die den niedrigsten Preis über einen bestimmten Zeitraum bestimmt.
Zusammenfassend ist dies eine typische Trend-Tracking-Breakout-Strategie. Sie tritt ein, wenn ein Breakout eingetreten ist, sperrt Gewinne und verfolgt Trends durch Stop-Loss und geht aus, wenn sich der Trend umkehrt.
Die wichtigsten Vorteile dieser Strategie sind:
Die wichtigsten Risiken dieser Strategie sind:
Die wichtigsten Lösungen sind:
Die wichtigsten Optimierungsrichtungen für diese Strategie sind:
Zusätzlich zu den höchsten/niedrigsten Preisen können auch Indikatoren wie gleitende Durchschnitte hinzugefügt werden, um die Trendbestimmung genauer zu machen.
Optimieren Sie die Parameter-Einstellungen. Testen und finden Sie die optimalen Kombinationen für Parameter wie höchste/niedrigste Preiszyklen, Stop-Loss-Multiplikatorfaktoren usw.
Optimieren Sie den Stop-Loss-Mechanismus. Testen Sie verschiedene Zusammensetzungen von beweglichen und festen Stop-Losses, um Stop-Losses weniger aggressiv zu machen.
Natürlich ist es als Breakout-Strategie stark auf Trendbeurteilung angewiesen und anfällig für Marktlärmstörungen. Schlechte Parameter-Tuning könnte auch die Leistung untergraben. Weitere Optimierungen sind erforderlich, um diese Probleme zu beheben.
/*backtest start: 2023-12-01 00:00:00 end: 2023-12-31 23:59:59 period: 1h basePeriod: 15m exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}] */ //@version=4 strategy(shorttitle="Trend Surfers - Breakout", title="Trend Surfers - Premium Breakout", overlay=true) // Risk for position and pyramid maxriskval = input(2, "Max % risk", type = input.float, tooltip="Risk % over total equity / Position", group = "Risk Management") pairnumber = input(title = "How many pairs",type = input.integer, defval= 1, tooltip="How many pairs are you trading with the strategy?", group = "Risk Management") // Emtry Exit highPeriod = input(title="Highest High Period", type=input.integer, defval=168 , tooltip="Highest High of X bars - This will trigger a Long Entry when close is above. (Thin Green Line)" , group = "Entry Condition") lowPeriod = input(title="Lowest Low Period", type=input.integer, defval=168, tooltip="Lowest low of X bars - This will trigger a Short Entry when close is under. (Thin Red Line)" , group = "Entry Condition") // Stoploss trailingAtrPeriod = input(title="Trailing ATR Pediod", type=input.integer, defval=10, tooltip="Average True Range for the Trailing Stop. (Thick Green Line) " , group = "Exit Condition") trailingAtrMultiplier = input(title="Trailing ATR Multiplier", type=input.float, defval=8 , group = "Exit Condition") fixAtrPeriod = input(title="Fix ATR Pediod", type=input.integer, defval=10, tooltip="Average True Range for the Fix Stoloss. (Thick Yellow Line)" , group = "Exit Condition") fixAtrMultiplier = input(title="Fix ATR Multiplier", type=input.float, defval=2 , group = "Exit Condition") // Pair info pair = syminfo.basecurrency + syminfo.currency // High Low Variable highestHigh = highest(high, highPeriod)[1] lowestLow = lowest(low, lowPeriod)[1] trailingAtr = atr(trailingAtrPeriod) * trailingAtrMultiplier // Trade Condition longCondition = crossover(close, highestHigh) shortCondition = crossunder(close, lowestLow) // Risk Variable fixAtr = atr(fixAtrPeriod) * fixAtrMultiplier stopvaluelong = close[1] - fixAtr[1] stopvalueshort = close[1] + fixAtr[1] // Position size Long maxpossize = strategy.equity / close positionsizelong = ( ( ( (maxriskval/100) * strategy.equity) / (close - stopvaluelong))) stopperclong = ((close - stopvaluelong) / close) * 100 leveragelong = max(1, ceil(positionsizelong / maxpossize)) * 2 posperclong = (((positionsizelong * close) / strategy.equity) *100 / leveragelong) / pairnumber realposlong = (((posperclong / 100) * strategy.equity) * leveragelong) / close // Position size Short positionsizeshort = ( ( ( (maxriskval/100) * strategy.equity) / (stopvalueshort - close))) stoppercshort = ((close - stopvalueshort) / close) * 100 leverageshort = max(1, ceil(positionsizeshort / maxpossize)) * 2 pospercshort = (((positionsizeshort * close) / strategy.equity) *100 / leverageshort) / pairnumber realposshort = (((pospercshort / 100) * strategy.equity) * leverageshort) / close // Alert Message entry_long_message = '\nGo Long for ' + pair + 'NOW!' + '\nPosition Size % =' + tostring(posperclong) + '\nLeverage' + tostring(leveragelong) + '\nStoploss Price =' + tostring(stopvaluelong) + '\nClose any Short position that are open for ' + pair + '!' + '\n\nVisit TrendSurfersSignals.com' + '\nFor automated premium signals (FREE)' entry_short_message ='\nGo Short for ' + pair + 'NOW!' + '\nPosition Size % =' + tostring(pospercshort) + '\nLeverage' + tostring(leverageshort) + '\nStoploss Price =' + tostring(stopvalueshort) + '\nClose any Long position that are open for ' + pair + '!' + '\n\nVisit TrendSurfersSignals.com' + '\nFor automated premium signals (FREE)' exit_short_message = '\nExit Short for ' + pair + 'NOW!' + '\n\nVisit TrendSurfersSignals.com' + '\nFor automated premium signals (FREE)' exit_long_message = '\nExit Long for ' + pair + 'NOW!' + '\n\nVisit TrendSurfersSignals.com' + '\nFor automated premium signals (FREE)' // Order if longCondition strategy.entry("Long", strategy.long, stop=highestHigh, comment="Long", qty=realposlong , alert_message = entry_long_message) if shortCondition strategy.entry("Short", strategy.short, stop=lowestLow, comment="Short", qty=realposshort , alert_message = entry_short_message) // Stoploss Trailing longTrailing = close - trailingAtr shortTrailing = close + trailingAtr var longTrailingStop = 0.0 var shortTrailingStop = 999999.9 trailingStopLine = 0.0 trailingStopLine := na fixedStopLine = 0.0 fixedStopLine := na var inTrade = 0 if longCondition or shortCondition if 0 == inTrade if longCondition inTrade := 1 else inTrade := -1 if 1 == inTrade and (shortCondition or low <= max(fixedStopLine[1], longTrailingStop)) inTrade := 0 if -1 == inTrade and (longCondition or high >= min(fixedStopLine[1], shortTrailingStop)) inTrade := 0 longTrailingStop := if (1 == inTrade) stopValue = longTrailing max(stopValue, longTrailingStop[1]) else 0 shortTrailingStop := if (-1 == inTrade) stopValue = shortTrailing min(stopValue, shortTrailingStop[1]) else 999999 // Fix Stoploss firstPrice = 0.0 firstFixAtr = 0.0 firstPrice := na firstFixAtr := na if 0 != inTrade firstPrice := valuewhen(inTrade != inTrade[1] and 0 != inTrade, close, 0) firstFixAtr := valuewhen(inTrade != inTrade[1] and 0 != inTrade, fixAtr, 0) if 1 == inTrade fixedStopLine := firstPrice - firstFixAtr trailingStopLine := longTrailingStop else fixedStopLine := firstPrice + firstFixAtr trailingStopLine := shortTrailingStop if (strategy.position_size > 0) strategy.exit(id="L Stop", stop=max(fixedStopLine, longTrailingStop) , alert_message = exit_long_message) if (strategy.position_size < 0) strategy.exit(id="S Stop", stop=min(fixedStopLine, shortTrailingStop) , alert_message = exit_long_message) // Plot plot(highestHigh, color=color.green, linewidth=1, transp=0, title='Highest High') plot(lowestLow, color=color.red, linewidth=1, transp=0, title='Lowest Low') plot(trailingStopLine, color=color.lime, linewidth=2, transp=0, offset=1, title='Trailing Stop') plot(fixedStopLine, color=color.orange, linewidth=2, transp=0, offset=1, title='Fixed Stop')