Isolationsband-Oszillationsverfolgungsstrategie

Schriftsteller:ChaoZhang, Datum: 2024-02-04 10:28:24
Tags:

img

Übersicht

Die Hauptidee dieser Strategie besteht darin, die langen und kurzen Stop-Loss-Linien basierend auf dem ATR-Indikator zu berechnen.

Strategieprinzip

Die Strategie verwendet die N-Perioden-ATR multipliziert mit einem Koeffizienten zur Berechnung der langen und kurzen Stop-Loss-Linien.

Long Stop = Highest Price - ATR * Coefficient 
Short Stop = Lowest Price + ATR * Coefficient

Es geht lang, wenn der Preis steigt und durch die lange Stop-Loss-Linie bricht, und geht kurz, wenn der Preis fällt und durch die kurze Stop-Loss-Linie bricht.

Durch die Verwendung des ATR-Bandes als Stop-Loss-Level kann diese Methode den Preistrend vollständig erfassen und gleichzeitig das Stop-Loss-Risiko gewährleisten.

Analyse der Vorteile

Der größte Vorteil dieser Strategie besteht darin, dass sie die Stop-Loss-Ebene automatisch anpassen kann, um Preistrends zu erfassen und gleichzeitig Risiken zu kontrollieren.

  1. Der auf dem ATR-Indikator basierende schwebende Stop-Loss kann den Stop-Loss-Bereich entsprechend der Marktvolatilität anpassen, um einen einzelnen Verlust wirksam zu kontrollieren.

  2. Durch die Einführung einer bahnbrechenden Methode zur Erzeugung von Signalen kann man Geräusche ausfiltern und Höhen und Tiefen vermeiden.

  3. Die Echtzeitanpassung der Stop-Loss-Linien zur Verfolgung von Kursschwankungen verhindert, dass der Stop-Loss zu locker ist und mehr Gewinne erzielt.

Risikoanalyse

Die Strategie birgt auch einige Risiken, die sich hauptsächlich auf die Festlegung des Stop-Loss-Niveaus und die Signalgenerierung konzentrieren.

  1. Ein unsachgemäßer ATR-Zyklus und -koeffizienten können zu einem zu breiten oder zu engen Stop-Loss führen.

  2. Die Durchbruchssignalmethode kann frühe Trendchancen verpassen.

  3. Es kann eine gewisse Verzögerung bei der Stop-Loss-Verfolgung während des Trendendens geben, ohne dass ein perfekter Ausgang möglich ist.

Die Gegenmaßnahmen zielen hauptsächlich darauf ab, die Parameter anzupassen, um den Stop-Loss vernünftiger zu machen, oder mit anderen Indikatoren zu helfen, den Trend und die Signale zu bestimmen.

Optimierungsrichtlinien

Die Strategie kann in folgenden Bereichen weiter optimiert werden:

  1. Einrichtung eines Stop-Loss-Systems der zweiten Schicht zur weiteren Kontrolle der Risiken.

  2. Kombination anderer Indikatoren zur Bestimmung des Trends und Verbesserung der Signalqualität.

  3. Fügen Sie bewegliche Stop-Profit-Strategien hinzu, um den Gewinn zu erhöhen, wenn sich der Trend weiter fortsetzt.

  4. Optimierung des ATR-Zyklus und der Koeffizientenparameter, um den Stop-Loss näher an die tatsächlichen Kursschwankungen zu bringen.

Zusammenfassung

Insgesamt ist diese Strategie sehr praktisch. Sie kann Risiken effektiv kontrollieren, indem sie automatisch den Stop-Loss-Level anpasst und gleichzeitig durch Trendverfolgung gute Gewinne erzielt. Wir können die Strategie weiter optimieren und verbessern, indem wir andere analytische Methoden auf der bestehenden Basis kombinieren, um sie stabiler und intelligenter zu machen.


