Free: indicator teardowns, a repaint checker and open-source scripts. No buy/sell signals, ever.

Taught to TradeSystems over signals.

Explainers / Breakout Finder by LonesomeTheBlue

Breakout Finder by LonesomeTheBlue, explained from the source

Breakout Finder is an open-source TradingView indicator by LonesomeTheBlue, about 27,700 boosts, first published in 2021. On the chart it is called "BF". When the price closes through a level that earlier turning points kept stopping at, it draws a box around that level and a small triangle under (or over) the bar. This page walks through its published code in order, says what each part does, and ends with where it fails. It does not say what any break will do next.

The surprise: "Minimum Number of Tests" asks for one more pivot than it says

The setting defaults to 2, and the description says the price must have tested the level twice. The code does count at least 2 turning points inside the box. But before it counts, it also requires that the newest three pivot highs in a row all sit below the breakout close, not two: the loop that walks back through the pivots stops one step later than the setting suggests. In our port on invented prices, loosening only that one test to "at least 2 pivots below the close" gave 21% to 23% more triangles. Nothing is broken on the chart; the setting just means "tests" plus one.

Step 1: the turning points

The script finds pivot highs and pivot lows with "Period" bars on each side (default 5). A pivot high is a high above the 5 bars before it and the 5 bars after it, so each pivot is only known 5 bars after it happened. It keeps a list of recent pivot highs and lows, newest first. When a new pivot is added, pivots older than "Max Breakout Length" (default 200 bars) are dropped from the end of the list. That cleanup only runs when a new pivot forms, and it never drops the newest one.

Step 2: the width of the box

The box is a band below a level (or above it, for breakdowns). Its height is "Threshold Rate %" (default 3%) of the distance between the highest high and the lowest low of the last 300 bars, or of all bars on a chart shorter than that. So the box is wider on a chart that has moved a lot in the last 300 bars, and narrower after a quiet stretch, whatever the timeframe.

Step 3: when a breakout triangle fires

On each bar the code checks a breakout up. The bar must close above its open, and its close must be above the highest high of the previous 5 bars. Then it walks back through the pivot highs from the newest, stopping at the first one at or above the close. The highest pivot passed on the way becomes the level, the top of the box. Then three tests apply. The newest three pivots in a row must sit below the close (Step 4 explains why three). The bar must open at or below the level, so a gap that opens above it does not count. And at least "Minimum Number of Tests" of the pivots it walked past must sit inside the band, between the level and the level minus the box height. Finally, the previous 5 bars' highest high must still be below the level. If all of that holds, it draws four lines, a box from the oldest pivot it counted to the current bar, and a blue triangle under the bar. A breakdown is the mirror image with pivot lows, a red box and a triangle above the bar.

Step 4: why the setting is off by one

The walk back through the pivots records the index of the last pivot below the close, starting from 0 for the newest. The test that follows asks for that index to be at least "Minimum Number of Tests". An index of 2 means three pivots (0, 1 and 2). So with the default of 2, three consecutive pivots below the close are needed before any are counted as tests, and with a setting of 1, two are needed. The count of tests inside the band is then checked against the setting as written.

What the settings change

"Period" (5) sets how many bars on each side make a pivot, and so how late each pivot is known. "Max Breakout Length" (200) sets how far back a pivot can be and still count. "Threshold Rate %" (3) sets the box height as a share of the 300-bar range, not of price. "Minimum Number of Tests" (2) sets how many pivots must sit in the band, and, through the off-by-one, how many in a row must sit below the close. Colours and line style are cosmetic. The 300-bar window and the 5-bar look-back for the prior high are tied to fixed numbers and to "Period" in the code.

What we checked in Python

We ported the pivot lists, the box width and both breakout tests to Python and ran them on invented random-walk prices, three runs of 20,000 bars, with 20 price ticks inside every bar so we could see what an unfinished bar shows. With the default settings it drew about 13 triangles per 1,000 bars (12.6 to 12.9) on prices that have nothing to find. For every 10 triangles that stayed at the close, there were 6 to 7 other bars where a triangle appeared during the bar and was gone by its close. Changing only the off-by-one test gave 21% to 23% more triangles. These figures describe the code on invented data, not any market.

Where it fails

Educational only. Not financial advice. Nothing here is a recommendation to buy or sell anything. Breakout Finder is by LonesomeTheBlue on TradingView and carries a Mozilla Public License 2.0 notice; this page describes its published open-source code in our own words and is not affiliated with the author. Simulation figures come from synthetic random-walk prices and say nothing about how the script trades.

Also explained: Repaint checker, VWAP, Supertrend, RSI, UT Bot Alerts, Nadaraya-Watson Envelope, Squeeze Momentum, What is repainting on TradingView?, Is TradingView backtesting accurate?, Chandelier Exit, WaveTrend Oscillator, QQE MOD, Pivot highs and lows, Hull Suite, Range Filter, Twin Range Filter, HalfTrend, ZigZag++, SSL Hybrid, CM MacD Ultimate MTF, Volume Profile / Fixed Range, ADX and DI, Support Resistance Channels, Market Structure Break & Order Block, Order Block Finder, Pivot Point SuperTrend, Trendlines with Breaks [LuxAlgo], Divergence for Many Indicators, TradingView script selling terms, Support and Resistance Levels with Break, Liquidity Swings [LuxAlgo], Pine Script errors, Breakout Probability (Expo), Did ChatGPT or Claude write your Pine Sc, Lorentzian Classification, SuperTrend AI (Clustering), Machine Learning Adaptive SuperTrend, Dynamic Swing Anchored VWAP, Support and Resistance Power Channel by , Support and Resistance (High Volume Boxe, Trendline Breakouts With Targets by Char

Next steps

  • Get a script fixed. Compiles but behaves differently live, or changes after a reload? In a Pine Script Audit, an AI model reads every line and writes a report on what to fix for $49, or also fixes those problems for $149. It cannot prove a script is safe.
  • Check your own script. Paste its source into the free repaint checker. It runs in your browser and flags known patterns.
Subscribe to the Teardown Letter: $19/moBack to Taught to Trade

No TradingView account yet? This affiliate link gives you a $15 coupon toward a paid plan, and we earn a commission if you buy one. The free plan is enough to follow this page.