Ejemplo n.º 1
0
        /// <summary>
        /// A Fisher Transform of Prices
        /// </summary>
        /// <param name="name">string - the name of the indicator</param>
        /// <param name="period">The number of periods for the indicator</param>
        public FisherTransform(string name, int period)
            : base(name, period)
        {
            // Initialize the local variables
            _maxHigh = new Maximum("MaxHigh", period);
            _minLow  = new Minimum("MinLow", period);
            value1   = new RollingWindow <IndicatorDataPoint>(period);

            // add two minimum values to the value1 to get things started
            value1.Add(new IndicatorDataPoint(DateTime.MinValue, .0001m));
            value1.Add(new IndicatorDataPoint(DateTime.MinValue, .0001m));
        }
Ejemplo n.º 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(IBaseDataBar input)
        {
            Minimum.Update(input.Time, input.Low);
            Maximum.Update(input.Time, input.High);

            if (!this.IsReady)
            {
                return(0);
            }

            var range = (Maximum.Current.Value - Minimum.Current.Value);

            return(range == 0 ? 0 : -100m * (Maximum.Current.Value - input.Close) / range);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates a new AroonOscillator from the specified up/down periods.
        /// </summary>
        /// <param name="name">The name of this indicator</param>
        /// <param name="upPeriod">The lookback period to determine the highest high for the AroonDown</param>
        /// <param name="downPeriod">The lookback period to determine the lowest low for the AroonUp</param>
        public AroonOscillator(string name, int upPeriod, int downPeriod)
            : base(name)
        {
            var max = new Maximum(name + "_Max", upPeriod);

            AroonUp = new FunctionalIndicator <IndicatorDataPoint>(name + "_AroonUp",
                                                                   input => ComputeAroonUp(upPeriod, max, input),
                                                                   aroonUp => max.IsReady
                                                                   );

            var min = new Minimum(name + "_Min", downPeriod);

            AroonDown = new FunctionalIndicator <IndicatorDataPoint>(name + "_AroonDown",
                                                                     input => ComputeAroonDown(downPeriod, min, input),
                                                                     aroonDown => min.IsReady
                                                                     );
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="DonchianChannel"/> class.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="upperPeriod">The period for the upper channel.</param>
 /// <param name="lowerPeriod">The period for the lower channel</param>
 public DonchianChannel(string name, int upperPeriod, int lowerPeriod)
     : base(name)
 {
     UpperBand = new Maximum(name + "_UpperBand", upperPeriod);
     LowerBand = new Minimum(name + "_LowerBand", lowerPeriod);
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="name">The indicator name</param>
 /// <param name="period">The lookback period</param>
 public WilliamsVixFix(string name, int period = 22) : base(name, period)
 {
     _wfvMaximum = new Maximum(period);
 }
 /// <summary>
 /// AroonUp = 100 * (period - {periods since max})/period
 /// </summary>
 /// <param name="upPeriod">The AroonUp period</param>
 /// <param name="max">A Maximum indicator used to compute periods since max</param>
 /// <param name="input">The next input data</param>
 /// <returns>The AroonUp value</returns>
 private static decimal ComputeAroonUp(int upPeriod, Maximum max, IndicatorDataPoint input)
 {
     max.Update(input);
     return(100m * (upPeriod - max.PeriodsSinceMaximum) / upPeriod);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Resets this indicator and both sub-indicators (Max and Min)
 /// </summary>
 public override void Reset()
 {
     Maximum.Reset();
     Minimum.Reset();
     base.Reset();
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Creates a new Williams %R.
 /// </summary>
 /// <param name="name">The name of this indicator</param>
 /// <param name="period">The lookback period to determine the highest high for the AroonDown</param>
 public WilliamsPercentR(string name, int period)
     : base(name)
 {
     Maximum = new Maximum(name + "_Max", period);
     Minimum = new Minimum(name + "_Min", period);
 }
Ejemplo n.º 9
0
 /// <summary>
 ///     Initializes a new instance of the WilliamsVixFixIndicator class with the specified name and period
 /// </summary>
 /// <param name="name">The name of this indicator</param>
 /// <param name="period">The period of the WVF</param>
 public WilliamsVixFixIndicator(string name, int period)
     : base(name)
 {
     _period  = period;
     _highest = new Maximum(period);
 }