Fort Mill
Posts: 1 since Jan 2019
Thanks Given: 0
Thanks Received: 0
|
Hello All - I have looked through a few threads but have not found anything that helps in my understanding of the current problem I am running into. I use the tradestation platform. I am trying to understand how the linear regression function works.
To create my first test, I am attempting to regress the last 30 bars of SP 500 Emini (dependent; data1 feed) versus the Russel (independent; data4 feed). I used the resources on the tradestation website to help construct the code below. However, when looking at the output variables, the numbers do not make sense. I pulled them all into a print file and calculated the regression manually in excel. I tried to troubleshoot but cannot figure out what I am doing wrong.
Any suggestions are appreciated.
Thank you!
----------------Start Code: My Failed Attempt------------------
Inputs:
RegArrayLength(30);
Var:
x(0), oLRSlope(0), oLRAngle(0), oLRIntercept(0), oLRValueRaw(0);
Array: ES_PrevCloses[30](0), RUS_PrevCloses[30](0);
For x = 1 to RegArrayLength begin
ES_PrevCloses[x] = Close[x] of data1;
RUS_PrevCloses[x] = Close[x] of data4;
End;
Value1 = LinRegArray2(RUS_PrevCloses, ES_PrevCloses, RegArrayLength, 0, oLRSlope, oLRAngle, oLRIntercept, oLRValueRaw);
Value2 = oLRSlope;
Value3 = oLRAngle;
Value4 = oLRIntercept;
Value5 = oLRValueRaw;
Value6 = Value4 + ((close[1] of data4)* Value2);
---------------------END Code---------------------
|