Indicators: LSMA

 

LSMA:

A typical Moving Average

Fig.1 The LSMA indicator

Fig.1 The LSMA indicator

Author: Nikolay Kositsin

 
If I set any smoothing period other than 50, the indicator disappears from the chart. Why can this happen?
 

Clinn:
У меня, если выставляю любой период сглаживания, отличный от 50, индикатор пропадает с графика. Почему такое может происходить?

The point is that the author's algorithm itself is humped and therefore the muving from the chart vertically swims away a lot!

 

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
 

This indicator is not working in several periods