Indicator · Pine Script v5 · On the chart

Candle Breaks 1v1 L+S

by chargersfan47

This indicator identifies single-candle breakout patterns where the current bar closes beyond the open of the preceding opposite-direction bar.

View on GitHub

GitHub stars7on the repository
Pine versionv5runs as is
Lines of code138
Settings0inputs
LicenceNone statedfile: MPL-2.0
Last update5 months ago11 May 2026

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 indicator, select all of the template text and paste. Press Save and give it a name.
  4. 4Add it to the chartPress Add to chart, then adjust the settings with the gear icon next to its name.

Source Code

138 lines of Pine Script v5 from Pine Scripts/Candle Breaks 1v1 L+S.txt, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

Candle Breaks 1v1 L+S.txt
// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
//@version=5
// By Chargersfan with help from syndotc
indicator("Candle Breaks 1v1 L+S", overlay=true)

//this sets the threshold of targets.  Anything below this number is shown in grey on the chart.
percentageDiffThreshold = 0.4

// Convert timeframe
timeframe = str.tostring(timeframe.period)

if timeframe.isintraday and timeframe.multiplier >= 60
    timeframe := str.tostring(timeframe.multiplier / 60) + 'H'
    timeframe

if timeframe.isintraday and timeframe.multiplier < 60  
    timeframe := str.tostring(timeframe.multiplier) + "m"
    timeframe

if timeframe == "1.2H"
    timeframe := "72m"

if timeframe == "1.3333333333H"
    timeframe := "80m"

if timeframe == "1.5H"
    timeframe := "90m"

if timeframe == "1.6H"
    timeframe := "96m"

if timeframe == "2.4H"
    timeframe := "144m"

if timeframe == "2.6666666667H"
    timeframe := "160m"

if timeframe == "4.8H"
    timeframe := "288m"

// Check previous candle
longIsBearish = close[1] < open[1]
longIsBullish = close > open[1]
shortIsBullish = close[1] > open[1]
shortIsBearish = close < open[1]

// Capture open[1] and low[1] values
openPrev = open[1]
highPrev = high[1]
lowPrev = low[1]

// Calculate target1618 using Fibonacci sequence
longTarget1618 = math.round(openPrev + (openPrev - lowPrev) * 0.618, 2)
shortTarget1618 = math.round(openPrev - (highPrev - openPrev) * 0.618, 2)

// Define entryPrice as open[1] of the bearish candle
entryPrice = open[1] // + (50 * syminfo.mintick)

// Calculate percentage difference between entryPrice and target1618
longPercentageDifference = ((longTarget1618 - entryPrice) / entryPrice) * 100
shortPercentageDifference = ((entryPrice - shortTarget1618) / entryPrice) * 100
// Condition for percentage difference being 0.2 or greater
longPercentageDiffCondition = longPercentageDifference >= percentageDiffThreshold
shortPercentageDiffCondition = shortPercentageDifference >= percentageDiffThreshold

// Condition for bullish candle breaking above bearish candle
bullishBreakAboveBearish = longIsBearish and longIsBullish and close > open[1]
// Condition for bullish candle breaking above bearish candle
bearishBreakBelowBullish = shortIsBullish and shortIsBearish and close < open[1]

string direction = ""

// Plotting shapes for visual indication on the chart with target1618 and percentageDifference in the label
if bullishBreakAboveBearish
    direction := "Long"
    direction

    if longPercentageDiffCondition
        label.new(bar_index,
             high,
             "🎯 " + str.tostring(math.round(longPercentageDifference, 2)) + "%" +
             "\nX " + str.tostring(longTarget1618) +
             "\nE " + str.tostring(entryPrice), 
             style=label.style_label_down,
             color=color.green,
             textcolor=color.white)
    else
        label.new(bar_index, high, str.tostring(math.round(longPercentageDifference, 2)) + "%", style=label.style_label_down, color=color.gray, textcolor=color.black)

if bearishBreakBelowBullish
    direction := "Short"
    direction

    if shortPercentageDiffCondition
        label.new(bar_index,
             low,
             "🎯 " + str.tostring(math.round(shortPercentageDifference, 2)) + "%" +
             "\nE " + str.tostring(entryPrice) +
             "\nX " + str.tostring(shortTarget1618),
             style=label.style_label_up,
             color=color.red,
             textcolor=color.white)
    else
        label.new(bar_index, low, str.tostring(math.round(shortPercentageDifference, 2)) + "%", style=label.style_label_up, color=color.gray, textcolor=color.black)

// Alert condition for main condition
alertcondition(bullishBreakAboveBearish, title="Bullish Breaks Above Bearish", message="Bullish Breaks Above Bearish Candle")

// New alert condition for main condition and percentage difference being 0.2 or greater
alertcondition(bullishBreakAboveBearish and longPercentageDiffCondition, title="Bullish Breaks Above Bearish with %Diff >= 0.2", message="Bullish Breaks Above Bearish Candle with %Diff >= 0.2")

