PRICE ACTION WITHIN THE LINEAR REGRESSION CHANNEL
http://tos.mx/Za1ku4yDESCRIPTION
I set out to look at how price action moves within the linear regression channel, but found it frustrating to be unable to see the history of price action relative to the channel at points in the past.
This code plots candles relative to the centerline of the linear regression channel (the linear regression line) and shows the movement relative to that.
USAGE
Following the indicator is simple enough. Entries may be signaled by the proce moving upward off the lower boundary, and exits (or short entries) may be found when the indicator is moving off the upper side band. If the price is meandering around the central line, it is an indication that there is little direction to the proce movement to go against the current trend (the channel may be compressing) and nothing is happening to change direction.
THIS IS IMPORTANT: Just because the price action is not moving within the channel does not mean that it is not moving, just that it is moving in harmony and agreement with the direction and rate of change of the linear regression line. It could be falling off a cliff or flying straight up for the moon... this indicator does not tell you anything about the trend of the indicator.
There are arrows shown in the screen capture that are not in this indicator. They are based on some other proprietary code and I cannot share them. However, I believe this indicator may be of value to some members of the community regardless.
Code:
####################################################
#
# PRICE MOVEMENT WITHIN LINEAR REGRESSION CHANNEL
#
# Price Action Relative to Linear Regression
#
# by mashume for the usethinkscript.com community
#
# 2022.03.28
#
# Released the MIT License as open source
# (c) mashume 2022
#
####################################################
declare lower;
input price = close;
input widthOfChannel = 90.0;
input fullRange = No;
input length = 50;
input colour = yes;
input labels = yes;
def MiddleLR;
if (fullRange)
then {
MiddleLR = InertiaAll(price);
} else {
MiddleLR = Inertia(price, length);
}
def dist = Highest((AbsValue(MiddleLR - price)) * (widthOfChannel / 100.0), length);
plot UpperLR = dist;
plot LowerLR = - dist;
UpperLR.SetDefaultColor(GetColor(3));
LowerLR.SetDefaultColor(GetColor(3));
plot zero = 0;
zero.SetDefaultColor(GetColor(3));
def h = high - MiddleLR;
def l = low - MiddleLR;
def o = open - MiddleLR;
def c = close - MiddleLR;
AddChart(open = o, high = h, low = l, close = c, growColor = color.light_gray, fallColor = color.light_gray, neutralColor = color.light_gray, type = ChartType.BAR);
plot LRS = 100 * ( wma(price, length) - Average(price, length) ) / (length - 1);
EYE CANDY AND DESCRIPTION
This is not investment advice.Several new indicators are included in this screen shot. But I'm lazy and only did one write up. You can find the other threads somewhere on usethinkscript.com
A
The LINEAR REGRESSION CENTERLINE EXCURSION indicator shows a clear enter signal which lasts nicely through the bulk of the upward movement.
B
The PRICE ACTION within LINEAR REGRESSION CHANNEL indicator shows a squeeze and a bounce off the lower line which corresponds nicely with a move upward in the price chart.
C
The LINEAR REGRESSION CENTERLINE EXCURSION indicator shows a good short signal, though the signal does not last as long as the downward trend.
D
Fourier RMS shows an increase in short term energy as a proportion of the total energy (the blue line rises and the red falls).
E
Fourier RMS shows an dramatic decrease in the short term (blue) line and a distinct rise in the long term (red).
Last edited: