bruce.lesko

Linear Regression - Reverse Up/Down Strategy

bruce.lesko Diupdate   
For my first foray into pine script I took the code from the generic "Consecutive up/down" and flipped the logic. I added a linear regression filter to try and stay with the overall trend. ATR added for visual, I eventually want to use it as part of the money management.


Rules to open trade or close the opposite:
IF the linear regression slope is >=0 AND the last candle closes lower, BUY
IF the linear regression slope is <=0 AND the last candle closes higher SELL

Rules to close the opposite:
IF the linear regression slope is >=0 AND the last candle closes higher, close any open SELL
IF the linear regression slope is <=0 AND the last candle closes lower, close any open BUY

Catatan Rilis:
Go with or against the Linear Regression trend using pullbacks or looking for breakouts of consecutive bars.
Catatan Rilis:
Updated smooth moving average for ATR channel
Catatan Rilis:
Added RSI for filtering overbought and oversold conditions
Catatan Rilis:
Code cleanup.
Catatan Rilis:
moved early exit to after entry to reduce redundant position calls
Catatan Rilis:
Set default behavior to go with major trend(200 linear regression slope) and against minor trend pullbacks(4 linear regression slope)
Catatan Rilis:
Added a date range function for choosing which date to test.
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?