Search This Blog

Sunday, January 5, 2014

Polynomial Regression Channel Analysis for Ninjatrader

Hello Traders,

The topic for today is the PRC ( Polynomial Regression Channel ).

What is, and how can be used the PRC ?

There are hundreds of sites, mostly mathematical sites where we can get a lot of info about it.

This is a brief summary :

When we have a series of data points ( price bars ) and we want to find a formula that best fits all points of the analyzed data set, we can use a linear regression :

Where Y = a.X + b
( picture from wikipedia )
Linear regression.svg

and it represent all the data points by a straight line.

This is the more elemental and easy to calculate... but with more error.

If we increase the degree of the polynomial to 2, then we get a parabola ;
Where Y = a.X2 + b.X + c
( charts generated with arachnoid page )

This kind of polynomial is always predicting a turning point ( polynomials with odd degree ( 1, 3, 5, etc ) will have the starting point and ending point with same trend )

So, for trading analysis, most people use degree = 3

On the following examples, I am using bigger samples ; 128 data points ( bars )
The PRC line is the gray dot-dashed line, and then I add two Bollinger bands. And the space between them is painted to create a zone:

On this CL 5 Minutes Chart we can see a 1 degree ( straight line ) polynomial calculated over the last 128 bars.

This is a 5 Minutes Gold Chart using a grade 3 polynomial :

So, selecting a big enough sample size and using a 3 degree optimized polynomial, we can create accurate trading zones that we can use on our daily trading.

We can use the PRC approach to any time frame, even a quick tick chart.
But I suggest using more slow and widely used charts, in the range of 5 Minutes or even higher. The most people looking and trading those levels, the better it will work...

On this example, we can see a 150 Ticks Gold Chart, using the levels provided from the 5 Min 3rd degree PRC ( previous chart )

Using the custom Indicator Pack TIS_PRC_OT from The Indicator Store we get the Basic PRC Indicator and its Muti Time Frame Version.

We can apply the TIS_PRC_OT indicator to any of our work charts, any time frame ( range, tick , volume, etc ) will always calculate the levels from the user defined time frame ( shown in the red box ). By default I use 5 Minutes, but again, we can select any time frame, even non standard types.

One important factor that must be taken into account ;
All the data points of the sample ( 128 on last examples ) are recalculated at each new sample.
That means that the PRC analysis repaints.
This is one of the reasons why it is suggested to use high time frame PRC's to define the levels and use them into a quick day trading chart, where we can get a target in an insignificant number of samples ( bars ) of the original Chart were the PRC was calculated.

Hope this information has been useful for you...
Please let me know if you have any questions...

Best Regards,

logo Pablo Maglio The Indicator Store 

Facebook Twitter LinkedIn Blogger Elance  G+  YouTube