RSI 1H/4H Multi-Level (REPAINT) - Hourly LimitWhat the script does
1) Indicator setup
Creates an overlay indicator named “RSI 1H/4H Multi-Level (REPAINT) - Hourly Limit” (overlay=true), so markers appear on the main price chart.
2) Inputs (user settings)
1 Hour Settings
len1h: RSI length for 1H (default 12)
lowL1h: lower threshold (default 30)
highL1h: upper threshold (default 70)
color1h: dot color for 1H-only triggers (default blue)
4 Hour Settings
len4h: RSI length for 4H (default 12)
lowL4h: lower threshold (default 30)
highL4h: upper threshold (default 70)
color4h: dot color for 4H-only triggers (default orange)
Visuals
showDots: toggle to show/hide dots on the chart
3) RSI calculation from higher timeframes (repainting)
Function:
rsi_htf(tf, length) uses request.security() to compute RSI from a higher timeframe:
gaps_off merges gaps smoothly
lookahead_on allows future higher-timeframe values to appear on earlier bars → repainting behavior
It calculates:
rsi1h = 1H RSI
rsi4h = 4H RSI
4) Alert frequency control (once per hour)
lastAlertHour stores the timestamp of the last alerted hourly candle start.
currentHourStart = time("60") gets the start time of the current 1-hour candle.
canAlert = currentHourStart > lastAlertHour ensures the script can only trigger once per new hour.
5) Cross conditions
Uses ta.cross() to detect RSI crossing either level (in either direction):
c1L: 1H RSI crosses the 1H lower level
c1H: 1H RSI crosses the 1H upper level
c4L: 4H RSI crosses the 4H lower level
c4H: 4H RSI crosses the 4H upper level
Then:
fire1h is true if either 1H cross happens
fire4h is true if either 4H cross happens
trigger is true if (1H or 4H cross) AND canAlert is true
6) Alert message and timer update
When trigger is true:
Updates lastAlertHour to the current hour start (blocks further alerts that hour)
Builds an English message indicating which timeframe(s) crossed and includes RSI values
Sends an alert with alert.freq_once_per_bar_close (one per bar close)
7) Chart visualization (dots)
Chooses dot color:
white if both 1H and 4H crossed within the allowed hour
color1h if only 1H crossed
color4h if only 4H crossed
Plots a small circle below the bar when showDots and trigger are true.
Indicador Pine Script®






















