NexusFi: Find Your Edge


Home Menu

 





Linear Regression Slope Angle Script


Discussion in TradeStation

Updated
    1. trending_up 4,478 views
    2. thumb_up 2 thanks given
    3. group 4 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread
  #1 (permalink)
madeinnyc
Highland Park, TX
 
Posts: 36 since Jan 2020
Thanks Given: 17
Thanks Received: 20

I'm attempting to measure the Angle of the Slope on a Linear Regression Slope study. I want to plot a label that measures the active bar and further improve it by adding another angle label that changes the angel value as I hover my pointer over the slope line.

There is a built function TLAngle in TS. It uses the arctangent of the slope where the slope is derived as rise (value change) over run (number of bars). But I'm not familiar with how to write the script. If someone here can help write the script, I will share a modified version of the Linear Regression Slope study which uses an exponential average...it gives very good signals!


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Strike Pause Holds, Oil Erases Monday Spike -- May CPI W …
Traders Hideout
Election Sunday Resolves: Peru Heads to Runoff at 42pct, …
Prediction Markets & Event Contracts
CME Cuts Precious Metals Margins Up to 21% Starting Toda …
Commodities
Post-Summit Market Verdict: ES -1%, NQ -1.5%, 10-Year Yi …
Traders Hideout
Rubios Good News Within Hours and the 30-Day Math: Why H …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
205 thanks
Sober Journey With S&P
21 thanks
30 Sessions
20 thanks
Volume Indicators
8 thanks
Thanks Mike. Godspeed.
7 thanks
  #2 (permalink)
 charttrader 
New Delhi / India
 
Experience: Advanced
Platform: multicharts
Trading: Index futures
Posts: 6 since Jun 2013
Thanks Given: 6
Thanks Received: 1

Hi madeinnyc,

you wish to have an indicator that plots the angle of slope for each bar?

so, if the angle is 80 degrees, it plots 80, and, if the angle on the next bar is 60, the plot will be 60, showing a falling indicator line.

Am I getting this right?

I use multicharts which has the same programming language. Once I get your clarification, I will try to code it.


Reply With Quote
  #3 (permalink)
madeinnyc
Highland Park, TX
 
Posts: 36 since Jan 2020
Thanks Given: 17
Thanks Received: 20



charttrader View Post
Hi madeinnyc,

you wish to have an indicator that plots the angle of slope for each bar?

so, if the angle is 80 degrees, it plots 80, and, if the angle on the next bar is 60, the plot will be 60, showing a falling indicator line.

Am I getting this right?

I use multicharts which has the same programming language. Once I get your clarification, I will try to code it.

Hi Charttrader - Yes, that's exactly what I'm hoping to measure. I think there's statistical significance in the slope crossing the zero line say at 70 degrees vs. 25 degrees. It's hard to judge the degree of the angle just by looking at the slope. This is would awesome to include in my slope study which I am more than happy to share with you.


Reply With Quote
  #4 (permalink)
bulldogcajun
santa fe, nm usa
 
Posts: 1 since Jun 2012
Thanks Given: 0
Thanks Received: 1

If this helps any. In Ninjascript ( c# )

private double SlopeToAngle(double slope)
{
angle = (Math.Atan(slope / TickSize) * toDegrees);
return(angle);
}
Where private double toDegrees = 180.0 / Math.PI;

Two examples:
HMA_1M = SlopeToAngle(Slope(HMA(14), 1, 0));
LR4_1M = SlopeToAngle(LinRegSlope(Close, 4)[0] );

If you have additional time frames on the same chart:
LR4_3M = SlopeToAngle(LinRegSlope(Closes[1], 4)[0] );


Reply With Quote
Thanked by:




Last Updated on November 30, 2020


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts