'MTF Candle Reference Table

Making another indicator but I'm a bit stuck.

I want an indicator that'll display the last x amount of candles for a set of different TFs in a table. Not sure if a regular table can be plotted into, but if not, I'm sure there's a way to graphically plot our own table with the candlesticks then? I was able to effectively get all of the different TFs to plot onto my chart with a specified amount of candles per TF, but that's about as far as I've gotten.

Problems:

  • The sets of candles are currently overlapped/plotted in the same place, can't tell the sets apart. Don't know how to shift them over to the left or right to un-overlap them.
  • Want to plot into a table
  • The ranges of each candle are by nature disproportionate to other time frames, so I'm not sure how to make the sets of candles (per TF) the same size as each other for referencing. for examples the daily candles are huge, spanning 100s of pips, but the 1 minute candle is small spanning 10s, so plotted next to each other makes the minute candles tiny.

Here's the code, thank you!

// This source code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © tonemontgomery

//@version=5
indicator("MTF Candles", overlay = false)


candle_count = input.int(defval = 4, title = "Candle Count", minval = 1, maxval = 8)


color_bull = input.color(color.blue, "Bullish", group = "Table Settings")
color_bear = input.color(color.red, "Bearish", group = "Table Settings")
wick_color = input.color(color.black, "Wick Color", group = "Table Settings")


candle_data(_TF) =>
    open_data = request.security(symbol = "", timeframe = _TF, expression = open)
    high_data = request.security(symbol = "", timeframe = _TF, expression = high)
    low_data = request.security(symbol = "", timeframe = _TF, expression = low)
    close_data = request.security(symbol = "", timeframe = _TF, expression = close)
    color_bias = open_data < close_data ? color_bull : color_bear
    [open_data, high_data, low_data, close_data, color_bias]
    
    
[D1_open, D1_high, D1_low, D1_close, D1_color] = candle_data(_TF = "1D")
[H4_open, H4_high, H4_low, H4_close, H4_color] = candle_data(_TF = "240")
[H1_open, H1_high, H1_low, H1_close, H1_color] = candle_data(_TF = "60")
[M15_open, M15_high, M15_low, M15_close, M15_color] = candle_data(_TF = "15")
[M5_open, M5_high, M5_low, M5_close, M5_color] = candle_data(_TF = "5")
[M1_open, M1_high, M1_low, M1_close, M1_color] = candle_data(_TF = "1")


plotcandle(D1_open, D1_high, D1_low, D1_close, title = "D1 Candles", show_last = candle_count, wickcolor = wick_color, color = D1_color)
plotcandle(H4_open, H4_high, H4_low, H4_close, title = "H4 Candles", show_last = candle_count, wickcolor = wick_color, color = H4_color)
plotcandle(H1_open, H1_high, H1_low, H1_close, title = "H1 Candles", show_last = candle_count, wickcolor = wick_color, color = H1_color)
plotcandle(M15_open, M15_high, M15_low, M15_close, title = "M15 Candles", show_last = candle_count, wickcolor = wick_color, color = M15_color)
plotcandle(M5_open, M5_high, M5_low, M5_close, title = "M5 Candles", show_last = candle_count, wickcolor = wick_color, color = M5_color)
plotcandle(M1_open, M1_high, M1_low, M1_close, title = "M1 Candles", show_last = candle_count, wickcolor = wick_color, color = M1_color)



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source