- Why Most Dividend Yield Calculators Get It Wrong
- The GetDividend Function: Foundation of Dividend Analysis
- Two Dividend Yield Calculation Methods
- Smart Payout Frequency Detection
- Special Dividend Handling
- Threshold-Based Color Coding
- Chart Bubble Integration
- Error Handling and Edge Cases
- Real-World Application Examples
- Integration with Broader Dividend Strategy
- Advanced Customization Options
- Performance and Data Considerations
- Troubleshooting Common Issues
- Dividend Yield Indicator vs. Other Tools
- Building Your Dividend Investment Process
Follow in Pat Monroe’s Footsteps with Smart Dividend Analysis
During the Great Depression, banker Pat Monroe convinced his small town to invest in Coca-Cola shares. That single share is now worth over $10 million and generates $270,000 in annual dividends. This dividend yield indicator helps you find similar opportunities today.
What this dividend yield indicator provides:
- Two calculation methods: standard multiplier vs. 1-year lookback
- Automatic payout frequency detection and special dividend handling
- Color-coded threshold alerts for quick screening
- Chart bubbles showing yield directly on price action
- Works only on daily charts for accurate dividend data access
Perfect for dividend investors who want to analyze yield trends and identify attractive entry points.
For Volatility Box members, I have a special “Pro” version of this indicator available, which also includes a Fair Value Calculation, using the Dividend Discount Model.
Why Most Dividend Yield Calculators Get It Wrong
Most platforms show you current dividend yield, but they don’t handle special dividends correctly or let you analyze yield trends over time. This dividend yield indicator fixes those problems by giving you two calculation methods and visual analysis tools.
The Pat Monroe story isn’t just inspirational – it highlights how dividend analysis can uncover generational wealth opportunities. This dividend yield indicator helps you spot when quality dividend stocks are trading at unusually high yields.
The GetDividend Function: Foundation of Dividend Analysis
ThinkOrSwim’s GetDividend() function returns dividend amounts, but only on daily charts. The dividend yield indicator starts by capturing this data properly:
def dividend = if IsNaN(GetDividend()) then dividend[1] else GetDividend();
This creates a persistent dividend value that carries forward until the next ex-dividend date. But for summation calculations, we need a different approach:
def dividend2 = if IsNaN(GetDividend()) then 0 else GetDividend();
This second variable stores zero on non-dividend days, allowing accurate sum calculations for the 1-year lookback method.
Two Dividend Yield Calculation Methods
The dividend yield indicator offers two calculation approaches because each has advantages:
Method 1: Standard Multiplier
Takes the current dividend and multiplies by expected annual payouts:
dividendYield = (dividend * payoutsMult) / close;
This matches what you see on Yahoo Finance and other platforms. The dividend yield indicator automatically detects payout frequency and handles special dividends.
Method 2: 1-Year Lookback
Sums actual dividends paid over the past 252 trading days:
dividendYield = sumPastYrDividends / close;
This method captures special dividends and varying payout amounts more accurately. Your dividend yield indicator switches between methods via user input.
Smart Payout Frequency Detection
The dividend yield indicator automatically counts dividend payments over the past year:
def totalDividends = Sum(if IsNaN(GetDividend()) then 0 else 1, 252);
This counts actual dividend events, not just carries forward the same value. The dividend yield indicator then determines the appropriate multiplier:
def payoutsMult = if totalDividends >= 12 then 12 else 4;
If there are 12+ payments (monthly dividends), it uses 12. Otherwise, it assumes quarterly (4). This handles most dividend schedules automatically.
Special Dividend Handling
Companies like Permian Basin Royalty Trust (PRT) sometimes issue special dividends. The dividend yield indicator accounts for this by offering both calculation methods. When you see 5 payouts instead of 4, the 1-year lookback method includes that special dividend while the standard method doesn’t.
This flexibility makes the dividend yield indicator more accurate than simple online calculators that can’t distinguish between regular and special dividends.
Threshold-Based Color Coding
The dividend yield indicator includes visual alerts based on your threshold settings:
input threshold = 0.04; // 4% default threshold
When dividend yield exceeds your threshold, labels turn light green. When below, they turn yellow. This makes the dividend yield indicator perfect for screening multiple stocks quickly.
Set your threshold based on your dividend strategy – maybe 4% for conservative income investing or 6% for higher-yield hunting.
Chart Bubble Integration
The dividend yield indicator places bubbles directly on ex-dividend dates:
AddChartBubble(chartBubblesOn and getDividend(), close, AsPercent(dividendYield),
if dividendYield > threshold then color.light_green else color.yellow);
This shows you exactly what the yield was when each dividend was declared. Track yield trends over time and spot when current yields are unusually high or low compared to historical levels.
Error Handling and Edge Cases
The dividend yield indicator handles common problems:
Non-Dividend Stocks: Shows “This company does not pay dividends” for growth stocks
Wrong Timeframes: Assert function prevents use on intraday charts:
Assert(getAggregationPeriod() == AggregationPeriod.Day,
"The Dividend Yield indicator works on a daily time frame chart only.");
Data Availability: Only displays dividend information when totalDividends > 0
Real-World Application Examples
Verizon Analysis: The dividend yield indicator might show VZ with a 7.48% yield when historical average is 4.3-4.5%. This signals either opportunity (if company fundamentals are solid) or concern (if dividend cut is possible).
Special Dividend Detection: When PRT issues a special dividend, the 1-year lookback method in your dividend yield indicator captures the true annual yield including that special payment.
Monthly vs Quarterly: REITs often pay monthly. The dividend yield indicator automatically detects this and uses the 12x multiplier instead of 4x.
Integration with Broader Dividend Strategy
Use this dividend yield indicator as part of comprehensive dividend analysis:
Yield Trends: High current yields might indicate either opportunity or trouble. Check fundamentals to determine which.
Sector Comparison: Run the dividend yield indicator across utility stocks to find the highest-yielding names in the sector.
Historical Context: Use chart bubbles to see if current yield is high compared to the stock’s own history.
Entry Timing: Consider initiating positions when quality dividend stocks hit yield levels that historically provided good returns.
Advanced Customization Options
Enhance your dividend yield indicator with these modifications:
Dividend Growth Rate: Add calculations to show year-over-year dividend growth
Payout Ratio Integration: Combine with earnings data to calculate payout ratios
Sector Yield Comparison: Compare individual stock yield to sector ETF yield
Alert Integration: Add alerts when yield crosses above/below threshold levels
Performance and Data Considerations
The dividend yield indicator uses 252-day lookbacks for annual calculations. This provides accurate trailing 12-month data while maintaining reasonable performance.
GetDividend() function only works on daily charts because dividend data isn’t available on intraday timeframes. The Assert statement prevents confusion by blocking the indicator on wrong timeframes.
Troubleshooting Common Issues
No Labels Showing: Check that you’re on a daily chart and the stock actually pays dividends
Wrong Yield Calculations: Verify which calculation method you’re using and whether special dividends are involved
Chart Bubbles Missing: Ensure chartBubblesOn is set to yes and you’re viewing ex-dividend dates
Threshold Colors Wrong: Double-check your threshold percentage – remember it’s decimal format (0.04 = 4%)
Dividend Yield Indicator vs. Other Tools
Compared to basic yield displays:
More Accurate: Handles special dividends and varying payout schedules
Visual Analysis: Chart bubbles show yield trends over time
Customizable: Set your own thresholds and calculation methods
Integrated: Works directly in your ThinkOrSwim charts alongside technical analysis
Building Your Dividend Investment Process
Use this dividend yield indicator as part of a systematic approach:
Step 1: Screen for stocks with yields above your threshold using the color coding
Step 2: Analyze yield trends using chart bubbles – is current yield historically high?
Step 3: Compare both calculation methods – do they align or show discrepancies?
Step 4: Investigate fundamental reasons for unusual yield levels
Step 5: Consider position sizing based on yield sustainability analysis
The dividend yield indicator transforms basic yield analysis into a comprehensive tool for dividend investing. Like Pat Monroe identifying Coca-Cola’s opportunity during the Depression, this indicator helps you spot when quality dividend stocks are offering unusually attractive yields.
Whether you’re building a retirement income portfolio or seeking high-yield opportunities, this dividend yield indicator provides the analysis tools needed to make informed dividend investment decisions.
# Dividend Yield Indicator for ThinkOrSwim
# TOS Indicators
# Home of the Volatility Box
# Indicator: Dividend Yield
# Code written in 2023
// ... 57 more lines ...Here are some resources that you may find useful: