# Function Polynomial Regression Strategy

Diupdate
To be clear I'm using the code from Richard Santos for the functional polynomial regression. I really loved his script idea (given that I'm into linear regression myself). I took his code and made a strategy which applies to bitcoin on the 5 minute chart (but you could adjust this for any asset), and you could make this work on anytime frame by adjusting the 'length' property of the regression until you get good results.

This strategy is very simple.

I drew lines to represent the bottom most part of the regression (green line), and top most part (red line). If the close crosses under the red line then you short. The reverse if it crosses above the green line then you go long.

Very simple but effective. To understand this script be sure to add Richard santos function polynomial regression so you can see what is going on and what I'm trying to do.

For example, on BTC with a length of 61 if you bought and held you would have only had 5% gain, instead with this strategy you are looking at very close to 60% gains! Now this could be a weird fluke of over-optimizing but I'm not sure this is the case because you can adjust the length from there +/- about 10 and still have good results. It's just certain lengths are the correct trading rhythms for different assets.

I'm excited to see how you guys use this and if you have any success. Be sure to thank Richard Santos for his great work!
Catatan Rilis:
I added trailing stop loss as requested by some users just enable it in the settings with the gear icon. By default I have it turned off, but with ETHUSD you can see that it can create improvements with the right settings. Just tweak it until you find the right settings.
Catatan Rilis:
I added backtest date range and the ability to:

- Do only LONGS
- Do only SHORTS
- Close instead of Short
- Close instead of Long

In the example uploaded, you can see that by turning off allowLongs, and enabling close instead of long you can see how effective this strategy is with just shorting alone. Using this you can optimize your parameters for just shorting or longing and then combine them later for the best settings.

Thanks to investCHK for the suggestion!

-=Gentleman Goat=- Download the TradingView Input Optimizer at tradingtools.software/optimizer
Discord: discord.gg/pGHHRczpbu
Skrip open-source

Dalam semangat TradingView, penulis dari skrip ini telah mempublikasikannya ke sumber-terbuka, maka trader dapat mengerti dan memverifikasinya. Semangat untuk penulis! Anda dapat menggunakannya secara gratis, namun penggunaan kembali kode ini dalam publikasi diatur oleh Tata Tertib. Anda dapat memfavoritkannya untuk digunakan pada chart

Pernyataan Penyangkalan

Informasi dan publikasi tidak dimaksudkan untuk menjadi, dan bukan merupakan saran keuangan, investasi, perdagangan, atau rekomendasi lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Persyaratan Penggunaan.

Inggin menggunakan skrip ini pada chart?