OPEN-SOURCE SCRIPT
Aggiornato Sentry Mode: Dynamic Trend & Exit System

Sentry Mode is designed for traders who prioritize risk management and structural trend alignment. It eliminates the guesswork of "How much should I buy?" by calculating your exact share count based on a live-tracking stop loss.
Core Features
1. The Sentry Position Manager (Quantitative Table)
The centerpiece of this script is a real-time data table that calculates:
Target vs. Actual Risk: Sees the gap between your desired equity risk and the actual dollar amount at stake after share rounding.
Dynamic Stop (Ribbon Top): The stop loss isn't a fixed percentage; it tracks the Low of the leading Moving Average in the ribbon, providing a "trailing floor."
Position Sizing: Automatically calculates shares based on your Account Size and Max Position % cap.
Invalid Price Filter: The Sentry will reject trade calculations (showing "PRICE BELOW STOP") if the asset is currently trading below the structural floor.
2. Structural Trend Ribbon
5-MA Cluster: Uses up to five user-selectable Moving Averages (SMA, EMA, WMA, etc.) to visualize trend strength.
Ribbon Top Analysis: Automatically identifies the "Fastest" MA to set the current trend boundary.
3rd MA Floor: Identifies the "meat" of the trend, serving as a secondary structural exit for trailing stops.
3. Multi-Timeframe Pivot Analysis
The script identifies and draws institutional-grade levels:
52-Week Highs: Tracks and extends 52-week highs with automated "Broken Line" logic when price clears the level.
Multi-Day Pivots: Visualizes 5-day, 9-day, 19-day, and 90-day pivot highs to identify supply zones and breakout entries.
Downtrend Resistance: Automatically plots 19-bar downward trendlines to identify "Cheat" entries and downtrend breaks.
4. SPY Market Context Filter
Broad Market Alignment: Includes a background color filter based on SPY (S&P 500) trend health.
ATR Volatility Scaling: The background changes intensity (L1, L2, L3) based on SPY’s ATR, warning you when the broad market is undergoing a "normal pullback" versus a "high-volatility breakdown."
4. How to Use
Define your Bankroll: In the settings, input your total Account Size and the percentage of equity you are willing to risk per trade (e.g., 0.25%).
Confirm the Trend: Look for price to be above the Ribbon Top. Ensure the SPY Context background is green.
Execute via Sentry Table: Read the "Shares" and "Pos Size" directly from the on-screen table.
Manage the Exit: The red dashed Sentry Line shows your floor. If price closes below this line (or the 3rd MA), the trend structure is broken.
5. Technical Details (For the Sidebar)
Signal Type: Trend-Following / Momentum.
Core Features
1. The Sentry Position Manager (Quantitative Table)
The centerpiece of this script is a real-time data table that calculates:
Target vs. Actual Risk: Sees the gap between your desired equity risk and the actual dollar amount at stake after share rounding.
Dynamic Stop (Ribbon Top): The stop loss isn't a fixed percentage; it tracks the Low of the leading Moving Average in the ribbon, providing a "trailing floor."
Position Sizing: Automatically calculates shares based on your Account Size and Max Position % cap.
Invalid Price Filter: The Sentry will reject trade calculations (showing "PRICE BELOW STOP") if the asset is currently trading below the structural floor.
2. Structural Trend Ribbon
5-MA Cluster: Uses up to five user-selectable Moving Averages (SMA, EMA, WMA, etc.) to visualize trend strength.
Ribbon Top Analysis: Automatically identifies the "Fastest" MA to set the current trend boundary.
3rd MA Floor: Identifies the "meat" of the trend, serving as a secondary structural exit for trailing stops.
3. Multi-Timeframe Pivot Analysis
The script identifies and draws institutional-grade levels:
52-Week Highs: Tracks and extends 52-week highs with automated "Broken Line" logic when price clears the level.
Multi-Day Pivots: Visualizes 5-day, 9-day, 19-day, and 90-day pivot highs to identify supply zones and breakout entries.
Downtrend Resistance: Automatically plots 19-bar downward trendlines to identify "Cheat" entries and downtrend breaks.
4. SPY Market Context Filter
Broad Market Alignment: Includes a background color filter based on SPY (S&P 500) trend health.
ATR Volatility Scaling: The background changes intensity (L1, L2, L3) based on SPY’s ATR, warning you when the broad market is undergoing a "normal pullback" versus a "high-volatility breakdown."
4. How to Use
Define your Bankroll: In the settings, input your total Account Size and the percentage of equity you are willing to risk per trade (e.g., 0.25%).
Confirm the Trend: Look for price to be above the Ribbon Top. Ensure the SPY Context background is green.
Execute via Sentry Table: Read the "Shares" and "Pos Size" directly from the on-screen table.
Manage the Exit: The red dashed Sentry Line shows your floor. If price closes below this line (or the 3rd MA), the trend structure is broken.
5. Technical Details (For the Sidebar)
Signal Type: Trend-Following / Momentum.
Note di rilascio
Added Alerts for different conditionsAdded Reference stop and target levels with price and % for better visuals of risk reward from Buy alert
It will work on Pine screener
Note di rilascio
Updated to remove extra plots, improvements to use pine screener export for portfolio approach. like, if you use sma50 for stop loss, then screen your portfolio watchlist and export the results for position size dollar risk and other parameters to excel and check how much are you invested if you are using this risk management approach and open portfolio heat.Note di rilascio
Added Two AlertsIf used on pine screener you stocks which are strong in strong market and strong in week market.
Sentry: Trend Strong With Market
Sentry: Trend Strong Against Market
Note di rilascio
Priming Bars Breaking up and Breaking Down label added. Note di rilascio
Position Management table updated to reflect stat of current barNote di rilascio
Few updates for better codeNote di rilascio
Updated few thingsNote di rilascio
Mini Coil updateNote di rilascio
Coil logic updateNote di rilascio
Addition of 19 Day Low Pivot LineNote di rilascio
Fixed typo 19 , earlier it was 9 for 19 day pivot low.Note di rilascio
Added Base PivotsScript open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.