Trend Lines

Posted By: Pipinator

Trend Lines - 12/28/12 04:35

JCL

Does Zorro have any provision for trendlines?
Or do I have to do the old y=mx+b myself?

Pip
Posted By: jcl

Re: Trend Lines - 12/28/12 09:01

If you mean linear regression: You can either use the "polyfit" function, or the standard "LinearReg" indicators in the ta-lib.
Posted By: Pipinator

Re: Trend Lines - 12/28/12 13:41

What I am looking for is a way to generate a trend line array that I can compare a breakout against. So I'm thinking if I have two points I determined for a trend line priceHigh(5), priceHigh(2) I could feed the points in to

trendArray = TrendLine()
I could compare (and plot)

if (price > trendArray[0] && price > priceHigh{1))
enterLong();


I don't understand what Linearreg is returning. b+m*(TimePeroid-1) is that the next value?

How do I call it?
LinearReg(var* Data, int TimePeriod): var
var *Data = priceHigh[0..5];

nextTrendValue = LinearReg(Data,60);??

Thanks!

Pipinator
Edit --------------
I've tried the following:
var nextValue = LinearReg(priceHigh,5);
printf("nextValue: %2.4f, priceHigh:%2.4f\n",(double)nextValue, (double) priceHigh);

The log file shows values like:
nextValue: 991021190119434640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0000, priceHigh:4211680.0000Bar:150
nextValue: 991021190119434640000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0000, priceHigh:4211680.0000Bar:151
Posted By: jcl

Re: Trend Lines - 12/28/12 17:55

How to call a function is explained in the tutorial. The LinearReg function and most other TA functions are called in exactly the same way as the LowPass function in workshop 4. If you are not sure what an indicator does, plot a line from it - then it normally becomes clear.

However, you're right - the LinearReg function doesn't make much sense to me either. Better use the LinearRegSlope function, which calculates the m value, the projected price change per bar.
Posted By: Pipinator

Re: Trend Lines - 12/28/12 18:27

Jcl.. thanks I will try that. But solve the mystery of printf for me. I tried printing out price priceHigh values with %f and it is coming up 0's or when I cast it to double, as an overflow number. How do I get the values to print in the log?

Pipinator
Posted By: Petra

Re: Trend Lines - 12/30/12 09:59

printf("\nMy price is: %f",priceHigh());
© 2024 lite-C Forums