Indicator · Pine Script v5 · On the chart

Day Trading Range

by Web3Degenerate· code credited to ZenAndTheArtOfTrading / PineScriptMastery.com

This indicator plots daily trading range lines on the price chart using higher timeframe data.

View on GitHub

GitHub stars2on the repository
Pine versionv5runs as is
Lines of code41
Settings3inputs
LicenceNone statedfile: MPL-2.0
Last update2 years ago13 Sep 2024

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

41 lines of Pine Script v5 from advanced-pine-script/5.Indicators/18.Day-Trading-Tool.pine, published under MPL-2.0 (file header). Keep the author's credit and licence lines when you reuse it.

18.Day-Trading-Tool.pine
// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © ZenAndTheArtOfTrading / PineScriptMastery.com
// Last Updated: 9th June, 2023
// @version=5
indicator("Day Trading Range", overlay=true)

// Get input
res     = input.timeframe(title="Timeframe", defval="D")
atrLen  = input.int(title="ATR Length", defval=5)
atrMult = input.float(title="ATR Multiplier", defval=0.5)

// Create non-repainting security function
rp_security(_symbol, _res, _src) => request.security(_symbol, _res, _src[barstate.isrealtime ? 1 : 0])[barstate.isrealtime ? 0 : 1]

// Get HTF price data
htfHigh = rp_security(syminfo.tickerid, res, high)
htfLow = rp_security(syminfo.tickerid, res, low)
htfATR = rp_security(syminfo.tickerid, res, ta.atr(atrLen)) * atrMult

// Open price and line variables
var line openPriceLine = na
var line upperAtrLine = na
var line lowerAtrLine = na
var line yesterdayHiLine = na
var line yesterdayLoLine = na
var line newDayLine = na

// Detect new day
if (ta.change(time(res)) > 0)
    line.delete(openPriceLine[1])
    line.delete(upperAtrLine[1])
    line.delete(lowerAtrLine[1])
    line.delete(yesterdayHiLine[1])
    line.delete(yesterdayLoLine[1])
    line.delete(newDayLine[1])
    newDayLine := line.new(bar_index, 99999999, bar_index, 0, xloc.bar_index, extend.none, color.white, line.style_solid, 2)
    openPriceLine := line.new(bar_index, open, bar_index + 1, open, xloc.bar_index, extend.right, color.white, line.style_solid)
    upperAtrLine := line.new(bar_index, open + htfATR, bar_index + 1, open + htfATR, xloc=xloc.bar_index, extend=extend.right, color=color.aqua, style=line.style_solid)
    lowerAtrLine := line.new(bar_index, open - htfATR, bar_index + 1, open - htfATR, xloc=xloc.bar_index, extend=extend.right, color=color.aqua, style=line.style_solid)
    yesterdayHiLine := line.new(bar_index, htfHigh, bar_index + 1, htfHigh, xloc=xloc.bar_index, extend=extend.right, color=color.red, style=line.style_solid)
    yesterdayLoLine := line.new(bar_index, htfLow, bar_index + 1, htfLow, xloc=xloc.bar_index, extend=extend.right, color=color.blue, style=line.style_solid)

Overview

Day Trading Range detects new trading days and draws the open price line in white, upper and lower ATR bands in aqua based on the ATR length and multiplier, yesterday's high in red, yesterday's low in blue, and a new day marker. The higher timeframe is default daily with ATR length 5 and multiplier 0.5. It helps identify potential intraday ranges for day trading. The tool uses a non-repainting security call to fetch HTF data.

Details

Published by

Web3Degenerate on GitHub

Code credit

ZenAndTheArtOfTrading / PineScriptMastery.com, as written in the script's header

Draws

On the price chart

Markets

Any symbol

Timeframes

M15-H1

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.

Settings

The inputs you can change from the gear icon on the chart. Defaults are the author's.

SettingTypeDefaultVariable
TimeframetimeframeDres
ATR Lengthint5atrLen
ATR Multiplierfloat0.5atrMult
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

56 stars

This indicator marks forex trading sessions and opening ranges on the price chart. It can draw Sydney, Tokyo, Frankfurt, London, and New York session boxes or five- and fifteen-minute opening ranges, plus an optional opening channel and a day-open range. Day r

Indicator v5 Sessions & timeSupport & resistance Repaints
Updated 2 months ago · None stated GitHub repository of Day Trading Booster by DGT

AM TBR — NQ Stats

by TamaraKGreen
46 stars

The AM TBR indicator calculates statistical levels for NQ futures using standard deviation. It plots a sigma ladder showing touch levels at 0.5 to 2.0 standard deviations, marks touch points, displays Mean Absolute Error (MAE) zones after touches, and shows Me

Indicator v6 Volatility & bandsSupport & resistance
Updated 8 weeks ago · None stated GitHub repository of AM TBR — NQ Stats

LoD Intraday Entry

by ChartsLector
41 stars

This overlay indicator marks the current day's low and a suggested entry zone a fraction of daily ATR below that low. It compares daily volume with a volume moving average, plots daily SMA and EMA distance, and draws an optional ATR-width price cloud. Labels c

Indicator v6 Support & resistanceVolatility & bands
Updated 4 days ago · None stated GitHub repository of LoD Intraday Entry

Zen Toolkit ETH

by Zen-Tim
29 stars

This indicator plots intraday reference levels, projection targets, and opening range boundaries tailored for continuous electronic trading session instruments such as gold. It calculates Average Bar Range targets in bullish and bearish multiples, previous day

Indicator v6 Support & resistanceSessions & time
Updated 2 weeks ago · MIT GitHub repository of Zen Toolkit ETH

This indicator combines six trading tools into a single chart overlay to optimize indicator limits. It calculates Bollinger Bands, projects weekend price boundaries, plots market structure elements like order blocks, breaker blocks, and MSB lines, marks New Yo

Indicator v6 Support & resistanceSMC / ICT / price action Repaints

More Volatility & bands scripts

Related on ForexR

Trade Your Charts With a Regulated Broker

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

Compare brokers