Candle Breakout Indicator

This is a simple indicator for setting candle breakout alerts. You will get a notification when price breaks and closes above or below the threshold you set.

How It Works

You set the long breakout and short breakout price, then the script waits until a candle breaks and closes beyond either of those zones. You can set one zone or both zones.

The only difference between this and a normal TradingView horizontal price alert is that you will not get an alert unless the candle closes beyond the level.


Long Breakout Price:
This sets the Long breakout price. Set it to zero to disable.

Short Breakout Price:
This sets the Short breakout price. Set it to zero to disable.

This tells the script how far to offset the rendered line from the current candle. This is for drawing purposes only and shouldn’t need to be modified.

How To Set Alerts

If you have any trouble setting alerts, try reading this article where I explain in detail how TradingView’s alert system works.

Pine Script Basics Course Pine Script Mastery Course

Source Code

// Created by Matthew J. Slabosz
// Last Updated: 9th October, 2020
// @version=4
study(title="Breakout Indicator", shorttitle="BKOI", overlay=true)

// Get user input
longBreakout = input(title="Long Breakout Price:", type=input.float, defval=0.0)
shortBreakout = input(title="Short Breakout Price:", type=input.float, defval=0.0)
offset = input(title="Offset", defval=5)

// Detect breakout
longAlert = longBreakout > 0 and close > longBreakout
shortAlert = shortBreakout > 0 and close < shortBreakout

// Plot data to chart
plot(longBreakout > 0 ? longBreakout : na, title="Long Breakout Price",, offset=offset)
plot(shortBreakout > 0 ? shortBreakout : na, title="Short Breakout Price",, offset=offset)

// Send out an alert if this candle meets our conditions
alertcondition(longAlert or shortAlert, title="Breakout Alert!", message="Breakout signal for {{ticker}}")

Last Updated: 9th October, 2020

Free Premium Charts!

5 1 vote
Article Rating
Notify of
Inline Feedbacks
View all comments