
Es handelt sich um eine auf Zeitzyklen basierende intelligente Rotationsstrategie, die durch Multi-Float-Rotationsgeschäfte in einem bestimmten Zeitraum Gewinne erzielt. Die Strategie verwendet eine flexible Positionsverwaltungsmechanik, die die Handelsrichtung automatisch an die Marktumgebung anpasst, und verfügt über eine Risikokontrolle. Die Strategie unterstützt Multi-Float-Zweise-Handel und kann optional ein Swing-Handelsmodus einleiten, der eine starke Anpassungsfähigkeit bietet.
Die Strategie steuert den Handel hauptsächlich über die Zeitspanne und den Positionszustand. Zuerst wird durch die Funktion inActivePeriod () festgestellt, ob der Handel innerhalb des gültigen Handelsbereichs der letzten 500 K-Linien liegt. In der gültigen Zeitspanne entscheidet die Strategie über den Handel nach Variablen wie Positionszustand (PositionHeld), Positionszeit (BarsHeld) und Pausezeit (BarsPaused). Wenn der Swing-Trading-Modus aktiviert ist, bewegt sich die Strategie schnell in mehrräumige Richtungen.
Die Strategie nutzt die Zeit-Zyklus-Kontrolle und Multi-Zyklus-Rotation, um die Markterträge zu erzielen. Sie ist flexibel und anpassungsfähig. Obwohl einige Risiken bestehen, kann die Stabilität und Profitabilität der Strategie durch angemessene Optimierungs- und Risikokontrollmaßnahmen deutlich verbessert werden.
/*backtest
start: 2024-10-12 00:00:00
end: 2024-11-11 00:00:00
period: 4h
basePeriod: 4h
exchanges: [{"eid":"Futures_Binance","currency":"BTC_USDT"}]
*/
//@version=5
strategy("Tickerly Test Strategy", overlay=true)
// Inputs
longEnabled = input.bool(true, "Enable Long Trades")
shortEnabled = input.bool(true, "Enable Short Trades")
swingEnabled = input.bool(false, "Enable Swing Trading")
// Variables
var positionHeld = 0
var barsHeld = 0
var barsPaused = 0
var lastAction = "none"
// Function to determine if we're in the last 500 bars
inActivePeriod() =>
barIndex = bar_index
lastBarIndex = last_bar_index
barIndex >= (lastBarIndex - 499)
// Main strategy logic
if inActivePeriod()
if swingEnabled
if positionHeld == 0 and barstate.isconfirmed
if lastAction != "long"
strategy.entry("Long", strategy.long)
positionHeld := 1
barsHeld := 0
lastAction := "long"
else
strategy.entry("Short", strategy.short)
positionHeld := -1
barsHeld := 0
lastAction := "short"
if positionHeld != 0
barsHeld += 1
if barsHeld >= 2
if positionHeld == 1
strategy.entry("Short", strategy.short)
positionHeld := -1
barsHeld := 0
lastAction := "short"
else
strategy.entry("Long", strategy.long)
positionHeld := 1
barsHeld := 0
lastAction := "long"
else
if positionHeld == 0 and barsPaused >= 1 and barstate.isconfirmed
if longEnabled and shortEnabled
if lastAction != "long"
strategy.entry("Long", strategy.long)
positionHeld := 1
barsHeld := 0
barsPaused := 0
lastAction := "long"
else
strategy.entry("Short", strategy.short)
positionHeld := -1
barsHeld := 0
barsPaused := 0
lastAction := "short"
else if longEnabled
strategy.entry("Long", strategy.long)
positionHeld := 1
barsHeld := 0
barsPaused := 0
lastAction := "long"
else if shortEnabled
strategy.entry("Short", strategy.short)
positionHeld := -1
barsHeld := 0
barsPaused := 0
lastAction := "short"
if positionHeld != 0
barsHeld += 1
if barsHeld >= 3
strategy.close_all()
positionHeld := 0
barsHeld := 0
barsPaused := 0 // Reset pause counter when exiting a position
else
barsPaused += 1
// Plotting active period for visual confirmation
plot(inActivePeriod() ? 1 : 0, "Active Period", color=color.new(color.blue, 80), style=plot.style_areabr)