Session & Volatility Tools
Session candles, ATR trailing stop tool, day trading tools, displaying stops and targets on the chart, and building session-aware indicators.
From Thrive on YouTube
Watch the matching Thrive video
Trading Indicators, Honestly: What They Can and Cannot Do
Part of Trading Journal and Performance Review. Education only. Not financial advice.
Session Candles Indicator
Session candles draw the open, high, low, and close of entire trading sessions (Asia, London, New York) as overlay candles on your intraday chart. This reveals which session is driving price and where key levels formed. On a 15-minute BTC chart, you can see the Asian session range as a single candle, then watch whether London breaks out of that range or reverses. This is foundational for session-based trading strategies.
1//@version=52indicator("Session Candles", overlay=true,3 max_boxes_count=500)45showAsia = input.bool(true, "Show Asia")6showLondon = input.bool(true, "Show London")7showNY = input.bool(true, "Show New York")89asiaTime = "2000-0400"10londonTime = "0300-1130"11nyTime = "0930-1600"12tz = "America/New_York"1314drawSession(sessionStr, boxColor, bgColor) =>15 inSession = not na(time("", sessionStr, tz))16 newSession = inSession and not inSession[1]1718 var float sessOpen = na19 var float sessHigh = na20 var float sessLow = na21 var int sessBar = na2223 if newSession24 sessOpen := open25 sessHigh := high26 sessLow := low27 sessBar := bar_index28 else if inSession29 sessHigh := math.max(sessHigh, high)30 sessLow := math.min(sessLow, low)3132 endSession = not inSession and inSession[1]33 if endSession and not na(sessBar)34 box.new(sessBar, sessHigh, bar_index[1], sessLow,35 border_color=boxColor, bgcolor=bgColor,36 border_width=1)3738if showAsia39 drawSession(asiaTime, color.new(color.purple, 30),40 color.new(color.purple, 92))41if showLondon42 drawSession(londonTime, color.new(color.blue, 30),43 color.new(color.blue, 92))44if showNY45 drawSession(nyTime, color.new(color.orange, 30),46 color.new(color.orange, 92))Session detection
time() function with a session string returns a non-na value only when the current bar falls within the specified time window. The transition from na to non-na marks the session open. Using a timezone parameter ensures consistency regardless of the chart's local timezone.Tracking session OHLC
var persist across bars. At session open, we reset the open/high/low. During the session, we continuously update the high and low. At session close (when the bar exits the time window), we have the complete OHLC range to draw.Drawing the box
box.new() draws a rectangle from the session start bar to the session end bar, bounded by the session high and low. The background is highly transparent (92) to avoid obscuring candles, while the border provides a clear visual boundary.ATR Trailing Stop Tool
An ATR trailing stop dynamically adjusts your stop loss based on current volatility. In trending markets, the stop follows price at a distance of N times ATR. When volatility expands (like during a BTC liquidation cascade), the stop widens to avoid getting stopped out on noise. When volatility contracts, the stop tightens to lock in profits. This is superior to fixed percentage stops because it adapts to market conditions automatically.
1//@version=52indicator("ATR Trailing Stop", overlay=true)34atrLen = input.int(14, "ATR Length")5atrMult = input.float(2.5, "ATR Multiplier", step=0.1)6src = input.source(close, "Source")78atr = ta.atr(atrLen)910var float trail = na11var int dir = 11213longStop = src - atr * atrMult14shortStop = src + atr * atrMult1516// Trail logic: ratchet the stop in the trend direction17if na(trail[1])18 trail := longStop19 dir := 120else21 if dir == 122 trail := math.max(nz(trail[1]), longStop)23 if src < trail24 trail := shortStop25 dir := -126 else27 trail := math.min(nz(trail[1]), shortStop)28 if src > trail29 trail := longStop30 dir := 13132// Visualization33trailColor = dir == 1 ? color.new(color.green, 0) :34 color.new(color.red, 0)35plot(trail, "ATR Trail", trailColor, 2, plot.style_linebr)3637// Flip signals38buyFlip = dir == 1 and dir[1] == -139sellFlip = dir == -1 and dir[1] == 140plotshape(buyFlip, "Buy Flip", shape.triangleup,41 location.belowbar, color.green, size=size.small)42plotshape(sellFlip, "Sell Flip", shape.triangledown,43 location.abovebar, color.red, size=size.small)4445bgcolor(dir == 1 ? color.new(color.green, 95) :46 color.new(color.red, 95))Multiplier selection
Day Trading Tool: Session Levels and Pivots
A session-aware day trading tool combines the previous session's high, low, and close with classic pivot point calculations to produce key intraday levels. Pivot points have been used by floor traders for decades. They represent equilibrium prices around which the market tends to rotate. For crypto, the previous day's high and low are the most respected intraday levels because they represent the boundaries of the last full cycle of trading.
1//@version=52indicator("Day Trading Levels", overlay=true,3 max_lines_count=500, max_labels_count=500)45showPivots = input.bool(true, "Show Pivot Points")6showPDHL = input.bool(true, "Show Prev Day H/L")78// Previous day OHLC (non-repainting)9pdHigh = request.security(syminfo.tickerid, "D",10 high[1], lookahead=barmerge.lookahead_on)11pdLow = request.security(syminfo.tickerid, "D",12 low[1], lookahead=barmerge.lookahead_on)13pdClose = request.security(syminfo.tickerid, "D",14 close[1], lookahead=barmerge.lookahead_on)1516// Classic pivot points17pp = (pdHigh + pdLow + pdClose) / 318r1 = 2 * pp - pdLow19s1 = 2 * pp - pdHigh20r2 = pp + (pdHigh - pdLow)21s2 = pp - (pdHigh - pdLow)2223if showPDHL24 plot(pdHigh, "Prev Day High", color.new(color.red, 30), 1,25 plot.style_stepline)26 plot(pdLow, "Prev Day Low", color.new(color.green, 30), 1,27 plot.style_stepline)28if showPivots29 plot(pp, "Pivot", color.new(color.yellow, 20), 2,30 plot.style_stepline)31 plot(r1, "R1", color.new(color.red, 50), 1,32 plot.style_stepline)33 plot(r2, "R2", color.new(color.red, 30), 1,34 plot.style_stepline)35 plot(s1, "S1", color.new(color.green, 50), 1,36 plot.style_stepline)37 plot(s2, "S2", color.new(color.green, 30), 1,38 plot.style_stepline)| Pivot Point (PP) | (High + Low + Close) / 3. Central equilibrium level. Price above PP = bullish bias, below = bearish bias. |
| R1 / S1 | First resistance and support levels. Most common intraday reversal zones. ~70% of price action stays within R1-S1. |
| R2 / S2 | Second resistance and support levels. Reached on high-volatility days. Breakout targets when R1/S1 fail to hold. |
| Prev Day High | The highest price from the prior 24h session. A breakout above this level signals continuation and fresh buying. |
| Prev Day Low | The lowest price from the prior 24h session. A breakdown below signals continuation selling and potential capitulation. |
Displaying Stops and Targets on Chart
Visualizing your stop loss, take profit, and risk-reward ratio directly on the chart eliminates guesswork. This tool draws horizontal lines at your entry, stop, and target levels, then adds a label showing the exact R:R ratio. Professional traders plan every trade visually before entering. This tool makes that process part of your indicator setup.
1//@version=52indicator("Trade Planner", overlay=true,3 max_lines_count=50, max_labels_count=50)45atrLen = input.int(14, "ATR Length")6slMult = input.float(2.0, "Stop ATR Mult", step=0.1)7tpMult = input.float(3.0, "Target ATR Mult", step=0.1)89ema21 = ta.ema(close, 21)10atr = ta.atr(atrLen)1112bullEntry = ta.crossover(close, ema21) and barstate.isconfirmed1314if bullEntry15 entryPrice = close16 stopPrice = entryPrice - atr * slMult17 tpPrice = entryPrice + atr * tpMult18 rr = tpMult / slMult1920 line.new(bar_index, entryPrice, bar_index + 20, entryPrice,21 color=color.white, width=2, style=line.style_solid)22 line.new(bar_index, stopPrice, bar_index + 20, stopPrice,23 color=color.red, width=1, style=line.style_dashed)24 line.new(bar_index, tpPrice, bar_index + 20, tpPrice,25 color=color.green, width=1, style=line.style_dashed)2627 label.new(bar_index + 22, tpPrice,28 "TP: " + str.tostring(tpPrice, "#.##"),29 color=color.new(color.green, 70),30 textcolor=color.green, style=label.style_label_left,31 size=size.tiny)32 label.new(bar_index + 22, stopPrice,33 "SL: " + str.tostring(stopPrice, "#.##"),34 color=color.new(color.red, 70),35 textcolor=color.red, style=label.style_label_left,36 size=size.tiny)37 label.new(bar_index + 22, entryPrice,38 "R:R " + str.tostring(rr, "#.#") + ":1",39 color=color.new(color.white, 70),40 textcolor=color.white, style=label.style_label_left,41 size=size.tiny)Always define your exit before entry
Complete Session-Aware Trading Tool
This comprehensive indicator combines session detection, ATR trailing stops, pivot levels, and entry/exit visualization into a single tool. It identifies the current trading session, shows the trailing stop appropriate for current volatility, plots key intraday levels, and marks entry signals when a session breakout occurs with confirming momentum. This is the type of multi-component tool that professional day traders build for their specific workflow.
1//@version=52indicator("Session Trading Tool", overlay=true,3 max_lines_count=100, max_labels_count=100)45atrLen = input.int(14, "ATR Length")6atrMult = input.float(2.0, "ATR Multiplier", step=0.1)78tz = "America/New_York"9inAsia = not na(time("", "2000-0400", tz))10inLondon = not na(time("", "0300-1130", tz))11inNY = not na(time("", "0930-1600", tz))1213sessName = inNY ? "NY" : inLondon ? "LON" : inAsia ? "ASIA" : "OFF"1415// Previous day levels (non-repainting)16pdH = request.security(syminfo.tickerid, "D",17 high[1], lookahead=barmerge.lookahead_on)18pdL = request.security(syminfo.tickerid, "D",19 low[1], lookahead=barmerge.lookahead_on)20pp = (pdH + pdL + request.security(syminfo.tickerid, "D",21 close[1], lookahead=barmerge.lookahead_on)) / 32223// ATR trailing stop24atr = ta.atr(atrLen)25var float trail = na26var int dir = 127longStop = close - atr * atrMult28shortStop = close + atr * atrMult2930if na(trail[1])31 trail := longStop32 dir := 133else if dir == 134 trail := math.max(nz(trail[1]), longStop)35 if close < trail36 trail := shortStop37 dir := -138else39 trail := math.min(nz(trail[1]), shortStop)40 if close > trail41 trail := longStop42 dir := 14344plot(trail, "ATR Trail", dir == 1 ? color.green : color.red,45 2, plot.style_linebr)46plot(pp, "Pivot", color.new(color.yellow, 30), 1,47 plot.style_stepline)48plot(pdH, "Prev High", color.new(color.red, 50), 1,49 plot.style_stepline)50plot(pdL, "Prev Low", color.new(color.green, 50), 1,51 plot.style_stepline)5253// Session background54bgCol = inNY ? color.new(color.orange, 95) :55 inLondon ? color.new(color.blue, 95) :56 inAsia ? color.new(color.purple, 95) : na57bgcolor(bgCol)5859if barstate.islast60 label.new(bar_index + 3, close, sessName,61 color=color.new(color.gray, 60),62 textcolor=color.white, size=size.small,63 style=label.style_label_left)Automatically detects Asia, London, and New York sessions with colored backgrounds
Dynamic stop that adapts to current volatility: widens in chaos, tightens in calm
Non-repainting high, low, and pivot point from the prior session
Current session name displayed at the right edge of the chart
One indicator replaces 3–4 separate tools, keeping your chart clean
Put this lesson to work
Free on Thrive, no account needed.