OPEN-SOURCE SCRIPT
Trend Score HTF (Raw Data) Pine Screener

📘 Trend Score HTF (Raw Data) Pine Screener — Indicator Guide
This indicator tracks price action using a custom cumulative Trend Score (TS) system. It helps you visualize trend momentum, detect early reversals, confirm direction changes, and screen for entries across large watchlists like SPX500 using TradingView’s Pine Script Screener (beta).
⸻
🔧 What This Indicator Does
• Assigns a +1 or -1 score when price breaks the previous high or low
• Accumulates these scores into a real-time tsScore
• Detects early warnings (primed flips) and trend changes (confirmed flips)
• Supports alerts and labels for visual and automated trading
• Designed to work inside the Pine Screener so you can filter hundreds of tickers live
⸻
⚙️ Recommended Settings (for Beginners)
When adding the indicator to your chart:
Go to the “Inputs” tab at the top of the settings panel.
Then:
• Uncheck “Confirm flips on bar close”
• Check “Accumulate TS Across Flips? (ON = non-reset, OFF = reset)”
This setup allows you to see trend changes immediately without waiting for bar closes and lets the trend score build continuously over time, making it easier to follow long trends.
⸻
🧠 Core Logic
Start Date
Select a meaningful historical start date — for example: 2020-01-01. This provides long-term context for trend score calculation.
Per-Bar Delta (Δ) Calculation
The indicator scores each bar based on breakout behavior:
If the bar breaks only the previous high, Δ = +1
If it breaks only the previous low, Δ = -1
If it breaks both the high and low, Δ = 0
If it breaks neither, Δ = 0
This filters out wide-range or indecisive candles during volatility.
Cumulative Trend Score
Each bar’s delta is added to the running tsScore.
When it rises, bullish pressure is building.
When it falls, bearish pressure is increasing.
Trend Flip Logic
A bullish flip happens when tsScore rises by +3 from the lowest recent point.
A bearish flip happens when tsScore falls by -3 from the highest recent point.
These flips update the active trend direction between bullish and bearish.
⸻
⚠️ What Is a “Primed” Flip?
A primed flip is a signal that the current trend is about to flip — just one point away.
A primed bullish flip means the trend is currently bearish, but the tsScore only needs +1 more to flip. If the next bar breaks the previous high (without breaking the low), it will trigger a bullish flip.
A primed bearish flip means the trend is currently bullish, but the tsScore only needs -1 more to flip. If the next bar breaks the previous low (without breaking the high), it will trigger a bearish flip.
Primed flips are plotted one bar ahead of the current bar. They act like forecasts and give you a head start.
⸻
✅ What Is a “Confirmed” Flip?
A confirmed flip is the first bar of a new trend direction.
A confirmed bullish flip appears when a bearish trend officially flips into a new bullish trend.
A confirmed bearish flip appears when a bullish trend officially flips into a new bearish trend.
These signals are reliable and great for entries, trend filters, or reversals.
⸻
🖼 Visual Cues
The trend score (tsScore) line shows the accumulated trend strength.
A Δ histogram shows the daily price contribution: +1 for breaking highs, -1 for breaking lows, 0 otherwise.
A green background means the chart is in a bullish trend.
A red background means the chart is in a bearish trend.
A ⬆ label signals a primed bullish flip is possible on the next bar.
A ⬇ label signals a primed bearish flip is possible on the next bar.
A ✅ means a bullish flip just confirmed.
A ❌ means a bearish flip just confirmed.
⸻
🔔 Alerts You Can Use
The indicator includes these built-in alerts:
• Primed Bullish Flip — watch for possible bullish reversal tomorrow
• Primed Bearish Flip — watch for possible bearish reversal tomorrow
• Bullish Confirmed — official entry into new uptrend
• Bearish Confirmed — official entry into new downtrend
You can set these alerts in TradingView to monitor across your chart or watchlist.
⸻
📈 How to Use in TradingView Pine Screener

