Trading Articles
Article Categories
Article Tools

TradeStation keyword question
Updated August 24, 2014
trending_up
1,880 views
thumb_up
1 thanks given
group
1 followers
forum
10 posts
attach_file
0 attachments

Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members

Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to

register in order to view the content of the threads and start contributing to our community.

It's free and simple.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)

TradeStation keyword question

(login for full post details)

#1 (permalink )
Philadelphia + NJ/US

Experience: Beginner

Platform: quantstrat

Trading: ETFs

Posts: 52 since Aug 2014

Thanks: 4 given,
39
received

Guys, simple question: in the following code, is the independent variable some sort of sequence of integers (EG if the length is 20, that the independent variable is 1-20), or is it the lagged price?
Value1 = RSquare(BarNumber,PriceH,Length);
If LinearRegSlope(PriceH, Length)<0 Then Value1 = -Value1;
The indicator I'm looking at is called R-squared autocorrelation, but I'm not overly familiar with tradeStation.
Thanks a lot.

Best Threads (Most Thanked) in the last 7 days on futures io

(login for full post details)

#2 (permalink )
Texas, USA

Experience: Advanced

Platform: TT Pro, Custom

Broker: dxFeed

Trading: Futures, Spreads

Posts: 249 since May 2014

Thanks: 596 given,
665
received

IlyaKipnis
Guys, simple question: in the following code, is the independent variable some sort of sequence of integers (EG if the length is 20, that the independent variable is 1-20), or is it the lagged price?
Value1 = RSquare(BarNumber,PriceH,Length);
If LinearRegSlope(PriceH, Length)<0 Then Value1 = -Value1;
The indicator I'm looking at is called R-squared autocorrelation, but I'm not overly familiar with tradeStation.
Thanks a lot.

Do you mean the "BarNumber" variable?

(login for full post details)

#3 (permalink )
Philadelphia + NJ/US

Experience: Beginner

Platform: quantstrat

Trading: ETFs

Posts: 52 since Aug 2014

Thanks: 4 given,
39
received

Hulk
Do you mean the "BarNumber" variable?

I suppose I'm asking what both of those lines do. That is, am I doing a rolling linear regression on integer values specifying time, or am I doing the rolling linear regression on the price against a lagged version of itself?

(login for full post details)

#4 (permalink )
Texas, USA

Experience: Advanced

Platform: TT Pro, Custom

Broker: dxFeed

Trading: Futures, Spreads

Posts: 249 since May 2014

Thanks: 596 given,
665
received

IlyaKipnis
I suppose I'm asking what both of those lines do. That is, am I doing a rolling linear regression on integer values specifying time, or am I doing the rolling linear regression on the price against a lagged version of itself?

I am not too good at math so I will stick to the first part of your question .
The first line calls a function called RSquare which takes 3 inputs, judging by the naming convention lets call them the independent input, the dependent input and length input.
The independent input, BarNumber, is a sequence of integers. For a given bar, it returns the sum of the bars in the chart before and including the given bar. If a length of 20 is specified and there are 500 bars in the chart, then the RSquare function will use the previous 20 values for this variable, i.e, 481-500.
The dependent variable seems to be an input and judging by its name, PriceH, it seems to be using the high of bars. You can verify this by the inputs to the study.
The returned value is held in a placeholder called "Value1".
The second line calculates the slope of the "PriceH" series using the same "Length" and changes the sign of the value returned in line 1 if the slope is negative.
I think.

The following user says Thank You to Hulk for this post:

(login for full post details)

#5 (permalink )
Philadelphia + NJ/US

Experience: Beginner

Platform: quantstrat

Trading: ETFs

Posts: 52 since Aug 2014

Thanks: 4 given,
39
received

Hulk
I am not too good at math so I will stick to the first part of your question

.

The first line calls a function called RSquare which takes 3 inputs, judging by the naming convention lets call them the independent input, the dependent input and length input.

The independent input, BarNumber, is a sequence of integers. For a given bar, it returns the sum of the bars in the chart before and including the given bar. If a length of 20 is specified and there are 500 bars in the chart, then the RSquare function will use the previous 20 values for this variable, i.e, 481-500.

The dependent variable seems to be an input and judging by its name, PriceH, it seems to be using the high of bars. You can verify this by the inputs to the study.

The returned value is held in a placeholder called "Value1".

The second line calculates the slope of the "PriceH" series using the same "Length" and changes the sign of the value returned in line 1 if the slope is negative.

I think.

Right. I'm asking about that slope that's positive or negative. Is that also using those same integers (EG 481-500) as the independent variable in that second line as well?

(login for full post details)

#6 (permalink )
Texas, USA

Experience: Advanced

Platform: TT Pro, Custom

Broker: dxFeed

