Category Oscilators  Published on 16/08/2018

Inverse MFI

Description

The Inverse Fisher Transform version of the MoneyFlowIndex indicator. This method once applied gives more clear and unequivocal signals also helping to avoid some whipsaw trades.

 


using System;
using cAlgo.API;
using cAlgo.API.Indicators;

namespace cAlgo.Indicators
{
    [Indicator(IsOverlay = false, AccessRights = AccessRights.None)]
    public class InverseMFI : Indicator
    {
        [Parameter(DefaultValue = 21, MinValue = 8)]
        public int Length { get; set; }

        [Output("InverseMFI", Color = Colors.CadetBlue, Thickness = 2)]
        public IndicatorDataSeries invmfi { get; set; }

        private MoneyFlowIndex mfi;
        private IndicatorDataSeries value1;
        private IndicatorDataSeries smooth;

        protected override void Initialize()
        {
            mfi = Indicators.MoneyFlowIndex(Length);
            value1 = CreateDataSeries();
            smooth = CreateDataSeries();
        }

        public override void Calculate(int index)
        {
            double mfiL = mfi.Result[index];
            double mfiH = mfi.Result[index];
            for (int i = index - Length + 1; i <= index; i++)
            {
                if (mfiH < mfi.Result[i])
                {
                    mfiH = mfi.Result[i];
                }
                if (mfiL > mfi.Result[i])
                {
                    mfiL = mfi.Result[i];
                }
            }
            if (mfiH != mfiL)
            {
                value1[index] = 0.1 * (mfi.Result[index] - 50);
                smooth[index] = (value1[index] + 2 * value1[index - 1] + 2 * value1[index - 2] + value1[index - 3]) / 6;
            }
            invmfi[index] = (Math.Exp(2 * smooth[index]) - 1) / (Math.Exp(2 * smooth[index]) + 1);
        }
    }
}


cwik_m's avatar
cwik_m

Joined on 26.06.2018

  • Distribution: Free
  • Language: C#
  • Trading platform: cTrader Automate
  • File name: InverseMFI.algo
  • Rating: 0
  • Installs: 1944
  • Modified: 13/10/2021 09:54
Comments
Log in to add a comment.
No comments found.