Linear Regression Intercept Buy Sell

Hey,

If I wanted to add a linear regression buy/sell signal to my charts, what would be the best way to achieve this. I tried to implement the below but showed no results.

LRINT(BARS=6,DEFAULT=Buy) == 1

Hi Jonathan,

It depends on what you consider to be a Buy criteria. For example, if the Close price Crosses Above the Linear Regression Intercept line you would set the script to:

Close() CrossesAbove LRINT(BARS=6, CALC=Close)

Ex5

This image shows the areas (in green) that would pass the above script.

Thank you, I was forgetting the Close() CrossesAbove!

 

Is this the same process for other scripts such as darvasbox etc?

Hi Jonathan,

The formula depends on the type of tool and the signal you want. Because the Linear Regression Intercept is drawn on the price chart then you want the signal to be when closing price crosses the tool, but if you were looking at an oscillator crossing below a value (eg RSI(5) and 30) then you would just use the tool in the function:

RSI(Bars=5) CrossesBelow 30

Note that it’s not possible to script for tools that you manually place on a chart, such as a Darvas Box or Fibonacci Retracement. If you want to be notified when those levels are breached you can use a Line Alert.