// Sending notifications with JSON-formatted alert message
if bullishBreakAboveBearish and longPercentageDiffCondition
    alert('{"symbol":"' + syminfo.ticker
             + '", "tf":"' + timeframe
             + '", "direction":"' + str.tostring(direction)
             + '", "price":"' + str.tostring(entryPrice) 
             + '", "tp":"' + str.tostring(longTarget1618)
             + '", "date":"' + str.format_time(timenow)     
             + '", "situation":"' + "1v1" + '"}',
             alert.freq_once_per_bar_close)

// Alert condition for main condition
alertcondition(bearishBreakBelowBullish, title="Bearish Breaks Below Bullish", message="Bearish Breaks Below Bullish Candle")

// New alert condition for main condition and percentage difference being 0.2 or greater
alertcondition(bearishBreakBelowBullish and shortPercentageDiffCondition, title="Bearish Breaks Below Bullish", message="Bearish Breaks Below Bullish Candle")

// Sending notifications with JSON-formatted alert message
if bearishBreakBelowBullish and shortPercentageDiffCondition
    alert('{"symbol":"' + syminfo.ticker
             + '", "tf":"' + timeframe
             + '", "direction":"' + str.tostring(direction)
             + '", "price":"' + str.tostring(entryPrice) 
             + '", "tp":"' + str.tostring(shortTarget1618)
             + '", "date":"' + str.format_time(timenow)  
             + '", "situation":"' + "1v1" + '"}',
             alert.freq_once_per_bar_close)

Overview

Candle Breaks 1v1 L+S calculates potential long and short breakout targets using a 0.618 Fibonacci projection from the prior candle range. The script draws labels directly on the price chart showing entry price, target level, and percentage gain. Setups exceeding a fixed threshold display green or red labels, while smaller moves appear in gray. It contains no configurable user inputs in settings, and it does not provide automated stop-loss or trade management rules.

Details

Published by

chargersfan47 on GitHub

Type

Indicator, Pine Script v5

Draws

On the price chart

Category

Candlestick patterns, Breakout, Support & resistance

Markets

Any symbol

Timeframes

Any timeframe

Risk Notes

No repainting, lookahead or stacked entries were found in its code or README. That says nothing about how well it works: test it first.

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

219 stars

This indicator identifies High Of Low Price (HOLP) and Low Of High Price (LOHP) candlestick setups based on price extremes over a specified lookback period. A HOLP signal triggers when the current bar closes above the high of a recent session low, whereas a LO

Indicator v5 Candlestick patternsBreakout
Updated 1 year ago · None stated GitHub repository of Candlestick Patterns - HOLP-LOHP

Reversal Breakout System

by TamaraKGreen
46 stars

This indicator detects inside candles inside larger parent candles on the price chart. It plots colored boxes around inside and parent candles, fills them with user-adjustable transparency, draws Fibonacci retracement lines and mother candle range lines, and d

Indicator v6 Candlestick patternsBreakout
Updated 7 weeks ago · None stated GitHub repository of Reversal Breakout System
7 stars

This indicator identifies market displacement, structure breaks, and Fair Value Gaps (FVGs) directly on the main price chart. It highlights displacement candles using an average range lookback and multiplier factor, with optional structure break filtering usin

Indicator v6 SMC / ICT / price actionSupport & resistance
Updated 3 months ago · None stated GitHub repository of [CT] Displacement FVG Toolkit

CTF Raid Indicator

by jerryinyang
5 stars

This indicator detects stop hunts, liquidity raids, and Rob Hoffman Inventory Retracement Bar breakouts directly on the main price chart. It tracks bullish and bearish retracement bars using dynamic arrays, identifying when incoming price action breaks these s

Indicator v5 SMC / ICT / price actionBreakout
Updated 2 years ago · None stated GitHub repository of CTF Raid Indicator

TheStrat Setup Screener

by 345-strategies
5 stars

This indicator screens Rob Smith's TheStrat setups across six configurable timeframes for TradingView's Pine Screener. It classifies bars and exposes inside reversals, 2-2 reversals and continuations, failing 2s, range expansions, and outside bars as numeric p

Indicator v6 Candlestick patternsSupport & resistance Repaints
Updated 2 days ago · MPL-2.0 GitHub repository of TheStrat Setup Screener

Inside Extended

by g-moe
3 stars

Inside Extended tracks inside bar patterns and projects their initial breakout ranges on the price chart. When a candle body falls completely within the high-low range of the prior candle, the indicator marks the inside bar in yellow and establishes the mother

Indicator v5 Candlestick patternsBreakout
Updated 5 months ago · None stated GitHub repository of Inside Extended

More indicators

Trade Your Charts With a Regulated Broker

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

Compare brokers