using System;
using System.Collections.Generic;
using System.Linq;
using System.ComponentModel;
using Matriks.Data.Identifiers;
using Matriks.Data.Symbol;
using Matriks.Engines;
using Matriks.Indicators;
using Matriks.Symbols;
using Matriks.AlgoTrader;
using Matriks.Trader.Core;
using Matriks.Trader.Core.Fields;
using Matriks.Trader.Core.TraderModels;
using Matriks.Lean.Algotrader.AlgoBase;
using Matriks.Lean.Algotrader.Models;
using Matriks.Lean.Algotrader.Trading;
namespace Matriks.Lean.Algotrader
{
[IndicatorInformationAttribute("IFT_MFI", IndicatorDrawingArea.NewWindow)]
[IndicatorLineInformationAttribute(new []
{
"IFT_MFI(0,1)"
})
]
public class IFT_MFI : MatriksIndicator
{
[DefaultValue(14)]
public int MFIPeriod
{
get; set;
}
[DefaultValue(9)]
public int MOVPeriod
{
get; set;
}
MFI mfi;
MOV mov;
decimal mfiiter1, mfiiter2;
double iftmfi;
public sealed override void OnInit()
{
mfi = MFIIndicator(Symbol, SymbolPeriod, MFIPeriod);
mov = new MOV(MOVPeriod, MovMethod.W);
DrawHorizantal(0.5m);
DrawHorizantal(-0.5m);
}
public override void OnDataUpdate(int currentBar, decimal inputValue, DateTime barDateTime)
{
mfiiter1 = 0.1m * (mfi.CurrentValue - 50);
mov.Update(mfiiter1, currentBar, barDateTime);
mfiiter2 = mov.CurrentValue;
iftmfi = (Math.Exp((double)(2 * mfiiter2)) -1) / (Math.Exp((double)(2 * mfiiter2)) + 1);
if (currentBar < MFIPeriod || currentBar < MOVPeriod || currentBar < Period)
{
SetLine(0, currentBar, 0);
return ;
}
SetLine(0, currentBar, (decimal) iftmfi);
}
}
}