NexusFi: Find Your Edge


Home Menu

 





Linear Regression Slope Indicator


Discussion in TradeStation

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




 
Search this Thread

Linear Regression Slope Indicator

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

This is a nice lower study to be used along with R Squared. If you are using a dark color background chart, be sure to change the plot line colors for better visibility:


 
Code
Indicator: Lin Regression Slope
inputs:
Price ( Close ),
Length( 20 ),
UpLineColor( Green ),
DnLineColor( Red ) ;

variables:
LRS( 0 ) ;

LRS = LinearRegSlope( Price, Length ) ;
Plot1( LRS, "LRS" ) ;

if LRS > 0 then
SetPlotColor( 1, UpLineColor )
else
SetPlotColor( 1, DnLineColor ) ;

Indicator: RSquared
inputs:
Price( Close ),
LinearRegLength( 20 ),
RSquaredLength( 20 ),
Threshold( 0.2 ),
AlertBarLength( 1 ),
ChartRSquaredColor( Yellow ),
ChartThreshLineColor( Red ),
RadarAlertBGColor( Red ),
RadarAlertTextColor( Black ),
RadarNoAlertBGColor( Black ) ,
RadarNoAlertTextColor( White ) ;

variables:
ApplicationType( 0 ),
AlertBarNum( 0 ),
LinRegVal( 0 ),
RSquared( 0 ) ;

if CurrentBar = 1 then
ApplicationType = GetAppInfo( aiApplicationType ) ;

LinRegVal = LinearRegValue( Price, LinearRegLength,0 ) ;
RSquared = RSquare( Price, LinRegVal, RSquaredLength ) ;

Plot1( Threshold, "R^2Trig" ) ;
Plot2( RSquared, "R^2" ) ;

if RSquared crosses over Threshold then
AlertBarNum = CurrentBar ;

if ApplicationType = cRadarScreen then
begin
if CurrentBar < AlertBarNum + AlertBarLength then
begin
SetPlotBGColor( 2, RadarAlertBGColor ) ;
SetPlotColor ( 2, RadarAlertTextColor ) ;
Alert( "RSquared crossing up through " + "threshold level." ) ;
end
else
begin
SetPlotBGColor( 2, RadarNoAlertBGColor ) ;
SetPlotColor ( 2, RadarNoAlertTextColor ) ;
end ;
end
else
begin
SetPlotColor( 1, ChartThreshLineColor ) ;
SetPlotColor( 2, ChartRSquaredColor ) ;
end ;

Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
What broker to use for trading palladium futures
Commodities
Cheap historycal L1 data for stocks
Stocks and ETFs
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Quantum physics & Trading dynamics
The Elite Circle
REcommedations for programming help
Sierra Chart
 
  #2 (permalink)
 
Tripken's Avatar
 Tripken 
Knoxville, TN/USA
Market Wizard
 
Experience: Beginner
Platform: TradeStation
Broker: TradeStation
Trading: ES
Frequency: Several times daily
Duration: Minutes
Posts: 624 since Feb 2010
Thanks Given: 1,583
Thanks Received: 1,368

Curious what your indicator does, could you post a screenshot of a chart?

I use an indi called linear regression High/Low on TS.

Thanks.

Reply With Quote




Last Updated on July 5, 2020


© 2024 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 - Privacy Policy - Downloads - Top
no new posts