//@version=5
indicator("Multi-Time Period Charts", overlay=true, max_boxes_count=500)
AUTO_TIMEFRAME_TOOLTIP = "When the Auto option is selected, the timeframe of the indicator is chosen automatically based on the chart timeframe. The Timeframe dropdown is ignored. The automated timeframes are: \n
'1 day' for any chart timeframes below '1 day' \n
'1 week' for any timeframes starting from '1 day' up to '1 week' \n
'1 month' for any timeframes starting from '1 week' up to '1 month' \n
'3 months' for any timeframes starting from '1 month' up to '3 months' \n
'12 months' for any timeframes above '3 months'"
HLR = "High/Low Range"
TR = "True Range"
HAR = "Heikin Ashi Range"
DEFAULT_RESOLUTION = "1M"
DEFAULT_COLOR_GROWTH = color.rgb(0, 150, 136, 80)
DEFAULT_COLOR_FALL = color.rgb(244, 67, 54, 80)
DEFAULT_CALCULATION_METHOD = HLR
DEFAULT_AUTO_RESOLUTION = true
var prevBarIndex = bar_index
drawBox(left, right, top, bottom, diff, growthColorInput, fallColorInput, borderGrowth, borderFall) =>
drawnBox = box.new(left, top, right, bottom)
if diff < 0
box.set_border_color(drawnBox, borderFall)
box.set_bgcolor(drawnBox, fallColorInput)
else
box.set_border_color(drawnBox, borderGrowth)
box.set_bgcolor(drawnBox, growthColorInput)
drawnBox
selectAutoTimeframe() =>
timeframe.isseconds ? '120':
timeframe.isminutes ? '1440':
timeframe.isdaily ? 'W':
timeframe.isweekly ? 'M':
timeframe.ismonthly and timeframe.multiplier < 3 ? '3M': '12M'
autoTimeframeInput = input(DEFAULT_AUTO_RESOLUTION, title="AutoTimeframe", tooltip=AUTO_TIMEFRAME_TOOLTIP)
timeframeInput = input.timeframe(DEFAULT_RESOLUTION, title="Timeframe")
timeframe = autoTimeframeInput ? selectAutoTimeframe() : timeframeInput
calculationMethodInput = input.string(DEFAULT_CALCULATION_METHOD, "Calculation", options = [HLR, TR, HAR])
growthColorInput = input(DEFAULT_COLOR_GROWTH, title="",inline="Body")
fallColorInput = input(DEFAULT_COLOR_FALL, title="Body", inline="Body")
growthBorderColor = color.new(growthColorInput, 0)
fallBorderColor = color.new(fallColorInput, 0)
[previousHigh, previousLow, previousClose, previousOpen, prePreviousClose] = request.security(syminfo.tickerid, timeframe, [high[1], low[1], close[1], open[1], close[2]], lookahead=barmerge.lookahead_on)
[currentHigh, currentLow, currentClose, currentOpen, prevClose] = request.security(syminfo.tickerid, timeframe, [high, low, close, open, close[1]])
isNewPeriod = ta.change(time(timeframe))
drawCurrent = barstate.islast and not isNewPeriod
secHigh = drawCurrent ? currentHigh : previousHigh
secPrevClose = drawCurrent ? prevClose : prePreviousClose
secLow = drawCurrent ? currentLow : previousLow
diff = drawCurrent ? currentClose - currentOpen : previousClose - previousOpen
left = prevBarIndex
right = drawCurrent ? bar_index : bar_index[1]
[ashiHigh, ashiLow] = request.security(ticker.heikinashi(syminfo.tickerid), timeframe, [high, low])
float top = na
float bottom = na
if calculationMethodInput == HLR
top := secHigh
bottom := secLow
else if calculationMethodInput == TR
top := math.max(secHigh, secPrevClose)
bottom := math.min(secLow, secPrevClose)
else if calculationMethodInput == HAR
top := ashiHigh
bottom := ashiLow
if isNewPeriod
prevBarIndex := bar_index
drawBox(left, right, top, bottom, diff, growthColorInput, fallColorInput, growthBorderColor, fallBorderColor)
var box prevBox = na
if barstate.islast
if isNewPeriod
prevBox := na
else
box.delete(prevBox)
prevBox := drawBox(left, right, top, bottom, diff, growthColorInput, fallColorInput, growthBorderColor, fallBorderColor)
Overview
Box height follows High/Low Range, True Range, or Heikin Ashi Range, and the fill is growth or fall color according to that period’s open-to-close change. Auto timeframe maps the chart timeframe to a higher one, or the user picks a timeframe manually. Colors and the calculation method are the main settings. The excerpt ends before the live-bar box is finished, and it does not generate trade signals.
The inputs you can change from the gear icon on the chart. Defaults are the author's.
Setting
Type
Default
Variable
AutoTimeframe
input
DEFAULT_AUTO_RESOLUTION
autoTimeframeInput
Timeframe
timeframe
DEFAULT_RESOLUTION
timeframeInput
Calculation
string
DEFAULT_CALCULATION_METHOD
calculationMethodInput
growthColorInput
input
DEFAULT_COLOR_GROWTH
growthColorInput
Body
input
DEFAULT_COLOR_FALL
fallColorInput
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.
This overlay indicator marks ICT liquidity void fills on the price chart and can show long and short signals. It places a Fibonacci level inside a displacement candle, defaulting to the midpoint, and draws lines in a chosen style. Optional filters limit the fi
This indicator plots Donchian Channel boundary lines along with dynamic fan projections directly on the price chart. It calculates the highest high, lowest low, and median price over a customizable lookback period. Whenever price establishes a new channel high
This indicator plots a custom Anchored Volume-Weighted Average Price (VWAP) directly on the price chart along with optional standard deviation bands. Users can anchor the VWAP to standard time periods like sessions, weeks, or months, or to corporate events suc
This indicator plots optional candlestick pattern signals on the price chart. It detects engulfing bars, inside bars, HOLP and LOHP, kicker patterns, body-mass extremes, higher highs and lower lows, ATR warnings, and four-bar fractals. Optional pivot marks use
Dynamic Linear Regression calculates and plots linear regression trendlines and standard deviation channels directly on the price chart over a user-selected time period. Traders can configure static channels locked at the end time, dynamic channels that contin
This indicator overlays trend-following Supertrend bands on the price chart using Average True Range calculations. It plots trailing stop lines, highlights active trend directions, and prints buy or sell shape labels when price closes across band thresholds. I