/*backtest
start: 2024-01-04 00:00:00
end: 2024-02-03 00:00:00
period: 1h
basePeriod: 15m
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © melihtuna
//@version=4
strategy("Chandelier Exit - Strategy",shorttitle="CE-STG" , overlay=true, default_qty_type=strategy.cash, default_qty_value=10000, initial_capital=10000, currency=currency.USD, commission_value=0.03, commission_type=strategy.commission.percent)

length = input(title="ATR Period", type=input.integer, defval=22)
mult = input(title="ATR Multiplier", type=input.float, step=0.1, defval=3.0)
showLabels = input(title="Show Buy/Sell Labels ?", type=input.bool, defval=false)
useClose = input(title="Use Close Price for Extremums ?", type=input.bool, defval=true)
highlightState = input(title="Highlight State ?", type=input.bool, defval=true)

atr = mult * atr(length)

longStop = (useClose ? highest(close, length) : highest(length)) - atr
longStopPrev = nz(longStop[1], longStop) 
longStop := close[1] > longStopPrev ? max(longStop, longStopPrev) : longStop

shortStop = (useClose ? lowest(close, length) : lowest(length)) + atr
shortStopPrev = nz(shortStop[1], shortStop)
shortStop := close[1] < shortStopPrev ? min(shortStop, shortStopPrev) : shortStop

var int dir = 1
dir := close > shortStopPrev ? 1 : close < longStopPrev ? -1 : dir

var color longColor = color.green
var color shortColor = color.red

longStopPlot = plot(dir == 1 ? longStop : na, title="Long Stop", style=plot.style_linebr, linewidth=2, color=longColor)
buySignal = dir == 1 and dir[1] == -1
plotshape(buySignal ? longStop : na, title="Long Stop Start", location=location.absolute, style=shape.circle, size=size.tiny, color=longColor, transp=0)
plotshape(buySignal and showLabels ? longStop : na, title="Buy Label", text="Buy", location=location.absolute, style=shape.labelup, size=size.tiny, color=longColor, textcolor=color.white, transp=0)

shortStopPlot = plot(dir == 1 ? na : shortStop, title="Short Stop", style=plot.style_linebr, linewidth=2, color=shortColor)
sellSignal = dir == -1 and dir[1] == 1
plotshape(sellSignal ? shortStop : na, title="Short Stop Start", location=location.absolute, style=shape.circle, size=size.tiny, color=shortColor, transp=0)
plotshape(sellSignal and showLabels ? shortStop : na, title="Sell Label", text="Sell", location=location.absolute, style=shape.labeldown, size=size.tiny, color=shortColor, textcolor=color.white, transp=0)

midPricePlot = plot(ohlc4, title="", style=plot.style_circles, linewidth=0, display=display.none, editable=false)

longFillColor = highlightState ? (dir == 1 ? longColor : na) : na
shortFillColor = highlightState ? (dir == -1 ? shortColor : na) : na
fill(midPricePlot, longStopPlot, title="Long State Filling", color=longFillColor)
fill(midPricePlot, shortStopPlot, title="Short State Filling", color=shortFillColor)


long_short = input(true, "Long-Short",type=input.bool, group="Strategy Settings")

start     = input(timestamp("2019-01-01"), "Date", type=input.time, group="Strategy Settings")
finish    = input(timestamp("2025-01-01"), "Date", type=input.time, group="Strategy Settings")   
window()  => true

slRatio=input(5, "Manuel Stop Loss Ratio", type=input.float, minval=0, group="Strategy Settings")
tpRatio=input(20, "Take Profit Ratio", type=input.float, minval=0, group="Strategy Settings")
tsStartRatio=input(10, "Trailing Stop Start Ratio", type=input.float, minval=0, group="Strategy Settings")
tsRatio=input(5, "Trailing Stop Ratio", type=input.float, minval=1, group="Strategy Settings")

lastBuyPrice = strategy.position_avg_price

diffHiPriceRatio = (high-lastBuyPrice)/lastBuyPrice*100
diffLoPriceRatio = (close-lastBuyPrice)/lastBuyPrice*100
posHiRatio=0.0
posHiRatio:= strategy.position_size > 0 ? diffHiPriceRatio > posHiRatio[1] ? diffHiPriceRatio : posHiRatio[1] : 0

s_diffHiPriceRatio = (low-lastBuyPrice)/lastBuyPrice*100
s_diffLoPriceRatio = (close-lastBuyPrice)/lastBuyPrice*100
s_posHiRatio=0.0
s_posHiRatio:= strategy.position_size < 0 ? s_diffLoPriceRatio < s_posHiRatio[1] ? s_diffLoPriceRatio : s_posHiRatio[1] : 0

strategy.entry("LONG", strategy.long, when = window() and buySignal)
strategy.close("LONG", when = window() and sellSignal)
strategy.close("LONG", when = diffLoPriceRatio<(slRatio*(-1)), comment="STOP-LONG")
strategy.close("LONG", when = diffHiPriceRatio>tpRatio, comment="TAKE-PROFIT-LONG")
strategy.close("LONG", when = ((posHiRatio[1]>tsStartRatio) and (posHiRatio[1]-diffHiPriceRatio)>tsRatio), comment="TRAILING-STOP-LONG")

if long_short
    strategy.entry("SHORT", strategy.short, when = window() and sellSignal)
    strategy.close("SHORT", when = window() and buySignal)
    strategy.close("SHORT", when = s_diffLoPriceRatio>(slRatio), comment="STOP-SHORT")
    strategy.close("SHORT", when = s_diffHiPriceRatio<(tpRatio*(-1)), comment="TAKE-PROFIT-SHORT")
    strategy.close("SHORT", when = ((s_posHiRatio[1]*(-1)>tsStartRatio) and ((s_posHiRatio[1]-s_diffLoPriceRatio))*(-1)>tsRatio), comment="TRAILING-STOP-SHORT")

Mehr