PROTECTED SOURCE SCRIPT
4H Synced Direction Divergence Alert US100 US500 US30

Overview
This script monitors three index symbols on a 4-hour (4H) basis and triggers an alert only when their last completed 4H candles are time-synchronized and their directions diverge (i.e., not all close in the same direction).
What it does
Compares the 4H candle direction (UP / DOWN / FLAT) across:
US100 (reference clock)
US500
US30
Sends an alert on the confirmed close of the 4H candle (not mid-candle).
Includes a detailed alert message showing:
the 4H close time
direction for each symbol
open, close, and the close-open delta
How it works (high level)
Reference clock (sync anchor):
The script uses Symbol 1 as the timing reference for 4H candle boundaries.
Strict bar synchronization:
It validates that all three symbols share the same 4H time_close before comparing directions.
If any symbol is missing that specific 4H bar (gap) or doesn’t align to the same close timestamp, no alert is triggered.
No repaint / no lookahead:
Data is requested without looking ahead, so the comparison is based on completed candles only.
Duplicate protection:
The script remembers the last fired 4H close time and prevents repeated alerts caused by recalculation.
How to use
Add the script to a clean chart.
Set your preferred symbols in the inputs (default: US100 / US500 / US30).
Create an alert:
Condition: select this script
Choose “Any alert() function call” (required, because the script uses alert() for detailed messages)
When a synchronized 4H close occurs and directions diverge, you will receive a detailed notification.
Inputs
Comparison TF: default 240 (4H)
Symbol 1 (Reference clock): default CAPITALCOM:US100
Symbol 2: default CAPITALCOM:US500
Symbol 3: default CAPITALCOM:US30
Timezone for alert message: controls only the displayed timestamp in the alert text
Notes / limitations
This script is designed for cross-symbol candle comparison, so alignment matters. If your symbols have different trading sessions, gaps, or data availability, the script may intentionally skip alerts when candles are not perfectly synchronized.
The script is an informational alert tool and is not a trading signal by itself. Always confirm context, liquidity, and market conditions.
This script monitors three index symbols on a 4-hour (4H) basis and triggers an alert only when their last completed 4H candles are time-synchronized and their directions diverge (i.e., not all close in the same direction).
What it does
Compares the 4H candle direction (UP / DOWN / FLAT) across:
US100 (reference clock)
US500
US30
Sends an alert on the confirmed close of the 4H candle (not mid-candle).
Includes a detailed alert message showing:
the 4H close time
direction for each symbol
open, close, and the close-open delta
How it works (high level)
Reference clock (sync anchor):
The script uses Symbol 1 as the timing reference for 4H candle boundaries.
Strict bar synchronization:
It validates that all three symbols share the same 4H time_close before comparing directions.
If any symbol is missing that specific 4H bar (gap) or doesn’t align to the same close timestamp, no alert is triggered.
No repaint / no lookahead:
Data is requested without looking ahead, so the comparison is based on completed candles only.
Duplicate protection:
The script remembers the last fired 4H close time and prevents repeated alerts caused by recalculation.
How to use
Add the script to a clean chart.
Set your preferred symbols in the inputs (default: US100 / US500 / US30).
Create an alert:
Condition: select this script
Choose “Any alert() function call” (required, because the script uses alert() for detailed messages)
When a synchronized 4H close occurs and directions diverge, you will receive a detailed notification.
Inputs
Comparison TF: default 240 (4H)
Symbol 1 (Reference clock): default CAPITALCOM:US100
Symbol 2: default CAPITALCOM:US500
Symbol 3: default CAPITALCOM:US30
Timezone for alert message: controls only the displayed timestamp in the alert text
Notes / limitations
This script is designed for cross-symbol candle comparison, so alignment matters. If your symbols have different trading sessions, gaps, or data availability, the script may intentionally skip alerts when candles are not perfectly synchronized.
The script is an informational alert tool and is not a trading signal by itself. Always confirm context, liquidity, and market conditions.
受保护脚本
此脚本以闭源形式发布。 但是,您可以自由使用,没有任何限制 — 了解更多信息这里。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
受保护脚本
此脚本以闭源形式发布。 但是,您可以自由使用,没有任何限制 — 了解更多信息这里。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。