OPEN-SOURCE SCRIPT
Timeframe Traffic Lights

TIMEFRAME TRAFFIC LIGHTS
See the trend on five timeframes at a glance, in one small box on your chart.
OVERVIEW
Timeframe Traffic Lights shows a row of coloured dots, one for each timeframe you choose. Green means that timeframe is trending up, red means down, and grey means there is no clear trend. When the dots agree, the trend is strong across the board. When they disagree, the market is mixed.
It draws nothing else on your chart, so it stays out of the way of your candles and your other indicators. It works on any chart timeframe, because each light looks at its own timeframe separately. It is a visual tool only. It does not give buy or sell signals and it does not place trades.
HOW EACH LIGHT DECIDES ITS COLOUR
Each light uses two average-price lines (moving averages): a fast one that follows the last 20 candles and a slow one that follows the last 50. On each timeframe the script checks how price and those two lines are lined up:
This is deliberately simple and easy to understand. You can change the 20 and 50 in the settings.
THE DEFAULT TIMEFRAMES
15m, 30m, 1h, 4h and 1D. You can change any of the five in the settings.
WHAT YOU SEE IN THE BOX
Row 1: timeframe names
The short name of each timeframe (15m, 30m, 1h, 4h, 1D).
Row 2: the dots
One dot per timeframe in green, red or grey.
Strength shading
A bright, solid dot means the trend is strong. A faded dot means the trend is there but weak or young. Grey dots are never faded, since there is no trend to measure. Strength is worked out by comparing the gap between the two average lines with the typical size of a candle on that timeframe (the average candle range over the last 14 candles). Using candle size keeps it fair across timeframes, so the same setting works on the 15m and on the daily. Fading only changes how a dot looks. A faded green dot still counts as green.
Recently-flipped marker (✦)
A small ✦ appears under any light that changed colour within the last 3 candles of its own timeframe. On the daily that means the last 3 days, and on the 15m it means the last 45 minutes. The ✦ takes the colour the light changed to. It sits in its own row that shows a blank space when nothing has flipped, so the box doesn't jump in height.
Candle countdown
The time left until each timeframe's current candle closes, shown as hours and minutes like 03:05. It uses a fixed format so the box doesn't change width as the numbers change. For timeframes of a day or more it shows days and hours, like 2d05h. The text is soft grey normally, and turns amber when less than 10% of that candle is left. That's the moment a dot is most likely to change.
Overall reading
One line under the dots that sums up all five:
- ▲ 4 of 5 UP (green)
- ▼ 3 of 5 DOWN (red)
- MIXED (grey)
A direction is only called when enough lights agree (3 out of 5 by default). Anything short of that reads as MIXED, and so does a tie between green and red.
Colour key (optional)
A row at the bottom explaining the colours: Up, Down, Mix and ✦ New. It's off by default to keep the box small.
ALERTS
You get an alert at the moment all five lights turn green ("all timeframes UP") or all five turn red ("all timeframes DOWN"). It fires once when they line up, not on every candle while they stay lined up.
To set it up: click Create Alert, choose Timeframe Traffic Lights as the condition, then select "Any alert() function call".
SETTINGS
Timeframes
Trend
Extras (each can be switched on or off)
Look
UPDATE ONLY WHEN A CANDLE CLOSES
By default the lights are live, so a dot can flip while that timeframe's candle is still forming. With "Update lights only when a candle closes" turned on, each light shows the reading from that timeframe's last finished candle. The dots stop flipping mid-candle, which means fewer false flips. The trade-off is that they react later, by up to one candle of that timeframe. The ✦ markers and the all-lights alert follow the same delay.
HOW TO READ IT
HOW TO USE
1. Add the indicator and open its settings.
2. Choose the five timeframes you care about.
3. Set the box position and text size. Tiny works best on a phone.
4. If the box is too tall, turn off the ✦ marker or the countdown.
5. Create an alert if you want to be told when all five lights agree.
Tips
GOOD TO KNOW
DISCLAIMER
This script is a visualisation tool for educational and informational purposes only. It is not financial advice and does not guarantee any results. Trading carries risk, so always manage your own risk.
See the trend on five timeframes at a glance, in one small box on your chart.
OVERVIEW
Timeframe Traffic Lights shows a row of coloured dots, one for each timeframe you choose. Green means that timeframe is trending up, red means down, and grey means there is no clear trend. When the dots agree, the trend is strong across the board. When they disagree, the market is mixed.
It draws nothing else on your chart, so it stays out of the way of your candles and your other indicators. It works on any chart timeframe, because each light looks at its own timeframe separately. It is a visual tool only. It does not give buy or sell signals and it does not place trades.
HOW EACH LIGHT DECIDES ITS COLOUR
Each light uses two average-price lines (moving averages): a fast one that follows the last 20 candles and a slow one that follows the last 50. On each timeframe the script checks how price and those two lines are lined up:
- Green: price is above the fast line, and the fast line is above the slow line. The trend is up.
- Red: price is below the fast line, and the fast line is below the slow line. The trend is down.
- Grey: anything in between. There is no clear trend.
This is deliberately simple and easy to understand. You can change the 20 and 50 in the settings.
THE DEFAULT TIMEFRAMES
15m, 30m, 1h, 4h and 1D. You can change any of the five in the settings.
WHAT YOU SEE IN THE BOX
Row 1: timeframe names
The short name of each timeframe (15m, 30m, 1h, 4h, 1D).
Row 2: the dots
One dot per timeframe in green, red or grey.
Strength shading
A bright, solid dot means the trend is strong. A faded dot means the trend is there but weak or young. Grey dots are never faded, since there is no trend to measure. Strength is worked out by comparing the gap between the two average lines with the typical size of a candle on that timeframe (the average candle range over the last 14 candles). Using candle size keeps it fair across timeframes, so the same setting works on the 15m and on the daily. Fading only changes how a dot looks. A faded green dot still counts as green.
Recently-flipped marker (✦)
A small ✦ appears under any light that changed colour within the last 3 candles of its own timeframe. On the daily that means the last 3 days, and on the 15m it means the last 45 minutes. The ✦ takes the colour the light changed to. It sits in its own row that shows a blank space when nothing has flipped, so the box doesn't jump in height.
Candle countdown
The time left until each timeframe's current candle closes, shown as hours and minutes like 03:05. It uses a fixed format so the box doesn't change width as the numbers change. For timeframes of a day or more it shows days and hours, like 2d05h. The text is soft grey normally, and turns amber when less than 10% of that candle is left. That's the moment a dot is most likely to change.
Overall reading
One line under the dots that sums up all five:
- ▲ 4 of 5 UP (green)
- ▼ 3 of 5 DOWN (red)
- MIXED (grey)
A direction is only called when enough lights agree (3 out of 5 by default). Anything short of that reads as MIXED, and so does a tie between green and red.
Colour key (optional)
A row at the bottom explaining the colours: Up, Down, Mix and ✦ New. It's off by default to keep the box small.
ALERTS
You get an alert at the moment all five lights turn green ("all timeframes UP") or all five turn red ("all timeframes DOWN"). It fires once when they line up, not on every candle while they stay lined up.
To set it up: click Create Alert, choose Timeframe Traffic Lights as the condition, then select "Any alert() function call".
SETTINGS
Timeframes
- Timeframe 1 to 5: which timeframes get a light
Trend
- Fast average length (default 20)
- Slow average length (default 50)
- Lights needed to call a direction (default 3 out of 5). Set it to 4 or 5 for a stricter overall reading, or 1 to react to any single light that beats the other side
Extras (each can be switched on or off)
- Fade the dot when the trend is weak
- Trend counts as strong at this gap (default 1.0). A lower number makes more dots bright, and a higher number makes fewer
- Mark lights that just changed colour (✦), and how many candles count as "just changed" (default 3)
- Show candle countdown
- Update lights only when a candle closes
- Show colour key
- Alert when all 5 lights agree
Look
- Box position: top left, top right, bottom left or bottom right (default bottom right)
- Text size: Tiny, Small, Normal or Large (default Small)
UPDATE ONLY WHEN A CANDLE CLOSES
By default the lights are live, so a dot can flip while that timeframe's candle is still forming. With "Update lights only when a candle closes" turned on, each light shows the reading from that timeframe's last finished candle. The dots stop flipping mid-candle, which means fewer false flips. The trade-off is that they react later, by up to one candle of that timeframe. The ✦ markers and the all-lights alert follow the same delay.
HOW TO READ IT
- All dots the same colour: every timeframe agrees, so the trend is strong across the board
- Mixed colours: the timeframes disagree. A short-term move may be going against the bigger picture
- Bright dots: the trend is well established
- Faded dots: the trend is weak or has only just started
- A fresh ✦ on a fast timeframe while the slow ones haven't moved: an early hint that something may be turning, and worth watching
- An amber countdown: that candle is about to close, so a dot may change soon
- Big timeframes (4h, 1D) usually move slowly, so a change there tends to matter more than a change on the 15m
HOW TO USE
1. Add the indicator and open its settings.
2. Choose the five timeframes you care about.
3. Set the box position and text size. Tiny works best on a phone.
4. If the box is too tall, turn off the ✦ marker or the countdown.
5. Create an alert if you want to be told when all five lights agree.
Tips
- Turn on "Update lights only when a candle closes" if you find the dots flip too often
- Turn on the colour key for a few days while you learn the symbols, then switch it off
- On a phone, use the Tiny text size and keep the extras you actually look at
GOOD TO KNOW
- Moving averages follow price, so the lights describe what has been happening, not what will happen. A green light does not mean price will keep rising
- In live mode, a dot (and the all-lights alert) can change while a candle is still forming, and can change back before it closes. Use the candle-close option if that bothers you
- Each timeframe needs about 50 candles of history loaded for its slow line to settle. On very short histories the first readings may look odd
- The strength setting is a starting point. The default of 1.0 is a guess that suits many markets, so adjust it until the bright and faded dots look right for your symbol
- The daily candle countdown follows your data feed's own day. For most Bitcoin feeds that is midnight UTC, not midnight in your local time
- On a market that is closed, the countdown may look odd or show --:--
- The number of lights is fixed at five. You can change which timeframes they use, but not how many there are
- The countdown updates whenever new price data arrives, so on a quiet chart it can lag by a few seconds
DISCLAIMER
This script is a visualisation tool for educational and informational purposes only. It is not financial advice and does not guarantee any results. Trading carries risk, so always manage your own risk.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
نص برمجي مفتوح المصدر
بروح TradingView الحقيقية، قام مبتكر هذا النص البرمجي بجعله مفتوح المصدر، بحيث يمكن للمتداولين مراجعة وظائفه والتحقق منها. شكرا للمؤلف! بينما يمكنك استخدامه مجانًا، تذكر أن إعادة نشر الكود يخضع لقواعد الموقع الخاصة بنا.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.