bruce.lesko

Linear Regression - Reverse Up/Down Strategy

bruce.lesko Güncellendi   
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

Sürüm Notları:
Go with or against the Linear Regression trend using pullbacks or looking for breakouts of consecutive bars.
Sürüm Notları:
Updated smooth moving average for ATR channel
Sürüm Notları:
Added RSI for filtering overbought and oversold conditions
Sürüm Notları:
Code cleanup.
Sürüm Notları:
moved early exit to after entry to reduce redundant position calls
Sürüm Notları:
Set default behavior to go with major trend(200 linear regression slope) and against minor trend pullbacks(4 linear regression slope)
Sürüm Notları:
Added a date range function for choosing which date to test.
Açık kaynak kodlu komut dosyası

Gerçek TradingView ruhuyla, bu betiğin yazarı, yatırımcının anlayabilmesi ve doğrulayabilmesi için onu açık kaynak olarak yayınladı. Yazarın eline sağlık! Bunu ücretsiz olarak kullanabilirsiniz, ancak bu kodun bir yayında yeniden kullanımı Kullanım Koşulları ile yönetilir. Bir grafikte kullanmak için favorilere ekleyebilirsiniz.

Feragatname

Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.

Bu komut dosyasını bir grafikte kullanmak ister misiniz?