Information

Username: gsmremont23
Member since: 03 Jun 2021
Last login: 03 Jun 2021
Status: Active

Activity

Where Created Comments
Algorithms 0 2
Forum Topics 0 0
Jobs 0 0

Last Algorithm Comments

GS
gsmremont23 · 3 years ago

also there is a data type error in my code. change to decimal

GS
gsmremont23 · 3 years ago

The indicator is shifted to the left. I compared with tradingview ALMA. Here is my version, it is identical to the one on tradingview. I was writing code for my platform. But as an example it is clear.

               _sizeWindws = CreateParameterInt("Size wondows", 9);
                _sigma = CreateParameterInt("Sigma", 6);
                _offset = CreateParameterDecimal("Offset", 0.85m);

                _candlePriceClose = CreateParameterStringCollection("Price close candle",                                                                                                                                    "Close",Entity.CandlePointsArray);

 

decimal GetAlma(List<Candle> candles, int index)
        {
            decimal result = 0;

            double m = (double)_offset.ValueDecimal * ((double)_sizeWindws.ValueInt - 1);            
            double s = _sizeWindws.ValueInt / _sigma.ValueInt;

            double weight = 0;
            
            for (int i = 0; i < _sizeWindws.ValueInt ; i++)
            {
                 weight = Math.Exp(-((i - m) * (i - m)) / (2 * s * s));
                
                _numerator.Values[index] = _numerator.Values[index] + ((decimal)weight * candles[index -                    _sizeWindws.ValueInt + 1 + i].GetPoint(_candlePriceClose.ValueString));
                _denominator.Values[index] = _denominator.Values[index] + (decimal)weight;
            }
            result = _numerator.Values[index] / _denominator.Values[index];

            
            return result;

        }