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 • 21 hours ago #

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

  2. Paolo.B • 4 hours ago #

    Hi Ivan, great work. I’d love to try this indicator in an automated system, but I don’t understand what I should do to trigger an entry signal with the red or green arrows.
    Thanks

avatar
Register or

Likes

avatar
Related users ' posts
RakeshPoluri I have a question about the bands on the candles. Is it bollinger bands or something else?
Nicolas I think that's 2 Bollinger Bands
Emperor.it "style(line,2)" C'è una guida ai parametri che si possono modificare ? Tipo stile della lin...
IV Mcm https://www.prorealcode.com/programming-with-prorealtime/
IV Mcm I don't speak English and the translation is not clear. Do you have a different turn of ...
IV Mcm stonk ?
avatar
Anonymous Thanks very much for sharing, look forward to testing this idea out.
Daniele Maddaluno Écrivez-moi où vous préférez you can easily find me on LinkedIn
AK27 C'est payant visiblement sur linkdin je peux pas vous envoyer, discord vous avez ?
Pensera Bonjour Nicolas, comment est-il possible de backtester cet indicateur? cela fait une erreu...
Nicolas Oui bien sûr, il doit y avoir pas mal de sujets dans le forum à ce propos.
simmerseb Bonjour, merci beaucoup pour cet indicateur je le trouve très clair et pertinent.
Noobywan (My apologies for unformatted code, the formatting only works in forum or library posts not ...
Noobywan Hi FXTT, no problem for requests (as long as no one requests me singing), just usually it’s ...
JC_Bywan Bug fix at line 38, should be: if changebarre or (opentime[1]=start) then (same as in ...
Manu L. Bonjour Nicolas, j'ai créé un screener avec l'aide à la prog en TF weekly mais je voudrai...
wtangsiri C'est exactement le même signal que donne le croisement et le décroisement de deux EMA (7 et...
PHAN100 bonjour, j'ai un bug sur le programme recopié prorealtime me dit qu'il y a un problème à ...
PHAN100 bonjour, bravo à l'auteur pour cet indicateur visuel sur le graphique, il nous reste à va...
Nicolas Il doit s'agir d'un mauvais copier/coller. Je suggère de télécharger le fichier itf contenu ...
Bard Hello @Nicolas, I can get this to display in a separate indicator panel but not on Price as ...
Stenozar Hi @Nicolas, how can I put the bands on price? Thanks, Stefano
yeoreum Thank you very much for the screener, it reminds me on Minervini VCP. How to change th...
reecet any codes like this but in minutes and hours rather than days?
PHAN100 bonjour, je viens de tester ce screener, je constate une anomalie...il ne renvoie pas l'e...
Oxxoz Re bonjour Vivien, Il me smeble que 3 mois, c'est 60 séances. Cordialement,
Vinks_o_7 thanks ...and It can be used on a monthly and weekly basis by changing just the duration in ...
nicko Many Thanks Viv. It looks good
Nokis Bonjour Vivien, Comment je peux faire pour adapter ton code afin: De cibler les sociétés q...
sam00075 I tried it today and it gave great results. So a big Thanks !
Nicolas Oui le code est correct et il fonctionne, j'ai de bons résultats sur la liste NASDAQ par exe...
pincherman Bonjour :-) J'ai coller le script dans prorealtime pour jouer avec le supertrend et j'ai un...
Nicolas Vous l'avez sans doute collé au mauvais endroit, dans l'éditeur de code pour les stratégies,...
Guillaume Mcm I gave the above message fix ;)
Tradingrob Is it possible to put the itf-file in the right way here in Prorealcode? so the right 'trend...
Guillaume Mcm Update link ;) https://www.prorealcode.com/topic/trend-histogramme-cci-mise-a-jour-suite-...
Bard Hi @Vonasi, this is an excellent tool! I noticed you times by 180 and was wondering why? W...
Bard I have no idea what is wrong with the posting on this website. I have problems editing posts...
Bard And now my first post displays okay? It literally had copies of my orig post all added toget...
Screw27 Hi man, I installed the indicator and i don't know why but my graph it is so big
HelixKing sounds interesting I'll take a look
Godo Bonjour Souhait Sam, Après de nombreux essais pour le mettre en format afin d'utiliser ce c...
Nicolas Il faut supprimer celles qui existent dans la fenêtre d'optimisation et les créer en dur dan...
crusoe76 hi there, anyone can help making this strategy work, i have a message saying replace variabl...
Screw27 Salut nicolas j'aimerais savoir tes résulats grace a cettte methode
eva.g.forsgren It dose not work, I get a strap instead of candels???????????????????????????????????????????
Nicolas That indicator is the one below the chart. The indicator to put on the price chart is this o...

Top