OPEN-SOURCE SCRIPT
Updated 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.
Release Notes
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
Release Notes
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.Release Notes
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
Release Notes
Priming Bars Breaking up and Breaking Down label added. Release Notes
Position Management table updated to reflect stat of current barRelease Notes
Few updates for better codeRelease Notes
Updated few thingsRelease Notes
Mini Coil updateRelease Notes
Coil logic updateRelease Notes
Addition of 19 Day Low Pivot LineRelease Notes
Fixed typo 19 , earlier it was 9 for 19 day pivot low.Release Notes
Added Base PivotsOpen-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.