bruce.lesko

Linear Regression - Reverse Up/Down Strategy

bruce.lesko Zaktualizowano   
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

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

Zgodnie z prawdziwym duchem TradingView, autor tego skryptu opublikował go jako open-source, aby traderzy mogli go zrozumieć i zweryfikować. Brawo dla autora! Możesz używać go za darmo, ale ponowne wykorzystanie tego kodu w publikacji jest regulowane przez Dobre Praktyki. Możesz go oznaczyć jako ulubione, aby użyć go na wykresie.

Wyłączenie odpowiedzialności

Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.

Chcesz użyć tego skryptu na wykresie?