This algorithm trades ETFs according to the trend from regression. The regression uses half-year daily data. If the absolute value of the slope is high enough and recent residual breaks the regression line, a long/short position is open. Idealy it takes profit when the residual breaks 1.64(90% confidence interval) or 1.96(95% confidence interval), at which moment we think the trend is going to reverse. For safety, I also added stoploss threshold for it.

Author