Exemple #1
0
 /// <summary>
 /// Resets this indicator to its initial state
 /// </summary>
 public override void Reset()
 {
     PreviousTypicalPrice = 0.0m;
     PositiveMoneyFlow.Reset();
     NegativeMoneyFlow.Reset();
     base.Reset();
 }
Exemple #2
0
        /// <summary>
        /// Computes the next value of this indicator from the given state
        /// </summary>
        /// <param name="input">The input given to the indicator</param>
        /// <returns>A new value for this indicator</returns>
        protected override decimal ComputeNextValue(TradeBar input)
        {
            decimal typicalPrice = (input.High + input.Low + input.Close) / 3.0m;
            decimal moneyFlow    = typicalPrice * input.Volume;

            PositiveMoneyFlow.Update(input.Time, typicalPrice > PreviousTypicalPrice ? moneyFlow : 0.0m);
            NegativeMoneyFlow.Update(input.Time, typicalPrice < PreviousTypicalPrice ? moneyFlow : 0.0m);
            PreviousTypicalPrice = typicalPrice;

            decimal totalMoneyFlow = PositiveMoneyFlow.Current.Value + NegativeMoneyFlow.Current.Value;

            if (totalMoneyFlow == 0.0m)
            {
                return(100.0m);
            }

            return(100m * PositiveMoneyFlow.Current.Value / totalMoneyFlow);
        }
Exemple #3
0
        /// <summary>
        ///      Computes the next value of this indicator from the given state
        /// </summary>
        /// <param name="time"></param>
        /// <param name="input">The input given to the indicator</param>
        /// <returns>A new value for this indicator</returns>
        protected override DoubleArray Forward(long time, DoubleArray input)
        {
            var typicalPrice = (input[HighIdx] + input[LowIdx] + input[CloseIdx]) / 3.0d;
            var moneyFlow    = typicalPrice * input[VolumeIdx];

            PositiveMoneyFlow.Update(time, typicalPrice > PreviousTypicalPrice ? moneyFlow : 0.0d);
            NegativeMoneyFlow.Update(time, typicalPrice < PreviousTypicalPrice ? moneyFlow : 0.0d);
            PreviousTypicalPrice = typicalPrice;

            var totalMoneyFlow = PositiveMoneyFlow + NegativeMoneyFlow;

            if (totalMoneyFlow == 0.0d)
            {
                return(100.0d);
            }

            return(100.0d * PositiveMoneyFlow / totalMoneyFlow);
        }