Strategy · Pine Script v6 · On the chart

Ede - Breakout Strategie (mit MA und ATR Exit)

by NinjaEde

This strategy enters long positions on volume-backed breakout setups with moving average confirmation.

View on GitHub

GitHub stars2on the repository
Pine versionv6current
Lines of code122
Settings17inputs
LicenceMIT
Last update10 months ago24 Dec 2025

Add It to Your TradingView Chart

  1. 1Copy the scriptPress Copy script above, or the copy button on the code below.
  2. 2Open the Pine EditorOpen a TradingView chart and choose Pine Editor at the bottom of the screen.
  3. 3Paste over the templateCreate a new strategy, select all of the template text and paste. Press Save and give it a name.
  4. 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.

Details

Published by

NinjaEde on GitHub

Type

Strategy, Pine Script v6

Draws

On the price chart

Category

Breakout, Moving averages, Volatility & bands

Markets

Stocks

Timeframes

M15-H1, H4 and above

Risk Notes

  • The strategy enters trades without a stop loss

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
MA10 anzeigenbooltrueshow_ma10
MA50 anzeigenbooltrueshow_ma50
MA150 anzeigenbooltrueshow_ma150
MA200 anzeigenbooltrueshow_ma200
Breakout-ModusstringNur Gapbreakout_mode_str
Volumen-Multiplikatorfloat1.5volMultiplier
Stop-Loss verwenden?booltrueuse_stoploss
Stop-Loss %float3.0stoploss_perc
Take-Profit verwenden?booltrueuse_takeprofit
Take-Profit %float6.0takeprofit_perc
Exit bei MA10booltrueexit_on_ma10
Exit bei MA50boolfalseexit_on_ma50
Show all 17 settings
SettingTypeDefaultVariable
ATR Exit aktivieren?booltrueexit_on_atr
ATR Periodeint14atr_period
ATR Multiplikatorfloat2.0atr_multiplier
ATR-Trailing-Stop exklusiv (nur dieser Exit)?boolfalseatr_exit_exclusive
ATR-Trailing-Stop erst ab Gewinn (%) aktiv?float0.0atr_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.

Similar Pine Scripts

Bollinger Breakout

by hackingthemarkets
189 stars

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

Strategy v4 Volatility & bandsBreakout
Updated 3 years ago · None stated GitHub repository of Bollinger Breakout
106 stars

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

Strategy v5 TrendMoving averages
Updated 2 years ago · GPL-3.0 GitHub repository of 9:22 5 MIN 15 MIN BANKNIFTY

均线突破交易系统

by tangly1024
76 stars

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

Strategy v5 TrendMoving averages
Updated 4 months ago · None stated GitHub repository of 均线突破交易系统

Bollinger bands examples

by tradingstrategy-ai
53 stars

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

Strategy v5 Volatility & bandsOscillators & momentum
Updated 3 years ago · None stated GitHub repository of Bollinger bands examples

Keltner Channels Strategy

by TWODS-CAPITAL
37 stars

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

Strategy v5 Volatility & bandsBreakout
Updated 3 years ago · MIT GitHub repository of Keltner Channels Strategy
16 stars

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

Strategy v6 TrendBreakout
Updated 11 months ago · None stated GitHub repository of Seykota Alt 10: Profit Targets

More strategys

Trade Your Charts With a Regulated Broker

Compare brokers that connect to TradingView, with spreads, minimum deposits and leverage side by side.

Compare brokers