Custom Dividend Yield Quote Column

FreshD

New member
I'm brand new here, hi to everyone! This looks like an excellent knowledge share site for TOS. I was trying to script a custom quote to display a column on my watchlist for the prior year's dividend yield in percent. Mainly so that I can create columns for the prior 5 years of dividend yield (years 1-5) and see at a glance how the yield has changed compared to the 5 year avg and current dividend. TOS has prebuilt quotes for the yield % (current dividend) and the dividend yield (annual yield) but not for prior years. I was trying to modify the code I have below using the close() function in plain text, which runs in the thinkscript fine. When I change the function from "close()" to "getdividend()" or "getyield()" I receive errors from the thinkscript I have not been able to overcome. I was unable to paste a screenshot on the post, and the link I inserted to my google drive of the image was marked as spam, and I was unable to submit it. Any help would be appreciated.

"def agg = AggregationPeriod.YEAR;
plot data = close(period = agg)"(y)

"def agg = AggregationPeriod.YEAR;
plot data = GetDividend(period = agg)[1];"👎

*No such parameter: period at 2:13
*0 params expected but 1 found while calling getdividend at 2:13
 
What I am basically trying to do is just convert my dividend per share quote columns (Current annual dividend, 2021 annual dividend, 2020 annual dividend, 2019 annual dividend...) into dividend yield columns so I can see them in percentage. Would it be possible to say divide this function by the price (price of the last trading day per each year, or yearly H+L/2, etc) to create a new custom quote for each? My last attempt can be seen in the code below with quotations and with an asterisk next to the error. Also, how do I pull the price at the time the dividend was paid or the last trading day for each dividend year or period? Will the script use the same period for price (same bar) as the "DividendsPerShareTTM()".

"def price = hl2;
DividendsPerShareTTM()/price;"

*Invalid statement: DividendsPerShareTTM at 2:1
 
Last edited by a moderator:
The ToS platform provides us the ability to display some of the fundamentals in watchlist columns but it doesn't allow us to utilize them in watchlist scripts.
 
The ToS platform provides us the ability to display some of the fundamentals in watchlist columns but it doesn't allow us to utilize them in watchlist scripts.
Is there a way calculate the dividend yield for each year in a script without using fundamentals that are not allowed in watchlist scripts?
 
Is there a way calculate the dividend yield for each year in a script without using fundamentals that are not allowed in watchlist scripts?
If you have a formula for calculating dividend yields which does not use Financial Fundamental data, you could try it in a watchlist script.
 

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
402 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top