'Linear Regression Line' indicator in Tradestation - Traders Laboratory

Go Back   Traders Laboratory > Trading Resources > Trading Indicators > Coding Forum

Coding Forum Collaborate, receive help, or discuss coding related issues.

Reply
 
LinkBack (1) Thread Tools Display Modes
  1 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 11-30-2007, 08:34 AM
Dogpile Dogpile is offline
Dogpile has no status.

 
Join Date: May 2007
Posts: 577
Thanks: 0
Thanked 7 Times in 5 Posts
'Linear Regression Line' indicator in Tradestation

any coding buffs know how to run a continually updating linear regression line off the adv-decl line since 1st bar of day?

I changed the code to make it work off the first bar of the day on regular 'price'... but my adv-decl line runs as an 'indicator' keying off the difference of Data1($Adv) & Data2 ($Decl). thus, is there a simple way to tell this indicator to run off another indicator rather than re-coding the entire thing to reference the difference of data1 & data2??

thx in advance.

Here is my current code (which is currently the canned 'Linear Reg Line' TS indicator with a small adjustment to run off the first bar of the day):

Quote:
inputs:

EndDate_YYMMDD( 0 ), { 0 or YYMMDD, constant; if EndDate_YYMMDD = 0,
EndTime_HHMM ignored and last bar on chart used }
EndTime_HHMM( 0 ), { 0 or HHMM, constant; EndTime_HHMM ignored if 0 }
Color( Yellow ),
ExtRight( true ) ;

variables:
EndDate( iff( EndDate_YYMMDD < 500000, EndDate_YYMMDD + 1000000,
EndDate_YYMMDD ) ),
LRV( 0 ),
LRVAgo( 0 ),
TLLRV( 0 ),
Flag( 0 ),
Length( 0 ),
firstbar(0);

if date>date[1] then begin
firstbar=currentbar;
end;

length=currentbar-firstbar;



if Flag = 0 then

{ Insert a lin reg line for the first time and set it's color and extents }

begin
if EndDate = 1000000 and LastBarOnChart then
begin
LRV = LinearRegValue( C, Length, 0 ) ;
LRVAgo = LinearRegValue( C, Length, Length - 1 ) ;
TLLRV = TL_New( Date[ Length - 1 ], Time[ Length - 1 ], LRVAgo, Date, Time,
LRV ) ;
Flag = 1 ;
end
else if Date = EndDate and ( Time = EndTime_HHMM or EndTime_HHMM = 0 ) then
begin
LRV = LinearRegValue( C, Length, 0 ) ;
LRVAgo = LinearRegValue( C, Length, Length - 1 ) ;
TLLRV = TL_New( Date[ Length - 1 ], Time[ Length - 1 ], LRVAgo, Date, Time,
LRV ) ;
Flag = 2 ;
end ;
if Flag = 1 or Flag = 2 then
begin
TL_SetColor( TLLRV, Color ) ;
TL_SetExtLeft( TLLRV, false ) ;
if ExtRight then
TL_SetExtRight( TLLRV, true )
else
TL_SetExtRight( TLLRV, false ) ;
end ;
end
else if Flag = 1 then

{ Reset the end-points of the flag-1 LRLine at each new bar after it has been drawn
for the first time; this effectively results in a new LRLine each time. }

begin
LRV = LinearRegValue( C, Length, 0 ) ;
LRVAgo = LinearRegValue( C, Length, Length - 1 ) ;
TL_SetBegin( TLLRV, Date[ Length - 1 ], Time[ Length - 1 ], LRVAgo ) ;
TL_SetEnd( TLLRV, Date, Time, LRV ) ;
end ;


{ ** Copyright (c) 1991-2003 TradeStation Technologies, Inc. All rights reserved. **
** TradeStation reserves the right to modify or overwrite this analysis technique
with each release. ** }
Attached Images
File Type: png VIX Regression Line.png (12.2 KB, 54 views)

Reply With Quote
  #2 (permalink)  
Old 11-30-2007, 01:01 PM
3monkeys 3monkeys is offline
3monkeys has no status.

 
Join Date: Jun 2007
Posts: 11
Thanks: 1
Thanked 6 Times in 2 Posts
Re: 'Linear Regression Line' indicator in Tradestation

Not an expert TS programmer here, but I think what you are asking is a little complicated with TS EL. Here is a similar example of drawing trendline on a subgraph:
https://www.tradestation.com/Discuss...Topic_ID=69608
Quote:
there are two primary issues. First, the TrendLines Automatic indicator is hard coded to use price data. These references will need to be replaced with references to your MyRSI calculations. Second, trendlines cannot be drawn on a subgraph without price data. Thus, you have to go through a somewhat tedious process of inserting a symbol into the desired subgraph, changing its color to the subgraph's background color and fixing the subgraph's scale to match
A simple solution may be to use the Opentick NYSE feed ($1/month) of ^ADDIFFN into the free for charting Ninjatrader and plot the regression channel. Please note that the Opentick feed is not always reliable, but neither is the Adv-Decl line. One more advantage is that you could see the candles for the Adv-Decl line, which is useful for some traders.

Reply With Quote
Reply

LinkBacks (?)
LinkBack to this Thread: http://www.traderslaboratory.com/forums/f56/linear-regression-line-indicator-in-tradestation-2920.html
Posted By For Type Date
Traders Laboratory - forumdisplay This thread Refback 11-30-2007 12:20 PM


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bid-Ask Pressure Indicator for Tradestation Soultrader Trading Indicators 17 03-27-2008 06:15 PM
BRICKS Indicator for Tradestation Soultrader Trading Indicators 8 02-23-2008 09:10 PM
Colby Indicator For Tradestation slableak Data Feeds 10 02-09-2008 07:54 PM


All times are GMT -4. The time now is 06:40 AM.

 


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64