OPEN-SOURCE SCRIPT
LSMAs

This indicator calculates and plots two Least Squares Moving Averages (LSMA) based on different lengths and a Smoothed Moving Average (SMMA) of the longer LSMA.
Inputs
lengthA : Period length for the first, longer LSMA.
lengthB : Period length for the second, shorter LSMA.
signAl : Signal period used in SMMA smoothing.
Calculations
LSMA-A and LSMA-B : Calculates the linear regression (least squares) of source over lengthA and lengthB respectively, with no offset. These represent two LSMAs, one slow and one fast.
SMMA : This is a smoothed moving average of the longer LSMA (LSMA-A).
Purpose
This indicator helps traders identify trend directions and momentum by using two least squares regression lines of different lengths to capture short- and long-term trends in price. The SMMA smoothing of the longer LSMA may be used as a signal or confirmation line to reduce noise and produce smoother signals.
It generates buy and sell signals based on the intersection of the LSMA-A and SMMA. If the LSMA-A crosses the SMMA upwards, a BUY signal is generated; if it crosses the SMMA downwards, a SELL signal is generated.
The LSMA-B, which is short-term, can be used for wave analysis. When a peak forms, a high is observed on the chart, and when a valley forms, a low is observed. This allows us to determine whether the wave is rising or falling.
Summary
Two LSMAs are calculated: one slow (lengthA), one fast (lengthB).
A smoothed moving average (SMMA) of the slow LSMA is computed using the signal length (signAl).
All three curves are overlaid on the price chart for visual trend and momentum analysis.
Inputs
lengthA : Period length for the first, longer LSMA.
lengthB : Period length for the second, shorter LSMA.
signAl : Signal period used in SMMA smoothing.
Calculations
LSMA-A and LSMA-B : Calculates the linear regression (least squares) of source over lengthA and lengthB respectively, with no offset. These represent two LSMAs, one slow and one fast.
SMMA : This is a smoothed moving average of the longer LSMA (LSMA-A).
Purpose
This indicator helps traders identify trend directions and momentum by using two least squares regression lines of different lengths to capture short- and long-term trends in price. The SMMA smoothing of the longer LSMA may be used as a signal or confirmation line to reduce noise and produce smoother signals.
It generates buy and sell signals based on the intersection of the LSMA-A and SMMA. If the LSMA-A crosses the SMMA upwards, a BUY signal is generated; if it crosses the SMMA downwards, a SELL signal is generated.
The LSMA-B, which is short-term, can be used for wave analysis. When a peak forms, a high is observed on the chart, and when a valley forms, a low is observed. This allows us to determine whether the wave is rising or falling.
Summary
Two LSMAs are calculated: one slow (lengthA), one fast (lengthB).
A smoothed moving average (SMMA) of the slow LSMA is computed using the signal length (signAl).
All three curves are overlaid on the price chart for visual trend and momentum analysis.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.
Open-source script
In true TradingView spirit, the creator of this script has made it open-source, so that traders can review and verify its functionality. Kudos to the author! While you can use it for free, remember that republishing the code is subject to our House Rules.
Disclaimer
The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.