OPEN-SOURCE SCRIPT

Linear Regression - Reverse Up/Down Strategy

Aktualisiert
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

Versionshinweise
Go with or against the Linear Regression trend using pullbacks or looking for breakouts of consecutive bars.
Versionshinweise
Updated smooth moving average for ATR channel
Versionshinweise
Added RSI for filtering overbought and oversold conditions
Versionshinweise
Code cleanup.
Versionshinweise
moved early exit to after entry to reduce redundant position calls
Versionshinweise
Set default behavior to go with major trend(200 linear regression slope) and against minor trend pullbacks(4 linear regression slope)
Versionshinweise
Added a date range function for choosing which date to test.
Linear RegressionRelative Strength Index (RSI)

Open-source Skript

Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun das Script auch andere Trader verstehen und prüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden. Die Nutzung dieses Codes in einer Veröffentlichung wird in unseren Hausregeln reguliert. Sie können es als Favoriten auswählen, um es in einem Chart zu verwenden.

Möchten Sie dieses Skript auf einem Chart verwenden?

Haftungsausschluss