OPEN-SOURCE SCRIPT
Cập nhật

Linear Regression - Reverse Up/Down Strategy

8 836
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

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

Thông báo miễn trừ trách nhiệm

Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.