Trading: Futures, Spreads

Posts: 249 since May 2014

Thanks: 596 given,
665
received

IlyaKipnis
Right. I'm asking about that slope that's positive or negative. Is that also using those same integers (EG 481-500) as the independent variable in that second line as well?

No. The inputs to the LinearRegSlope function is the PriceH variable so it is using whatever is being assigned to PriceH.

(login for full post details)

#7 (permalink )
Philadelphia + NJ/US

Experience: Beginner

Platform: quantstrat

Trading: ETFs

Posts: 52 since Aug 2014

Thanks: 4 given,
39
received

Hulk
No. The inputs to the LinearRegSlope function is the PriceH variable so it is using whatever is being assigned to PriceH.

I get that PriceH is the dependent variable (the y). What is the x? 1 through Length?

(login for full post details)

#8 (permalink )
Site Administrator Swing Trader Data Scientist & DevOps

Manta, Ecuador

Experience: Advanced

Platform: My own custom solution

Trading: Emini Futures

Posts: 49,745 since Jun 2009

Thanks: 32,292 given,
97,488
received

IlyaKipnis
Guys, simple question: in the following code, is the independent variable some sort of sequence of integers (EG if the length is 20, that the independent variable is 1-20), or is it the lagged price?
Value1 = RSquare(BarNumber,PriceH,Length);
If LinearRegSlope(PriceH, Length)<0 Then Value1 = -Value1;
The indicator I'm looking at is called R-squared autocorrelation, but I'm not overly familiar with tradeStation.
Thanks a lot.

IlyaKipnis
I suppose I'm asking what both of those lines do. That is, am I doing a rolling linear regression on integer values specifying time, or am I doing the rolling linear regression on the price against a lagged version of itself?

Would need to see the RSquare function to understand the inputs, which looks like the bar number, High dataseries and a variable Length.
Would be evaluated once per bar by default.
Mike

(login for full post details)

#9 (permalink )
Texas, USA

Experience: Advanced

Platform: TT Pro, Custom

Broker: dxFeed

Trading: Futures, Spreads

Posts: 249 since May 2014

Thanks: 596 given,
665
received

IlyaKipnis
I get that PriceH is the dependent variable (the y). What is the x? 1 through Length?

Doesnt look like x begins at 1. x begins at BarNumber - length where BarNumber = the current number of bars in the chart so x should begin at 481 if the current bar being calculated was bar # 500 in the chart. If length was 20, x would be 481 through 500.

(login for full post details)

#10 (permalink )
Philadelphia + NJ/US

Experience: Beginner

Platform: quantstrat

Trading: ETFs

Posts: 52 since Aug 2014

Thanks: 4 given,
39
received

Hulk
Doesnt look like x begins at 1. x begins at BarNumber - length where BarNumber = the current number of bars in the chart so x should begin at 481 if the current bar being calculated was bar # 500 in the chart. If length was 20, x would be 481 through 500.

Alright, so Rsquare is the R-squared of the high of prices (y) with respect to bar number (x).
The slope, ALSO, is the high of prices (y) with respect to bar number(x)?

(login for full post details)

#11 (permalink )
Texas, USA

Experience: Advanced

Platform: TT Pro, Custom

Broker: dxFeed

Trading: Futures, Spreads

Posts: 249 since May 2014

Thanks: 596 given,
665
received

IlyaKipnis
Alright, so Rsquare is the R-squared of the high of prices (y) with respect to bar number (x).
The slope, ALSO, is the high of prices (y) with respect to bar number(x)?

I think I am unable to translate the code to you. Lets just go by the documentation:
R-Square Function

R-Square (r2) is the coefficient of determination, which measures the proportion of variation that is explained by the independent variable in a regression model. This function takes the value of CoeffR for the specified Length and squares the value. that is, CoeffR(Length) * CoeffR(Length). The RSquared value can be interpreted as the proportion of the variance of Price with respect to the specified period (’Length’).

So, this function would use the PriceH over specified length to compute the value.
LinearRegSlope Function

Linear Regression is a concept also known as the "least squares method" or "best fit." Linear Regression attempts to fit a straight line between several data

points in such a way that distance between each data point and the line is minimized.

Returns

A numeric value containing the slope of the current regression line.

Usage

The input Price can be hard coded with a bar attribute such as Close, Open, High, Low, and Volume or a numeric series type input. It can also be replaced with a valid

EasyLanguage expression. For example: Close + Open, or Average(RSI(Close,14),14).

The input Length can be hard coded replaced with a numeric simple type input.

And this function calculates the slope of PriceH over the same length used in the previous function.
Hopefully this answers the question, otherwise I am out

Last Updated on August 24, 2014

Right now
Ongoing
Right now
February
Coming soon
March