TrendLine BreakOuts

TrendLine BreakOuts

1) Introduction

TrendLine BreakOuts is a indicator inspired by the original concept created by ChartPrime. It automates the discovery of dynamic trendlines built from swing pivots and highlights the first valid breakout with clear, actionable visuals. Once a breakout occurs, the tool overlays ATR-based take-profit (TP) and stop-loss (SL) rails and tracks which level is reached first, helping traders evaluate follow-through after a structural break. Designed for clarity and speed, it works on any timeframe and instrument, and it offers flexible controls to switch between wick or body pivots and to enable/disable bullish or bearish structures.

2) How the Indicator Works

Pivot detection

  • The script scans left/right bars defined by period to confirm swing highs and lows.
  • pivottype = 1 → uses wicks (low/high).
  • pivottype = 0 → uses bodies (min(open, close) / max(open, close)).

A pivot is confirmed when the current candidate is lower (for lows) or higher (for highs) than the surrounding window on both sides. This ensures robust swing points and limits noise.

Trendline construction

  • Bearish lines are drawn by connecting two descending pivot highs (PH).
  • Bullish lines are drawn by connecting two ascending pivot lows (PL).
  • The slope is computed from the latest two relevant pivots and the line is projected forward bar by bar.

Breakout logic

  • For bullish setups (using pivot highs): the indicator checks when price closes above the projected line → breakout.
  • For bearish setups (using pivot lows): the indicator checks when price closes below the projected line → breakout.

On the breakout bar, the script establishes TP/SL levels and begins tracking which one is hit first.

Volatility engine (TP & SL)

  • The buffer Zband is derived from ATR(30) and the instrument price, then shifted and halved as used in the code.
  • TP/SL are placed symmetrically around the breakout reference using a multiplier (*20 in the script).
  • As bars evolve, the script checks: TP hit first (win) or SL hit first (loss).

Drawing layer (what you see)

  • Trendline segments to the breakout point.
  • ▲ / ▼ breakout icons at the crossing.
  • Dotted TP/SL rails that extend until the exit bar.
  • ✖ marker at the exact exit price (TP or SL first).

3) Inputs & Defaults (Configuration Panel)

Input Type Default What it controls Notes & typical ranges
period Integer 9 Swing width (pivot sensitivity) 6–20 common. Lower = more signals, more noise. Higher = smoother, fewer but stronger lines.
pivottype Integer 1 1 = wicks; 0 = bodies Bodies help reduce false breaks from wick spikes; wicks capture “true extremes”.
showtrendUP Boolean 1 Show bullish (breaks of descending highs) Set to 0 to hide all bullish structures.
showtrendDN Boolean 1 Show bearish (breaks of ascending lows) Set to 0 to hide all bearish structures.

Under the hood:

  • leftbars = period
  • rightbars = max(1, floor(period/2))
    This creates a forward/backward confirmation window around each candidate swing.

4) Signal Anatomy & Chart Markings

Bullish pattern (break above a descending line built from pivot highs):

  • Dark green trendline up to the breakout bar.
  • ▲ green marker at the breakout.
  • Green dotted line for TP and dark red dotted line for SL.
  • ✖ orange point at the exit (whichever is hit first), with a small green label.

Bearish pattern (break below an ascending line built from pivot lows):

  • Dark red trendline up to the breakout bar.
  • ▼ dark red marker at the breakout.
  • Green dotted line for TP and dark red dotted line for SL.
  • ✖ orange point at the exit, with a small dark red label.

Legend (quick view):

  • Trendlines: dark green (bullish), dark red (bearish).
  • Breakout icons: (up), (down).
  • TP: dotted (green).
  • SL: dotted (dark red).
  • Exit: (orange point + label).

5) Trade Management Logic

  • On breakout, the indicator computes TP and SL using the volatility buffer Zband.
  • It simulates the path bar by bar after the breakout: if TP is touched first, it registers a win; if SL is touched first, a loss.
  • The script draws until the first event occurs; if neither is hit by the current bar, the rails remain open to barindex.
  • islastbarupdate ensures drawing is efficient and that only relevant, up-to-date segments are output on the last recalculation.

6) Code (ProBuilder)

Share this

Risk disclosure:

No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.

ProRealTime ITF files and other attachments : How to import ITF files into ProRealTime platform?

PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials

  1. roccafragius • 10 hours ago #

    Great Indicator Ivan, thank you so much! It seems better than similar indicator that are available in the market 🙂

avatar
Register or

Likes

avatar
Related users ' posts
Iván Gracias! Para el screener sólo tienes que copiar el indicador y poner como condición de búsq...
Lean Muchas gracias Iván, ya lo he podido crear.
bertoluce Hello Ivan, thank you very much for the indicator. An observation: would it be possible (and...
lee Thank you!
Doddge Hola Iván, ¿sería posible crear un screener que indique cuándo las velas coloreadas del indi...
RTR Ivan thank you for the pro-screener. I a trying to understand how to write the signals from ...
Iván Hi, Lines 62 and 63. These lines define buy and sell conditions.
Iván Hi We could find stocks with sweep on: //PRC_Sweep Institucional //version = 0 //28.0...
inverse Like the way you think Ivan ... :)
ar Bonjour Ivan et merci pour ton partage, Est-il possible d'avoir ce code en ITF
Iván Hi You should delete from the indicator code all drawing functions and all variables not us...
Iván I've created a screener to show [longcondition or shortcondition]
Chrisinobi Hallo Ivan, Danke das ist Perfekt !! Kannst du bitte in der Screener-Bibliothek die itf. hoc...
MaoRai54 Thanks, now it's OK. in your first code at line 15-16 it's missing.
Madrosat Hello Ivan Did you try a strategy with this indicator
Iván Hi. No I didn't. This is a code translation requested by an user a few days ago.
Iván
2 years ago
cjr30 Simplemente modifica las lineas 19 y 21 por las siguientes: drawtext("▲",barindex,low-0.1*a...
groelandes Gracias!!
WhyAskOZ i copied the code into strategy and it gives error on line 21 and 23. it says " Line 1: ...
Iván
2 years ago
Madrosat Hello Ivan You have interesting topics on indicators , smart supertrend, optimised trend t...
Iván Hi! thanks. All of these codes are translations requested in the forum. I've on mind to back...
Raspete01 Buenos días Iván, estoy intentando llevar el código eliminando los colores y pasando un Back...
jacquesgermain sì da aggiungere
Maik2404 auf welchen Wert muss ich die Kompresionsperiode stellen?
jacquesgermain — Période de compression : ce paramètre détermine la période de rétrospection utilisée pour ...
Iván
2 years ago
winnie37 Hi Ivan, if i want to use it, and call the oscillator value (in grey, green or red), how to...
Iván The oscillator is smoothtype. In inputs there is de lag to configure the output
ARLEQUIN49 Hello Ivan, Would it be possible to convert the code of this QQE MOD indicator which accomp...
ARLEQUIN49 here is the code: //@version=4 //By Glaz, Modified // study("QQE MOD") RSI_Period = i...
Iván Hi, Yes I can translate it but please, create a new topic for it.
Fgats quelques explications en Français ici : Some explanations in French here : https://www.p...
Nicolas Merci pour cette contribution, j'apprécie ! :)
Fgats Merci Nicolas pour ces encouragements et merci aussi pour le commentaire en Anglais accompa...
Alai-n I really like it when you develop ideas around price movement! I am much less a fan of all t...
elcortijoverde Muy buen trabajo.Intuitivo y claro.Gracias por tu dedicación y aportación.
Nicolas
2 years ago
B-Xtrender
B-Xtrender
8
Indicators
616248 Bonjour Nicolas, Peux tu nous expliquer le principe de fonctionnement ? Ou nous mettre un...
Nicolas Le lien vers l'article IFTA de l'auteur est dans le post déjà :)
P. Marlowe Very poweful indeed. It deserves close attention. I really appreciate very much IFTA backgro...
JS
2 years ago
Trendilo
Trendilo
1
Indicators
Coded1 very interesting indicator, thanks JS
Nicolas
2 years ago
Lucas0000 Hello, Congratulations on this programming, it seems incredible to me, I am new to this but ...
plbourse Hello, I am trying to use this singal (in fact I have converted it to an indicateur giving B...
manfeber Buenos dias,alguien me podria decir como se descargar el archivo o el indicador Q-Trend??,ya...
BriceE Bonjour Nicolas, Je suis a la recherche d'indicateurs pour me donner la meilleure indicatio...

Top