Welcome to the Traders Laboratory Forums.
Coding Forum Collaborate, receive help, or discuss coding related issues.

Reply
Old 11-30-2007, 09:34 AM   #1

Join Date: May 2007
Posts: 577
Ignore this user

Thanks: 0
Thanked 26 Times in 17 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 Thumbnails
'Linear Regression Line' indicator in Tradestation-vix-regression-line.png  
Dogpile is offline  
Reply With Quote
Old 11-30-2007, 02:01 PM   #2

Join Date: Jun 2007
Location: MC
Posts: 46
Ignore this user

Thanks: 4
Thanked 24 Times in 16 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.
3monkeys is offline  
Reply With Quote

Reply

Tags
regression

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Bid-Ask Pressure Indicator for Tradestation Soultrader Trading Indicators 81 08-18-2009 04:29 PM
Colby Indicator For Tradestation slableak Brokers and Data Feeds 12 11-29-2008 11:23 AM
BRICKS Indicator for Tradestation Soultrader Trading Indicators 8 02-23-2008 10:10 PM

All times are GMT -4. The time now is 06:20 AM.
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
©2006-2011 Traders Laboratory, All Rights Reserved.