Calculate the angle of a trendline

blooey

New member
Hi all,

I'm new to the forum but have found a few great indicators that have helped me tremendously...like the SSL Hybrid and super trend. Thanks to all who have translated these to thinkscript.

My question: is there an accurate way to calculate the actual angle of 2 points in thinkscript? I'm aware of how to calculate the slope mathematically, but on a chart, X can vary based on how large the candlesticks are displayed and there doesn't seem to be a way to get the current size of a chart's candle X size. It would be nice to know the angle of a moving average/trend line to gauge how strong the trend is.

Anyone know how to do this in thinkscript?
 
@blooey The term you are looking for is "slope" in your searches... There are several indicators in these forums that address "slope"... However, there is one caveat to slope... It will vary based on zoom levels... The slope will change as zoom is increased/decreased, which is why there are so few implementations... Slope is relative rather than finite...

That being said, the TOS Trendline drawing tool can display the angle of the line when you hover over the line once drawn... But, again, that angle will change based on zoom...

For this reason, "trend" means more than "slope" or "angle"... Focus on what really counts and doesn't change due to zoom or timeframe...
 
Hi all,

I'm new to the forum but have found a few great indicators that have helped me tremendously...like the SSL Hybrid and super trend. Thanks to all who have translated these to thinkscript.

My question: is there an accurate way to calculate the actual angle of 2 points in thinkscript? I'm aware of how to calculate the slope mathematically, but on a chart, X can vary based on how large the candlesticks are displayed and there doesn't seem to be a way to get the current size of a chart's candle X size. It would be nice to know the angle of a moving average/trend line to gauge how strong the trend is.

Anyone know how to do this in thinkscript?
Since the x-values are evenly spaced (generally time based data) - your "run" between any any two adjacent candles will be 1.
The "rise" or difference between the candles in value. Such as (close - close[1]) that is the close compared to the prior close.

Slope is rise/run or (close - close[1]) / 1 And this equals (close - close[1]).

Similarly valid slopes could be:
(open - open[3]) / 3 --- The slope of the open compared to 3 periods prior.
(MovingAvg - MovingAvg[10]) / 10 --- The slope of a defined moving average compared to its value 10 periods ago.
 

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
659 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