Indicators: LSMA

 

LSMA:

A typical Moving Average

Fig.1 The LSMA indicator

Fig.1 The LSMA indicator

Author: Nikolay Kositsin

 

There is bug/error in this indicator, entering a number value between 21 and 49 to the "smoothing depth" will cause the LSMA line position to be shifted up. Also, there is one extra character typo at the vertical shift label:

input int PriceShift=0; // vertical shift of the indicator in pointsх
 
xtemer #:

There is bug/error in this indicator, entering a number value between 21 and 49 to the "smoothing depth" will cause the LSMA line position to be shifted up. Also, there is one extra character typo at the vertical shift label:

I'm not sure if this is really a bug in this old indicator, or if it is a meanwhile changed behaviour of the compiler / MT-internal calculations (Metaquotes likes to do that ;)

The problem here is the division between 2 int's into a double, where the result is always rounded to the int-value, e.g. with a period is a int of 51:

double length = (period + 1) / 3;   // (51 + 1) / 3   = 17.0, while 
double length = (period + 1) / 3.0; // (51 + 1) / 3.0 = 17.3333...

Anyhow, you can us my version until a fix appears.

Files:
LSMA.mq5  10 kb