Fisher Transform in C#

I stole bits and pieces of this from different places. Initial credit goes to cTrader, followed by TradingView and finally to Andrey for helping me get my unit tests passing.

    
    public class FisherTransform : IndicatorBase
    {
        public int Length = 9;

        public decimal[] Fish { get; set; }
        public decimal[] Trigger { get; set; }

        decimal _maxHigh;
        decimal _minLow;

        private decimal _value1;
        private decimal _lastValue1;

        public FisherTransform(IEnumerable<Candle> candles, int length)
            : base(candles)
        {
            Length = length;
            RequiredCount = Length;
            _lastValue1 = 1;
        }

        protected override void Initialize()
        {
            Fish = new decimal[Series.Length];
            Trigger = new decimal[Series.Length];
        }

        public override void Compute(int startIndex = 1, int? endIndex = null)
        {
            if (endIndex == null)
                endIndex = Series.Length;

            for (int index = startIndex; index < endIndex; index++)
            {
                if (index == 1)
                {
                    Fish[index - 1] = 1;
                }

                _minLow = Series.Average.Lowest(Length, index);
                _maxHigh = Series.Average.Highest(Length, index);

                _value1 = Maths.Normalize(0.66m * (Maths.Divide(Series.Average[index] - _minLow, Math.Max(_maxHigh - _minLow, 0.001m)) - 0.5m) + 0.67m * _lastValue1);

                _lastValue1 = _value1;

                Fish[index] = 0.5m * Maths.Log(Maths.Divide(1 + _value1, Math.Max(1 - _value1, .001m))) + 0.5m * Fish[index - 1];
                Trigger[index] = Fish[index - 1];
            }
        }
    }
    
 

Note, base page can be found here. Also, I only post these indicators once I have written unit tests against them. Please comment below if something doesn’t look right.


Wilders Moving Average in C# (RMA)

Note, base page can be found here. Also, I only post these indicators once I have written unit tests against them. Please comment below if something doesn’t look right.

    
 	public class WildersMovingAverage : IndicatorBase
    {
        public decimal[] Result { get; set; }

        public int Period = 14;

        public decimal _previousSum = 0;

        public WildersMovingAverage(IEnumerable<Candle> candles, int length)
            : base(candles)
        {
            Period = length;
        }

        protected override void Initialize()
        {
            Result = new decimal[Series.Length];
        }

        public override void Compute(int startIndex = 0, int? endIndex = null)
        {
            if (endIndex == null)
                endIndex = Series.Length;

            decimal alpha = 1m / Period;
            for (int index = startIndex; index < endIndex; index++)
            {
                Result[index] = alpha * Series.Close[index] + (1 - alpha) * _previousSum;
                _previousSum = Result[index];
            }
        }
    }