AIQ code based on Perry Kaufman’s article in May 2025 issue of Stocks & Commodities, “Trading The Channel,” is shown here and also provided in a downloadable code file. This encodes the system that the author describes as a linear regression slope trading system, which goes long when the linear regression slope goes above the zero line and exits when the linear regression slope drops below the zero line.
! TRADING THE CHANNEL ! Author: Perry J Kaufman, TASC May 2025 ! Coded by: Richard Denning, 3/15/2025 ! Example of trading the linear regression slope: Len is 20. C is [close]. LRslope is Slope2(C,Len). Signal is iff(LRslope > 0,1,-1). Buy if Signal = 1 and valresult(Signal,1) = -1. ExitLong if Signal = -1.
The imagee below shows an example of the linear regression slope line plotted on a daily chart of QQQ (Nasdaq-100 ETF).
