Candle Color From Other Asset

143
Candle Color From Other Asset

OVERVIEW
This indicator colors the candles on your current chart based on the price action of a different asset that you choose. For example, you can trade BTCUSDT.P on Bybit while the candles show whether Gold (XAUUSD) is currently moving up or down. This makes it easy to see intermarket relationships and spot when two assets are moving together or diverging, without switching charts or adding a second pane.

HOW IT WORKS
The script requests the open and close data of your chosen reference asset using request.security() on the same timeframe as your chart. It then compares the values and colors each candle on your chart:

- Reference candle up: colored with the "up" color
- Reference candle down: colored with the "down" color
- No data or doji: colored with the neutral color (optional)

Two color logics are available:
1. Close vs Open: colors by the reference asset's own candle direction
2. Close vs Previous Close: colors by whether the reference closed higher or lower than the previous bar

An "Invert colors" option flips the colors, which is useful when studying inversely correlated assets (for example, USD index vs BTC).

HOW TO USE
1. Add the indicator to any chart.
2. Open the settings and click "Reference asset" to search for any symbol from TradingView's list.
3. Choose the color logic and your preferred colors.
4. For the clearest result, go to chart settings > Symbol and turn off Body, Borders and Wick styling for your main candles, or set them to match, so the indicator's colors are not hidden by the default candle colors.

NOTES
- The reference asset is read on the same timeframe as your chart (a 15m chart uses 15m reference candles).
- Markets with different trading hours (for example Gold, which is closed on weekends, vs crypto) will show neutral candles when the reference has no data. This can be turned off in the settings.
- The script uses barmerge.lookahead_off, so it does not repaint on historical bars.

CREDITS
Written in Pine Script v6 with the help of Claude, an AI assistant by Anthropic. I described the idea and Claude helped write and refine the code.

DISCLAIMER
This indicator is for educational and informational purposes only. It does not provide trading signals or financial advice. Correlation between assets can change or break at any time. Always do your own research and manage your risk.

Thông báo miễn trừ trách nhiệm

Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.