Inspired by Rob Smith (R.I.P.), creator of TheStrat, this indicator visually maps price movements across higher timeframes to achieve full timeframe continuity—a core principle of TheStrat strategy. Below is a detailed breakdown of the script’s functionality and practical applications.
How the Script Works
1. User Input Configuration
_timeframe_opt = input.timeframe("60", "Select Timeframe", options=["1", "3", "5", "15", "30", "60", "240", "D", "W", "M", "3M", "12M"])_
_show_hl = input.bool(false, "Show Hi/Lo")_- Custom Timeframe Selection: Users can choose timeframes from 1 minute to 12 months (default: 60 minutes).
- High/Low Toggle: Optional markers for candle highs/lows.
2. Detecting New Candles
_is_new_candle = (time(timeframe_opt) != time(timeframe_opt)[1])_A new candle is identified when the timestamp of the current bar differs from the previous bar in the selected timeframe.
3. Variable Initialization
var float open_offset = na
var float high_offset = na
var float low_offset = na
var float close_offset = na
var line ln = naStores dynamic values for custom candle plotting relative to the chosen timeframe.
4. Calculating Candle Values
New Candle Logic:
if is_new_candle
open_offset := open
high_offset := high - open_offset
low_offset := low - open_offset
close_offset := close - open_offsetExisting Candle Updates:
else
high_offset := math.max(high - open_offset, high_offset[1])
low_offset := math.min(low - open_offset, low_offset[1])
close_offset := close - open_offset5. Plotting Custom Candles
plotcandle(
open_offset - open_offset, high_offset, low_offset, close_offset,
title="Custom Timeframe Candle",
color=(close_offset >= 0 ? color.green : color.red),
bordercolor=color.black, wickcolor=color.black
)- Color Rules: Green if close ≥ open; red otherwise.
- Visual Customization: Black borders/wicks for clarity.
6. High/Low Markers (Optional)
plot(show_hl ? high_offset : na, color=color.black, style=plot.style_circles)
plot(show_hl ? low_offset : na, color=color.black, style=plot.style_circles)7. Dashed Line for Intraday Candles
if is_new_candle and timeframe.isintraday
ln := line.new(
bar_index, 2.22, bar_index, -2.22,
color=color.new(color.black, 45),
style=line.style_dashed
)Marks new intraday candles with a vertical dashed line.
8. Timeframe Display Table
var table tf_table = table.new(position.top_right, columns=1, rows=1)
if is_new_candle
table.cell(tf_table, 0, 0, "Timeframe: " + timeframe_opt, text_color=color.white)How to Use the Indicator
Achieve multi-timeframe analysis by overlaying this indicator for each desired timeframe (e.g., hourly, daily, weekly).
Steps:
- Add the indicator to your chart.
- Repeat for each timeframe (e.g., 4 instances for hourly/daily/weekly/monthly).
- Select the target timeframe via the dropdown menu in each instance.
👉 Explore advanced trading tools to enhance your strategy further.
FAQs
Q1: Why is timeframe continuity important?
A: It aligns short-term trades with the broader market trend, reducing false signals and improving win rates.
Q2: Can I use this for crypto markets?
A: Yes! The script supports any asset with time-based data, including cryptocurrencies.
Q3: How do I avoid clutter when monitoring multiple timeframes?
A: Use contrasting colors for candles and disable high/low markers for cleaner charts.
Q4: Is this compatible with TradingView’s free plan?
A: Yes, but custom timeframe inputs may require a Pro+ subscription for full functionality.
👉 Optimize your trading setup with institutional-grade tools and low latency execution.