bruce.lesko

Linear Regression - Reverse Up/Down Strategy

bruce.lesko 已更新   
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

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

本著真正的TradingView精神,該腳本的作者將其開源發布,以便交易者可以理解和驗證它。為作者喝彩吧!您可以免費使用它,但在出版物中重複使用此代碼受網站規則的約束。 您可以收藏它以在圖表上使用。

免責聲明

這些資訊和出版物並不意味著也不構成TradingView提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。

想在圖表上使用此腳本?