Trend Angle For ThinkOrSwim

GpInvest

New member
RE: really impressive TREND indicator
The author states:
The "Trend Angle" indicator serves as a tool for traders to decipher market trends through a methodical lens. It quantifies the inclination of price movements within a specified timeframe, making it easy to understand current trend dynamics.

Conceptual Foundation:
Angle Measurement:
The essence of the "Trend Angle" indicator is its ability to compute the angle between the price trajectory over a defined period and the horizontal axis. This is achieved through the calculation of the arctangent of the percentage price change, offering a straightforward measure of market directionality.

Smoothing Mechanisms: The indicator incorporates options for "Moving Average" and "Linear Regression" as smoothing mechanisms. This adaptability allows for refined trend analysis, catering to diverse market conditions and individual preferences.

nNndEen.png

Good morning
I find this indicator (TREND ANGLE) really usefull and i tried to find something similar here to use it on ToS without success.
if anyone is so kinde to look at him and see if a conversion is possible I thiink the comunity could have a great tools to filter bad entry and even get into good one fast
https://www.tradingview.com/script/5xNrSUp4-Trend-Angle/
 
Last edited by a moderator:

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

RE: really impressive TREND indicator from tredingview

Good morning
I find this indicator (TREND ANGLE) really usefull and i tried to find something similar here to use it on ToS without success.
if anyone is so kinde to look at him and see if a conversion is possible I thiink the comunity could have a great tools to filter bad entry and even get into good one fast
https://www.tradingview.com/script/5xNrSUp4-Trend-Angle/
check the below:

CSS:
#// This Pine Script™ code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
#// © gotbeatz26107
#indicator("Trend Angle", overlay=false)
# Converted by Sam4Cok@Samer800    - 05/2024
declare lower;

input source        = close;       # 'Indicator Source'
input DetrendIndicator  = no;      # 'Detrend Indicator?'
input length            = 90;      # "Length"
input ColorizeIndicator = yes;     # 'Colorize Indicator?'
input smoother_type = {"Moving Average", default "Linear Regression"};  # 'Smoother Type'
input average_type  = AverageType.EXPONENTIAL;
input angle_change_degree = 5; #, "Angle Change Alert Threshold (degrees)", group = 'Alerts')

def na = Double.NaN;
def last = IsNaN(close);

#// Calculate the angle
script trend_angle {
    input source = close;
    input length = 90;
    def pi = Double.Pi;
    def price_change  = (source - source[length]) / source[length];
    def angle_radians = ATan(price_change);
    def angle_degrees = angle_radians * (180 / pi);
    plot trend_angle = angle_degrees;
}

def angle        = trend_angle(source, length);
def angle_smooth = MovingAverage(average_type, angle, length); #, average_type);
def regression   = Inertia(angle, length);
def smoother     = if smoother_type == smoother_type."Linear Regression" then regression else angle_smooth;

#// Final Calculation
def indicator = if DetrendIndicator then angle - smoother else angle;
def threshold = if DetrendIndicator then 0 else smoother;

#// Angle change detection
def angle_alert = MovingAverage(average_type, angle, angle_change_degree);
def angle_change = (angle_alert - angle_alert[1]);

#// Main
plot smoothplot = if last then na else if DetrendIndicator then 0 else threshold; #, title = 'Average'
plot main_plot = if last then na else indicator; #, "Angle"

plot zero_line = if last then na else if DetrendIndicator then na else 0;
smoothplot.AssignValueColor(if ColorizeIndicator then Color.GRAY else Color.YELLOW);
main_plot.SetDefaultColor(Color.WHITE);
zero_line.SetDefaultColor(Color.DARK_GRAY);

AddCloud(if ColorizeIndicator then indicator else na,  smoothplot,  Color.DARK_GREEN,  Color.DARK_RED, yes);
script rising{
    input src = close;
    input len = 5;
    plot result = if len == 1 then src > src[1] else
                  fold i = 0 to len -1 with p = no while src[i] > getvalue(src, i+1) do
                  getvalue(src,i+1) > getvalue(src, i+2);
}

plot angleChange = if rising(angle_change, angle_change_degree) then 0 else na;
angleChange.SetPaintingStrategy(PaintingStrategy.SQUARES);
angleChange.AssignValueColor(if angle_alert > 0 then Color.GREEN else COlor.RED);


#////End of CODE
 
Last edited by a moderator:
I tried to make a scan out of it. I would assume a bullish crossover would be where main_plot crosses above smoothplot within the last five days. When I input that condition, the scan button is not active. What am I doing wrong?
 
I tried to make a scan out of it. I would assume a bullish crossover would be where main_plot crosses above smoothplot within the last five days. When I input that condition, the scan button is not active. What am I doing wrong?

Are you sure that what you are asking is what you want?
This is a TREND ANGLE indicator.
It appears that the scan you're seeking does not align with the intended purpose of this indicator.

The crossover that you are seeking is rate of change over linear regression (or moving average).
This will probably have too many whipsaws to be useful.
If you do find a use for it; do come back and tell us.

FYI, the reason that you could not do a straight normal scan is because the script functions can't be processed in the Scan Hacker.
So this scan has been stripped of the choices. Inputs are set to the defaults.
If your inputs are different (such as linear regression vs moving average); this will not yield the same results.
Scan for Crossover:
Ruby:
#indicator("Trend CROSSOVER SCAN ONLY
# Converted by Sam4Cok@Samer800    - 05/2024

input length            = 90;      # "Length"
input average_type  = AverageType.EXPONENTIAL;

#// Calculate the angle
script trend_angle {
    input source = close;
    input length = 90;
    def pi = Double.Pi;
    def price_change  = (source - source[length]) / source[length];
    def angle_radians = ATan(price_change);
    def angle_degrees = angle_radians * (180 / pi);
    plot trend_angle = angle_degrees;
}

def angle        = trend_angle(close, length);
def regression   = Inertia(angle, length);

plot scan = angle crosses above regression ;

See next post for scan of Trend Angle
 
Last edited:
The purpose of this indicator is to alert to significant changes in the price rate-of-change over x bars
This indicator cannot be scanned normally in the Scan Hacker because the Scan Hacker cannot process the complex choices provided by the amazing @samer800.

In order to make the indicator scan, all the choices have been stripped out.
This scan has been written with the default settings.
Trend Angle Scan with default settings
Ruby:
#indicator("Trend Angle SCAN ONLY
# Converted by Sam4Cok@Samer800    - 05/2024

input length            = 90;      # "Length"
input average_type  = AverageType.EXPONENTIAL;

#// Calculate the angle
script trend_angle {
    input source = close;
    input length = 90;
    def pi = Double.Pi;
    def price_change  = (source - source[length]) / source[length];
    def angle_radians = ATan(price_change);
    def angle_degrees = angle_radians * (180 / pi);
    plot trend_angle = angle_degrees;
}

input angle_change_degree = 5; #, "Angle Change Alert Threshold (degrees)"
def angle        = trend_angle(close, length);
def angle_smooth = MovingAverage(average_type, angle, length); #, average_type);
def angle_alert = MovingAverage(average_type, angle, angle_change_degree);
def angle_change = (angle_alert - angle_alert[1]);

script rising{
    input src = close;
    input len = 5;
    plot result = if len == 1 then src > src[1] else
                  fold i = 0 to len -1 with p = no while src[i] > getvalue(src, i+1) do
                  getvalue(src,i+1) > getvalue(src, i+2);
}

plot angleChange = rising(angle_change, angle_change_degree);

#////End of CODE


P2PdFow.png

nNndEen.png
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
264 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