Indicators: LSMA

 

LSMA:

Least Square Moving Average - a moving average calculated by the least squares method.

The indicator has two input parameters:

  • Period - calculation period;
  • Applied price - price used for calculations.

Calculation:

LSMA[i]=Sum/L2

where

Sum[i] = (Period - N)*Price[i] + (Period - N - 1)*Price[i-1] + … + (1 - N)*Price[i-Period+1],
N = (Period + 1)/3,
L2 = Period*(Period + 1)/6

Author: Scriptor

 
The software draws the LSMA with period (2), but does not draw with 3 and 4 periods, it draws with 5, but does not draw with 6 and 7, it draws again with 8. And it continues drawing one every 3 periods, I only tested it until 50. But I don't understand MQL5 enough to fix the error.