bruce.lesko

Linear Regression - Reverse Up/Down Strategy

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

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

Dentro do verdadeiro espírito TradingView, o autor deste script publicou ele como um script de código aberto, para que os traders possam compreender e checar ele. Um viva ao autor! Você pode usá-lo gratuitamente, mas a reutilização deste código em uma publicação é regida pelas Regras da Casa. Você pode favoritá-lo para usá-lo em um gráfico.

Aviso legal

As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.

Quer usar esse script no gráfico?