Ejemplo n.º 1
0
        public void ResetsProperly()
        {
            var mfi = new MoneyFlowIndex(3);

            foreach (var data in TestHelper.GetDataStream(4))
            {
                var tradeBar = new TradeBar
                {
                    Open   = data.Value,
                    Close  = data.Value,
                    High   = data.Value,
                    Low    = data.Value,
                    Volume = Decimal.ToInt64(data.Value)
                };
                mfi.Update(tradeBar);
            }
            Assert.IsTrue(mfi.IsReady);
            Assert.IsTrue(mfi.PositiveMoneyFlow.IsReady);
            Assert.IsTrue(mfi.NegativeMoneyFlow.IsReady);
            Assert.AreNotEqual(mfi.PreviousTypicalPrice, 0.0m);

            mfi.Reset();

            Assert.AreEqual(mfi.PreviousTypicalPrice, 0.0m);
            TestHelper.AssertIndicatorIsInDefaultState(mfi);
            TestHelper.AssertIndicatorIsInDefaultState(mfi.PositiveMoneyFlow);
            TestHelper.AssertIndicatorIsInDefaultState(mfi.NegativeMoneyFlow);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new MoneyFlowIndex indicator. The indicator will be automatically
        /// updated on the given resolution.
        /// </summary>
        /// <param name="symbol">The symbol whose MFI we want</param>
        /// <param name="period">The period over which to compute the MFI</param>
        /// <param name="resolution">The resolution</param>
        /// <param name="selector">Selects a value from the BaseData to send into the indicator, if null defaults to the Value property of BaseData (x => x.Value)</param>
        /// <returns>The MoneyFlowIndex indicator for the requested symbol over the specified period</returns>
        public MoneyFlowIndex MFI(string symbol, int period, Resolution?resolution = null, Func <BaseData, TradeBar> selector = null)
        {
            var name = CreateIndicatorName(symbol, "MFI" + period, resolution);
            var mfi  = new MoneyFlowIndex(name, period);

            RegisterIndicator(symbol, mfi, resolution, selector);
            return(mfi);
        }
Ejemplo n.º 3
0
        protected override void OnStart()
        {
            label      = "Colonel V1 " + Symbol.Code + " " + TimeFrame.ToString() + " / ";
            _fastMa    = Indicators.MovingAverage(SourceSeries, FastPeriods, MAType);
            _slowMa    = Indicators.MovingAverage(SourceSeries, SlowPeriods, MAType);
            _macd      = Indicators.MacdHistogram(LongCycle, ShortCycle, Period);
            rsi        = Indicators.RelativeStrengthIndex(Source, Periods);
            _SSR       = Indicators.GetIndicator <SinewaveSupportResistance>(MarketSeries, Alpha);
            _moneyFlow = Indicators.MoneyFlowIndex(MFIPeriod);
            _parabolic = Indicators.ParabolicSAR(minaf, maxaf);

            Positions.Opened += PositionsOnOpened;
            Positions.Closed += PositionsOnClosed;
        }
Ejemplo n.º 4
0
        protected override void OnStart()
        {
            label      = "TheMajorV2PSar" + Symbol.Code + " " + TimeFrame.ToString() + " / " + HighOrderTimeFrame.ToString();
            tendency   = Indicators.GetIndicator <CandlestickTendency>(HighOrderTimeFrame);
            index      = MarketSeries.Close.Count - 1;
            _macd      = Indicators.MacdHistogram(LongCycle, ShortCycle, Period);
            rsi        = Indicators.RelativeStrengthIndex(Source, Periods);
            _SSR       = Indicators.GetIndicator <SinewaveSupportResistance>(MarketSeries, Alpha);
            _moneyFlow = Indicators.MoneyFlowIndex(MFIPeriod);
            _parabolic = Indicators.ParabolicSAR(minaf, maxaf);

            Positions.Opened += PositionsOnOpened;
            Positions.Closed += PositionsOnClosed;
        }
Ejemplo n.º 5
0
        protected override void OnStart()
        {
            label      = "The Major V3 " + Symbol.Code + " " + TimeFrame.ToString() + " / " + HighOrderTimeFrame.ToString();
            tendency   = Indicators.GetIndicator <CandlestickTendency>(HighOrderTimeFrame);
            index      = MarketSeries.Close.Count - 1;
            _hmaslow   = Indicators.GetIndicator <HMAslow>(SlowPeriods);
            _macd      = Indicators.MacdHistogram(LongCycle, ShortCycle, Period);
            rsi        = Indicators.RelativeStrengthIndex(Source, Periods);
            _SSR       = Indicators.GetIndicator <SinewaveSupportResistance>(MarketSeries, Alpha);
            _FPP       = Indicators.GetIndicator <FiboPivotPointsIntraDay>(MarketSeries, NoPiv, DrawingWidth);
            _moneyFlow = Indicators.MoneyFlowIndex(MFIPeriod);

            Positions.Opened += PositionsOnOpened;
            Positions.Closed += PositionsOnClosed;
        }
Ejemplo n.º 6
0
        public void TestTradeBarsWithNoVolume()
        {
            var mfi = new MoneyFlowIndex(3);

            foreach (var data in TestHelper.GetDataStream(4))
            {
                var tradeBar = new TradeBarValue {
                    Open   = data.Value.Value,
                    Close  = data.Value.Value,
                    High   = data.Value.Value,
                    Low    = data.Value.Value,
                    Volume = 0
                };
                mfi.Update(DateTime.Now, tradeBar);
            }

            Assert.AreEqual(mfi.Current.Value, 100.0d);
        }
Ejemplo n.º 7
0
        public void TestTradeBarsWithNoVolume()
        {
            var mfi = new MoneyFlowIndex(3);

            foreach (var data in TestHelper.GetDataStream(4))
            {
                var tradeBar = new TradeBar
                {
                    Open     = data.Price,
                    Close    = data.Price,
                    High     = data.Price,
                    Low      = data.Price,
                    TimeZone = TimeZone.Utc,
                    Volume   = 0
                };
                mfi.Update(tradeBar);
            }

            Assert.Equal(100.0m, mfi.Current.Price);
        }
Ejemplo n.º 8
0
        public void ComparesAgainstExternalData()
        {
            var mfi = new MoneyFlowIndex(20);

            TestHelper.TestIndicator(mfi, "spy_mfi.txt", "Money Flow Index 20");
        }
Ejemplo n.º 9
0
 protected override void OnStart()
 {
     // Put your initialization logic here
     rsi1 = Indicators.RelativeStrengthIndex(source, period);
     mfi1 = Indicators.MoneyFlowIndex(period);
 }