OPEN-SOURCE SCRIPT

Segment Regression

267
As an example of the descriptive power of Pine Script, this very short example traces a 'segment regression', a result not entirely obvious with so few lines of code, repositioning them when the previous inference moves away from the graph beyond the pre-set limit.

A trick used is to restart the new inference segment
- from the maximum reached in the previous trend, when positive (slope>0)
- from the minimum reached in the previous trend, when negative (slope<0)

The result can in my opinion be easily used to build strategies.

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.