Step 1: Create your own watchlist — for example, SPX500
Step 2: Favorite this indicator so it shows up in the screener
Step 3: Go to TradingView → Products → Screeners → Pine (Beta)
Step 4: Select this indicator and choose a condition, like “Bullish Confirmed”
Step 5: Click Scan
You’ll instantly see stocks that just flipped trends or are close to doing so.
⸻
⏰ When to Use the Screener
Use this screener after market close or before the next open to avoid intraday noise.
During the day, if a candle breaks both the high and low, the delta becomes 0, which may cancel a flip or primed signal.
Results during regular trading hours can change frequently. For best results, scan during stable periods like pre-market or after-hours.
⸻
🧪 Real-World Examples
SWK
NVR
WMT
UNH
Each of these examples shows clean, structured trend transitions detected in advance or confirmed with precision.
PLTR: complicated case primed for bullish (but we don't when it will flip)

⚠️ Risk Disclaimer & Trend Context
A confirmed bullish signal does not guarantee an immediate price increase. Price may continue to consolidate or even pull back after a bullish flip.
Likewise, a primed bullish signal does not always lead to confirmation. It simply means the conditions are close — but if the next bar breaks both the high and low, or breaks only the low, the flip will be canceled.
On the other side, a confirmed bearish signal does not mean the market will crash. If the overall trend is bullish (for example, tsScore has been rising for weeks), then a bearish flip may just represent a short-term pullback — not a trend reversal.
You always need to consider the overall market structure. If the long-term trend is bullish, it’s usually smarter to wait for bullish confirmation signals. Bearish flips in that context are often just dips — not opportunities to short.
This indicator gives you context, not predictions. It’s a tool for alignment — not absolute outcomes. Use it to follow structure, not fight it.
This indicator tracks price action using a custom cumulative Trend Score (TS) system. It helps you visualize trend momentum, detect early reversals, confirm direction changes, and screen for entries across large watchlists like SPX500 using TradingView’s Pine Script Screener (beta).
⸻
🔧 What This Indicator Does
• Assigns a +1 or -1 score when price breaks the previous high or low
• Accumulates these scores into a real-time tsScore
• Detects early warnings (primed flips) and trend changes (confirmed flips)
• Supports alerts and labels for visual and automated trading
• Designed to work inside the Pine Screener so you can filter hundreds of tickers live
⸻
⚙️ Recommended Settings (for Beginners)
When adding the indicator to your chart:
Go to the “Inputs” tab at the top of the settings panel.
Then:
• Uncheck “Confirm flips on bar close”
• Check “Accumulate TS Across Flips? (ON = non-reset, OFF = reset)”
This setup allows you to see trend changes immediately without waiting for bar closes and lets the trend score build continuously over time, making it easier to follow long trends.
⸻
🧠 Core Logic
Start Date
Select a meaningful historical start date — for example: 2020-01-01. This provides long-term context for trend score calculation.
Per-Bar Delta (Δ) Calculation
The indicator scores each bar based on breakout behavior:
If the bar breaks only the previous high, Δ = +1
If it breaks only the previous low, Δ = -1
If it breaks both the high and low, Δ = 0
If it breaks neither, Δ = 0
This filters out wide-range or indecisive candles during volatility.
Cumulative Trend Score
Each bar’s delta is added to the running tsScore.
When it rises, bullish pressure is building.
When it falls, bearish pressure is increasing.
Trend Flip Logic
A bullish flip happens when tsScore rises by +3 from the lowest recent point.
A bearish flip happens when tsScore falls by -3 from the highest recent point.
These flips update the active trend direction between bullish and bearish.
⸻
⚠️ What Is a “Primed” Flip?
A primed flip is a signal that the current trend is about to flip — just one point away.
A primed bullish flip means the trend is currently bearish, but the tsScore only needs +1 more to flip. If the next bar breaks the previous high (without breaking the low), it will trigger a bullish flip.
A primed bearish flip means the trend is currently bullish, but the tsScore only needs -1 more to flip. If the next bar breaks the previous low (without breaking the high), it will trigger a bearish flip.
Primed flips are plotted one bar ahead of the current bar. They act like forecasts and give you a head start.
⸻
✅ What Is a “Confirmed” Flip?
A confirmed flip is the first bar of a new trend direction.
A confirmed bullish flip appears when a bearish trend officially flips into a new bullish trend.
A confirmed bearish flip appears when a bullish trend officially flips into a new bearish trend.
These signals are reliable and great for entries, trend filters, or reversals.
⸻
🖼 Visual Cues
The trend score (tsScore) line shows the accumulated trend strength.
A Δ histogram shows the daily price contribution: +1 for breaking highs, -1 for breaking lows, 0 otherwise.
A green background means the chart is in a bullish trend.
A red background means the chart is in a bearish trend.
A ⬆ label signals a primed bullish flip is possible on the next bar.
A ⬇ label signals a primed bearish flip is possible on the next bar.
A ✅ means a bullish flip just confirmed.
A ❌ means a bearish flip just confirmed.
⸻
🔔 Alerts You Can Use
The indicator includes these built-in alerts:
• Primed Bullish Flip — watch for possible bullish reversal tomorrow
• Primed Bearish Flip — watch for possible bearish reversal tomorrow
• Bullish Confirmed — official entry into new uptrend
• Bearish Confirmed — official entry into new downtrend
You can set these alerts in TradingView to monitor across your chart or watchlist.
⸻
📈 How to Use in TradingView Pine Screener
Step 1: Create your own watchlist — for example, SPX500
Step 2: Favorite this indicator so it shows up in the screener
Step 3: Go to TradingView → Products → Screeners → Pine (Beta)
Step 4: Select this indicator and choose a condition, like “Bullish Confirmed”
Step 5: Click Scan
You’ll instantly see stocks that just flipped trends or are close to doing so.
⸻
⏰ When to Use the Screener
Use this screener after market close or before the next open to avoid intraday noise.
During the day, if a candle breaks both the high and low, the delta becomes 0, which may cancel a flip or primed signal.
Results during regular trading hours can change frequently. For best results, scan during stable periods like pre-market or after-hours.
⸻
🧪 Real-World Examples
SWK
NVR
WMT
UNH
Each of these examples shows clean, structured trend transitions detected in advance or confirmed with precision.
PLTR: complicated case primed for bullish (but we don't when it will flip)
⚠️ Risk Disclaimer & Trend Context
A confirmed bullish signal does not guarantee an immediate price increase. Price may continue to consolidate or even pull back after a bullish flip.
Likewise, a primed bullish signal does not always lead to confirmation. It simply means the conditions are close — but if the next bar breaks both the high and low, or breaks only the low, the flip will be canceled.
On the other side, a confirmed bearish signal does not mean the market will crash. If the overall trend is bullish (for example, tsScore has been rising for weeks), then a bearish flip may just represent a short-term pullback — not a trend reversal.
You always need to consider the overall market structure. If the long-term trend is bullish, it’s usually smarter to wait for bullish confirmation signals. Bearish flips in that context are often just dips — not opportunities to short.
This indicator gives you context, not predictions. It’s a tool for alignment — not absolute outcomes. Use it to follow structure, not fight it.
Skrypt open-source
W duchu TradingView twórca tego skryptu udostępnił go jako open-source, aby traderzy mogli analizować i weryfikować jego funkcjonalność. Brawo dla autora! Możesz korzystać z niego za darmo, ale pamiętaj, że ponowna publikacja kodu podlega naszym Zasadom Społeczności.
Wyłączenie odpowiedzialności
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.
Skrypt open-source
W duchu TradingView twórca tego skryptu udostępnił go jako open-source, aby traderzy mogli analizować i weryfikować jego funkcjonalność. Brawo dla autora! Możesz korzystać z niego za darmo, ale pamiętaj, że ponowna publikacja kodu podlega naszym Zasadom Społeczności.
Wyłączenie odpowiedzialności
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.