Session-Based Strategies & Breakouts
Daily breakout indicators, pre-market breakout detection, afternoon vs morning range expansion, hiding lower timeframes, and referencing lower timeframes safely.
From Thrive on YouTube
Watch the matching Thrive video
Breakouts vs Pullbacks: Two Ways to Enter and How to Choose
Education only. Not financial advice.
Daily Breakout Indicator
A daily breakout occurs when price decisively moves above the previous day's high or below the previous day's low. These levels are universally watched. Every institutional trading desk, every market maker algorithm, and every retail trader with a daily chart can see them. When BTC breaks above yesterday's high on strong volume, it signals that buyers have overcome the prior session's resistance. The breakout indicator detects these events in real time and marks them on your chart.
1//@version=52indicator("Daily Breakout Detector", overlay=true)34volMult = input.float(1.5, "Volume Confirm Multiplier", step=0.1)56// Previous day's high and low (non-repainting)7[prevHigh, prevLow] = request.security(syminfo.tickerid, "D",8 [high[1], low[1]], lookahead=barmerge.lookahead_on)910// Volume confirmation11avgVol = ta.sma(volume, 20)12highVol = volume > avgVol * volMult1314// Breakout detection15var bool brokeHigh = false16var bool brokeLow = false1718// Reset flags on new day19if ta.change(time("D"))20 brokeHigh := false21 brokeLow := false2223// Detect first breakout of the day24bullBreak = not brokeHigh and close > prevHigh and highVol25bearBreak = not brokeLow and close < prevLow and highVol2627if bullBreak28 brokeHigh := true29if bearBreak30 brokeLow := true3132// Visualization33plot(prevHigh, "Prev High", color.new(color.red, 30), 2, plot.style_stepline)34plot(prevLow, "Prev Low", color.new(color.green, 30), 2, plot.style_stepline)3536plotshape(bullBreak, "Bull Break", shape.triangleup,37 location.belowbar, color.green, size=size.small, text="Break")38plotshape(bearBreak, "Bear Break", shape.triangledown,39 location.abovebar, color.red, size=size.small, text="Break")4041alertcondition(bullBreak, "Bullish Daily Breakout",42 "Price broke above previous day high with volume")Why volume matters
One signal per day
var bool brokeHigh flag ensures you only get one breakout signal per direction per day. Without this, every candle above the previous high would trigger, flooding your chart with redundant markers.New day reset
ta.change(time("D")) detects when a new daily bar begins on any timeframe. This resets the breakout flags, allowing fresh detection for each trading day.Pre-Market Breakout Detection
In crypto, there is no official "pre-market" since markets trade 24/7. However, the period between the US close (4 PM EST) and the Asian open (8 PM EST) is typically the lowest volume window of the day. Moves that occur during this dead zone and sustain into the Asian session often set the tone for the next 24 hours. This indicator captures range expansion during low-liquidity hours.
1//@version=52indicator("Off-Hours Breakout", overlay=true)34quietStart = input.session("1600-2000", "Quiet Window (NY time)")5asianOpen = input.session("2000-0400", "Asian Session (NY time)")6tz = "America/New_York"78// Track quiet window range9inQuiet = not na(time("", quietStart, tz))10inAsian = not na(time("", asianOpen, tz))1112var float quietHigh = na13var float quietLow = na14var bool tracked = false1516if inQuiet17 if not tracked18 quietHigh := high19 quietLow := low20 tracked := true21 else22 quietHigh := math.max(quietHigh, high)23 quietLow := math.min(quietLow, low)24else if not inQuiet and not inAsian25 tracked := false2627// Breakout during Asian session28asianBullBreak = inAsian and ta.crossover(close, quietHigh) and not na(quietHigh)29asianBearBreak = inAsian and ta.crossunder(close, quietLow) and not na(quietLow)3031plot(inAsian or inQuiet ? quietHigh : na, "Quiet High",32 color.new(color.orange, 30), 1, plot.style_stepline)33plot(inAsian or inQuiet ? quietLow : na, "Quiet Low",34 color.new(color.teal, 30), 1, plot.style_stepline)3536plotshape(asianBullBreak, "Asian Bull Break", shape.arrowup,37 location.belowbar, color.green, size=size.small)38plotshape(asianBearBreak, "Asian Bear Break", shape.arrowdown,39 location.abovebar, color.red, size=size.small)Morning vs Afternoon Range Expansion
Statistically, the first four hours of the US session (9:30 AM – 1:30 PM EST) produce the majority of the daily range in traditional markets. In crypto, the equivalent is the first four hours after the daily candle opens on your exchange (usually midnight UTC). This indicator compares the range expansion in the first half of the day versus the second half, letting you see whether the current day's move happened early (typical of trending days) or late (typical of reversal days).
1//@version=52indicator("Range Expansion Analysis", overlay=false)34morningSession = input.session("0000-1200", "Morning Window (UTC)")5afternoonSession = input.session("1200-0000", "Afternoon Window (UTC)")6tz = "Etc/UTC"78inMorning = not na(time("", morningSession, tz))9inAfternoon = not na(time("", afternoonSession, tz))1011var float morningHigh = na12var float morningLow = na13var float pmHigh = na14var float pmLow = na1516if ta.change(time("D"))17 morningHigh := na18 morningLow := na19 pmHigh := na20 pmLow := na2122if inMorning23 morningHigh := na(morningHigh) ? high : math.max(morningHigh, high)24 morningLow := na(morningLow) ? low : math.min(morningLow, low)2526if inAfternoon27 pmHigh := na(pmHigh) ? high : math.max(pmHigh, high)28 pmLow := na(pmLow) ? low : math.min(pmLow, low)2930morningRange = nz(morningHigh - morningLow)31pmRange = nz(pmHigh - pmLow)32totalRange = math.max(morningRange + pmRange, 0.0001)33morningPct = morningRange / totalRange * 1003435plot(morningPct, "Morning %", color.blue, 2)36hline(50, "Equal Split", color.new(color.gray, 60))37bgcolor(morningPct > 65 ? color.new(color.blue, 90) :38 morningPct < 35 ? color.new(color.orange, 90) : na)Trading implication
Hiding Lower Timeframes
Some scripts are designed for specific timeframes and produce misleading results on others. A session breakout tool built for the 5m chart is useless on the weekly. PineScript provides the timeframe.period variable and helper functions to restrict when your script runs.
1//@version=52indicator("Session Tool", overlay=true)34// Convert timeframe to approximate minutes for comparison5tfMinutes = switch6 timeframe.isseconds => timeframe.multiplier / 607 timeframe.isminutes => timeframe.multiplier8 timeframe.isdaily => timeframe.multiplier * 14409 timeframe.isweekly => timeframe.multiplier * 1008010 timeframe.ismonthly => timeframe.multiplier * 4320011 => 01213// Only run on intraday charts (60 min or less)14validTF = tfMinutes > 0 and tfMinutes <= 601516if not validTF and barstate.islast17 label.new(bar_index, close,18 "This indicator requires a 1H or lower timeframe",19 color=color.new(color.red, 20), textcolor=color.white,20 style=label.style_label_left, size=size.normal)2122// Guard all logic behind the validTF check23prevDayHigh = validTF ? request.security(syminfo.tickerid, "D",24 high[1], lookahead=barmerge.lookahead_on) : na25prevDayLow = validTF ? request.security(syminfo.tickerid, "D",26 low[1], lookahead=barmerge.lookahead_on) : na2728plot(prevDayHigh, "PDH", color.new(color.red, validTF ? 20 : 100), 2, plot.style_stepline)29plot(prevDayLow, "PDL", color.new(color.green, validTF ? 20 : 100), 2, plot.style_stepline)Referencing Lower Timeframes Safely
When you use request.security() to fetch a timeframe lower than your chart, PineScript only returns the value at the close of each of your chart's bars, not every lower-timeframe bar within it. This means you miss most of the lower-TF data. Understanding this limitation prevents common mistakes.
| Pitfall #1: Missing data | On a 1H chart requesting "5" data, you only see 1 of the 12 five-minute bars per hour. The other 11 are invisible. |
| Pitfall #2: False signals | A "5m RSI crossover" detected on a 1H chart will miss most crossovers because you only check RSI at the close of each hour. |
| Pitfall #3: Repainting | Lower-TF data can change mid-bar because multiple lower-TF bars complete while your chart bar is still open. |
| Safe alternative | Use request.security_lower_tf() to get an array of intrabar values. Or simply chart the lower timeframe directly. |
| Best practice | Only use request.security() to fetch HIGHER timeframes. For lower-TF data, switch your chart to that timeframe. |
Session High/Low Tracking and Visualization
Tracking the developing session high and low as it builds throughout the day is a core technique for intraday traders. Unlike the previous day's static levels, these are dynamic: the high ratchets up as price makes new highs, and the low drops as price makes new lows. Visualizing this building range shows you exactly how much of the expected daily range has been captured.
1//@version=52indicator("Session H/L Tracker", overlay=true)34atrLen = input.int(14, "ATR Length (Daily)")56dailyATR = request.security(syminfo.tickerid, "D",7 ta.atr(atrLen)[1], lookahead=barmerge.lookahead_on)8dayOpen = request.security(syminfo.tickerid, "D",9 open, gaps=barmerge.gaps_off)1011// Track developing session high and low12var float sessHigh = na13var float sessLow = na1415if ta.change(time("D"))16 sessHigh := high17 sessLow := low18else19 sessHigh := math.max(nz(sessHigh, high), high)20 sessLow := math.min(nz(sessLow, low), low)2122sessRange = sessHigh - sessLow23rangePct = dailyATR > 0 ? sessRange / dailyATR * 100 : 02425// ATR-projected targets from the day open26projHigh = dayOpen + dailyATR * 0.527projLow = dayOpen - dailyATR * 0.52829plot(sessHigh, "Session High", color.new(color.red, 20), 2, plot.style_stepline)30plot(sessLow, "Session Low", color.new(color.green, 20), 2, plot.style_stepline)31plot(projHigh, "ATR Proj High", color.new(color.red, 60), 1, plot.style_circles)32plot(projLow, "ATR Proj Low", color.new(color.green, 60), 1, plot.style_circles)Complete Build: Session Breakout Trading Tool
This is a complete session breakout system with entries, stops, and targets. It draws the previous day's range, detects breakouts with volume confirmation, calculates ATR-based stops and targets, and displays a compact status table. Apply it to BTCUSDT or ETHUSDT on the 5m or 15m chart for intraday breakout trading.
1//@version=52indicator("Session Breakout System", overlay=true, max_labels_count=50)34atrMult = input.float(1.5, "Stop ATR Multiple", step=0.1)5rrRatio = input.float(2.0, "Reward/Risk Ratio", step=0.1)6volMult = input.float(1.5, "Volume Confirm Multiple", step=0.1)78// Previous day levels (non-repainting)9[pdHigh, pdLow, pdClose] = request.security(syminfo.tickerid, "D",10 [high[1], low[1], close[1]], lookahead=barmerge.lookahead_on)11dailyATR = request.security(syminfo.tickerid, "D",12 ta.atr(14)[1], lookahead=barmerge.lookahead_on)1314midpoint = (pdHigh + pdLow) / 215avgVol = ta.sma(volume, 20)16highVol = volume > avgVol * volMult1718// Breakout state tracking19var int tradeDir = 0 // 1 = long, -1 = short, 0 = flat20var float entryPrice = na21var float stopPrice = na22var float tpPrice = na2324// Reset on new day25if ta.change(time("D"))26 tradeDir := 027 entryPrice := na28 stopPrice := na29 tpPrice := na3031// Breakout entries (only one per day)32if tradeDir == 033 if close > pdHigh and highVol and barstate.isconfirmed34 tradeDir := 135 entryPrice := close36 stopPrice := close - dailyATR * atrMult37 tpPrice := close + dailyATR * atrMult * rrRatio38 label.new(bar_index, low, "LONG",39 color=color.green, textcolor=color.white,40 style=label.style_label_up, size=size.tiny)41 if close < pdLow and highVol and barstate.isconfirmed42 tradeDir := -143 entryPrice := close44 stopPrice := close + dailyATR * atrMult45 tpPrice := close - dailyATR * atrMult * rrRatio46 label.new(bar_index, high, "SHORT",47 color=color.red, textcolor=color.white,48 style=label.style_label_down, size=size.tiny)4950// Level plots51plot(pdHigh, "PDH", color.new(color.red, 20), 2, plot.style_stepline)52plot(pdLow, "PDL", color.new(color.green, 20), 2, plot.style_stepline)53plot(midpoint, "Mid", color.new(color.gray, 50), 1, plot.style_stepline)5455// Active trade levels56plot(tradeDir != 0 ? entryPrice : na, "Entry",57 color.new(color.white, 20), 1, plot.style_cross)58plot(tradeDir != 0 ? stopPrice : na, "Stop",59 color.new(color.red, 20), 1, plot.style_cross)60plot(tradeDir != 0 ? tpPrice : na, "Target",61 color.new(color.green, 20), 1, plot.style_cross)6263// Status table64if barstate.islast65 t = table.new(position.bottom_right, 2, 4,66 bgcolor=color.new(#0d0b14, 10),67 border_width=1, border_color=color.new(color.gray, 70))6869 table.cell(t, 0, 0, "Status", text_color=color.gray, text_size=size.small)70 statusText = tradeDir == 1 ? "LONG" : tradeDir == -1 ? "SHORT" : "FLAT"71 statusCol = tradeDir == 1 ? color.green : tradeDir == -1 ? color.red : color.gray72 table.cell(t, 1, 0, statusText, text_color=statusCol, text_size=size.small)7374 table.cell(t, 0, 1, "Entry", text_color=color.gray, text_size=size.small)75 table.cell(t, 1, 1, tradeDir != 0 ? str.tostring(entryPrice, "#.##") : "-",76 text_color=color.white, text_size=size.small)7778 table.cell(t, 0, 2, "Stop", text_color=color.gray, text_size=size.small)79 table.cell(t, 1, 2, tradeDir != 0 ? str.tostring(stopPrice, "#.##") : "-",80 text_color=color.red, text_size=size.small)8182 table.cell(t, 0, 3, "Target", text_color=color.gray, text_size=size.small)83 table.cell(t, 1, 3, tradeDir != 0 ? str.tostring(tpPrice, "#.##") : "-",84 text_color=color.green, text_size=size.small)Indicator, not strategy
indicator(), not a strategy(). It marks entries and calculates levels, but it does not simulate trades or produce backtest results. To validate the edge, convert the logic to a strategy using strategy.entry() and strategy.exit(), then run it against BTCUSDT 15m data with realistic commission (0.075%) and slippage (2 ticks).Put this lesson to work
Free on Thrive, no account needed.