1Copy the scriptPress Copy script above, or the copy button on the code below.
2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
4Add it to the chartPress Add to chart. The trades and results appear in the Strategy Tester tab; adjust the settings with the gear icon.
Source Code
122 lines of Pine Script v6 from breakout-strategie-v3.pine, published under MIT. Keep the author's credit and licence lines when you reuse it.
breakout-strategie-v3.pine
//@version=6
strategy("Ede – Breakout Strategie (mit MA und ATR Exit)", overlay=true, max_lines_count=500, max_labels_count=500)
// === MA Inputs ===
show_ma10 = input.bool(true, "MA10 anzeigen")
show_ma50 = input.bool(true, "MA50 anzeigen")
show_ma150 = input.bool(true, "MA150 anzeigen")
show_ma200 = input.bool(true, "MA200 anzeigen")
// === Breakout Settings ===
breakout_mode_str = input.string(title="Breakout-Modus", defval="Nur Gap", options=["Nur Gap", "Streng (Gap UND starke Kerze)", "Locker (Gap ODER starke Kerze)"])
// Intern in Zahlen übersetzen für die Logik
breakout_mode = breakout_mode_str == "Streng (Gap UND starke Kerze)" ? 1 : breakout_mode_str == "Locker (Gap ODER starke Kerze)" ? 2 : 3
volMultiplier = input.float(1.5, title="Volumen-Multiplikator", minval=0.5)
// === Exit Settings ===
use_stoploss = input.bool(true, title="Stop-Loss verwenden?")
stoploss_perc = input.float(3.0, title="Stop-Loss %", minval=0.1)
use_takeprofit = input.bool(true, title="Take-Profit verwenden?")
takeprofit_perc = input.float(6.0, title="Take-Profit %", minval=0.1)
exit_on_ma10 = input.bool(true, title="Exit bei MA10")
exit_on_ma50 = input.bool(false, title="Exit bei MA50")
exit_on_atr = input.bool(true, title="ATR Exit aktivieren?")
atr_period = input.int(14, title="ATR Periode", minval=1)
atr_multiplier = input.float(2.0, title="ATR Multiplikator", minval=0.1)
// NEU: ATR-Trailing-Stop exklusiv?
atr_exit_exclusive = input.bool(false, title="ATR-Trailing-Stop exklusiv (nur dieser Exit)?")
// NEU: ATR-Trailing-Stop erst ab Gewinnschwelle aktivieren (in % vom Einstieg)?
atr_trail_activation_perc = input.float(0.0, title="ATR-Trailing-Stop erst ab Gewinn (%) aktiv?", minval=0.0)
// === MA Berechnung ===
sma10 = ta.sma(close, 10)
sma50 = ta.sma(close, 50)
sma150 = ta.sma(close, 150)
sma200 = ta.sma(close, 200)
// === MA Plots mit Transparenz ===
plot(show_ma10 ? sma10 : na, color=color.new(color.blue, 40), title="MA10")
plot(show_ma50 ? sma50 : na, color=color.new(color.orange, 40), title="MA50")
plot(show_ma150 ? sma150 : na, color=color.new(color.green, 40), title="MA150")
plot(show_ma200 ? sma200 : na, color=color.new(color.red, 40), title="MA200")
// === Breakout Logik ===
avgVol = ta.sma(volume, 20)
volBreak = volume > avgVol * volMultiplier
gap = open > high[1]
body = math.abs(close - open)
candleSize = high - low
strongCandle = (close > open) and (body > candleSize * 0.5)
maTrend = sma50 > sma50[1]
candleOK = close > open
isBreakout = volBreak and (close > sma50) and (open > close) and maTrend
if breakout_mode == 1
isBreakout := isBreakout and gap and strongCandle
else if breakout_mode == 2
isBreakout := isBreakout and (gap or strongCandle)
else
isBreakout := isBreakout and gap
// === Entry & Exit Management ===
// inPosition-Variable entfernt, Positionsstatus über strategy.position_size
var float entryPrice = na
var float stopPrice = na
var float targetPrice = na
var float atrTrailStop = na
var float highestSinceEntry = na
atr = ta.atr(atr_period)
ma10Cross = ta.crossunder(close, sma10)
ma50Cross = ta.crossunder(close, sma50)
// Einstieg
if isBreakout and strategy.position_size == 0
strategy.entry("Breakout Long", strategy.long)
entryPrice := close
stopPrice := close * (1 - stoploss_perc / 100)
targetPrice := close * (1 + takeprofit_perc / 100)
highestSinceEntry := close
atrTrailStop := close - atr * atr_multiplier
// Während Position offen ist
if strategy.position_size > 0
// High seit Einstieg tracken
highestSinceEntry := na(highestSinceEntry) ? close : math.max(highestSinceEntry, high)
// ATR-Trailing-Stop berechnen
atrTrailStop := highestSinceEntry - atr * atr_multiplier
// NEU: ATR-Trailing-Stop erst ab Gewinnschwelle aktivieren
atr_trail_active = atr_trail_activation_perc == 0.0 or (close >= entryPrice * (1 + atr_trail_activation_perc / 100))
// Exits
stopHit = use_stoploss and close <= stopPrice
tpHit = use_takeprofit and close >= targetPrice
ma10Exit = exit_on_ma10 and ma10Cross
ma50Exit = exit_on_ma50 and ma50Cross
atrExit = exit_on_atr and atr_trail_active and close < atrTrailStop
// NEU: ATR-Trailing-Stop exklusiv?
if atr_exit_exclusive
if atrExit
strategy.close("Breakout Long")
entryPrice := na
stopPrice := na
targetPrice := na
highestSinceEntry := na
atrTrailStop := na
else
if stopHit or tpHit or ma10Exit or ma50Exit or atrExit
strategy.close("Breakout Long")
entryPrice := na
stopPrice := na
targetPrice := na
highestSinceEntry := na
atrTrailStop := na
// === Visuelle Darstellung ===
// Linien für Stop-Loss, Take-Profit und ATR-Trailing-Stop
plot(strategy.position_size > 0 and use_stoploss ? stopPrice : na, color=color.red, style=plot.style_linebr, linewidth=2, title="Stop-Loss")
plot(strategy.position_size > 0 and use_takeprofit ? targetPrice : na, color=color.green, style=plot.style_linebr, linewidth=2, title="Take-Profit")
plot(strategy.position_size > 0 and exit_on_atr ? atrTrailStop : na, color=color.purple, style=plot.style_linebr, linewidth=2, title="ATR-Trailing-Stop")
// Hintergrundfarbe nur, wenn Position offen (über strategy.position_size)
bgcolor(strategy.position_size > 0 ? color.new(color.green, 85) : na)
Overview
Ede - Breakout Strategie (mit MA und ATR Exit) plots the 10, 50, 150, and 200 simple moving averages directly on the price chart. Users can select between three breakout modes: gap only, strict gap with a strong candle, or loose mode requiring either. Risk management includes optional percentage-based stop-loss and take-profit targets, moving average crossunder exits, and an ATR trailing stop that can activate after reaching a designated profit threshold.
Volume-confirmed breakout entry logic
Three selectable gap and candle breakout modes
Four configurable simple moving averages
ATR-based trailing stop with profit activation threshold
Percentage-based stop-loss and take-profit targets
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
MA10 anzeigen
bool
true
show_ma10
MA50 anzeigen
bool
true
show_ma50
MA150 anzeigen
bool
true
show_ma150
MA200 anzeigen
bool
true
show_ma200
Breakout-Modus
string
Nur Gap
breakout_mode_str
Volumen-Multiplikator
float
1.5
volMultiplier
Stop-Loss verwenden?
bool
true
use_stoploss
Stop-Loss %
float
3.0
stoploss_perc
Take-Profit verwenden?
bool
true
use_takeprofit
Take-Profit %
float
6.0
takeprofit_perc
Exit bei MA10
bool
true
exit_on_ma10
Exit bei MA50
bool
false
exit_on_ma50
Show all 17 settings
Setting
Type
Default
Variable
ATR Exit aktivieren?
bool
true
exit_on_atr
ATR Periode
int
14
atr_period
ATR Multiplikator
float
2.0
atr_multiplier
ATR-Trailing-Stop exklusiv (nur dieser Exit)?
bool
false
atr_exit_exclusive
ATR-Trailing-Stop erst ab Gewinn (%) aktiv?
float
0.0
atr_trail_activation_perc
Third-party code. ForexR did not write, test or endorse this script, and the summary above was generated automatically from its code and README. Indicators describe the past, and a strategy's backtest can look better than live trading, especially when a script repaints. Check it in the Strategy Tester and on a demo account before you rely on it.
This price-chart strategy plots a simple moving average and upper and lower bands built from the standard deviation of close, scaled by separate offset inputs. It enters a fixed quantity long when close crosses above the upper band and a fixed quantity short w
This strategy runs on the price chart and enters long when a fast simple moving average crosses above a slow one, and short on the opposite cross, while closing the other side. Entries also need ATR above a filter, a pullback check, a minimum candle-body chang
This strategy trades long breakouts of a fast and a slow moving average on the price chart. It opens a long position when price crosses above either average, using a percentage of equity as size. It reduces the position by a set share when the high reaches the
This strategy plots exponential-moving-average Bollinger bands on the price chart and calculates RSI. It opens a long position when close crosses above the upper band while RSI is at or above a threshold, the date filter allows trading, and no position is open
This strategy builds Keltner-style bands around an exponential or simple moving average of the chosen source. Band width uses average true range, raw true range, or a smoothed high-low range, scaled by a multiplier. When the source crosses above the upper band
This strategy plots Donchian channels, trailing stops, and profit targets directly on the price chart. It enters breakout trades using a 55-bar Donchian channel and sizes positions according to an ATR-based risk percentage per unit. The system adds units as pr