Esempio n. 1
0
        /// <summary>
        /// Creates a new Stochastics Indicator from the specified periods.
        /// </summary>
        /// <param name="name">The name of this indicator.</param>
        /// <param name="period">The period given to calculate the Fast %K</param>
        /// <param name="kPeriod">The K period given to calculated the Slow %K</param>
        /// <param name="dPeriod">The D period given to calculated the Slow %D</param>
        public Stochastic(string name, int period, int kPeriod, int dPeriod)
            : base(name)
        {
            Maximum  = new Maximum(name + "_Max", period);
            Mininum  = new Minimum(name + "_Min", period);
            SumFastK = new Sum(name + "_SumFastK", kPeriod);
            SumSlowK = new Sum(name + "_SumD", dPeriod);

            FastStoch = new FunctionalIndicator <TradeBar>(name + "_FastStoch",
                                                           input => ComputeFastStoch(period, input),
                                                           fastStoch => Maximum.IsReady,
                                                           () => Maximum.Reset()
                                                           );

            StochK = new FunctionalIndicator <TradeBar>(name + "_StochK",
                                                        input => ComputeStochK(period, kPeriod, input),
                                                        stochK => Maximum.IsReady,
                                                        () => Maximum.Reset()
                                                        );

            StochD = new FunctionalIndicator <TradeBar>(name + "_StochD",
                                                        input => ComputeStochD(period, kPeriod, dPeriod),
                                                        stochD => Maximum.IsReady,
                                                        () => Maximum.Reset()
                                                        );
        }
 /// <summary>
 /// Resets this indicator to its initial state
 /// </summary>
 public override void Reset()
 {
     _previous = 0;
     _medianMax.Reset();
     _medianMin.Reset();
     base.Reset();
 }
Esempio n. 3
0
        /// <summary>
        /// Creates a new IchimokuKinkoHyo indicator from the specific periods
        /// </summary>
        /// <param name="name">The name of this indicator</param>
        /// <param name="tenkanPeriod">The Tenkan-sen period</param>
        /// <param name="kijunPeriod">The Kijun-sen period</param>
        /// <param name="senkouAPeriod">The Senkou A Span period</param>
        /// <param name="senkouBPeriod">The Senkou B Span period</param>
        /// <param name="senkouADelayPeriod">The Senkou A Span delay</param>
        /// <param name="senkouBDelayPeriod">The Senkou B Span delay</param>
        public IchimokuKinkoHyo(string name, int tenkanPeriod = 9, int kijunPeriod = 26, int senkouAPeriod = 26, int senkouBPeriod = 52, int senkouADelayPeriod = 26, int senkouBDelayPeriod = 26)
            : base(name)
        {
            WarmUpPeriod = Math.Max(tenkanPeriod + senkouADelayPeriod, kijunPeriod + senkouADelayPeriod);
            WarmUpPeriod = Math.Max(WarmUpPeriod, senkouBPeriod + senkouBDelayPeriod);

            TenkanMaximum         = new Maximum(name + "_TenkanMax", tenkanPeriod);
            TenkanMinimum         = new Minimum(name + "_TenkanMin", tenkanPeriod);
            KijunMaximum          = new Maximum(name + "_KijunMax", kijunPeriod);
            KijunMinimum          = new Minimum(name + "_KijunMin", kijunPeriod);
            SenkouBMaximum        = new Maximum(name + "_SenkouBMaximum", senkouBPeriod);
            SenkouBMinimum        = new Minimum(name + "_SenkouBMinimum", senkouBPeriod);
            DelayedTenkanSenkouA  = new Delay(name + "DelayedTenkan", senkouADelayPeriod);
            DelayedKijunSenkouA   = new Delay(name + "DelayedKijun", senkouADelayPeriod);
            DelayedMaximumSenkouB = new Delay(name + "DelayedMax", senkouBDelayPeriod);
            DelayedMinimumSenkouB = new Delay(name + "DelayedMin", senkouBDelayPeriod);
            Chikou = new Delay(name + "_Chikou", senkouADelayPeriod);

            SenkouA = new FunctionalIndicator <IndicatorDataPoint>(
                name + "_SenkouA",
                input => SenkouA.IsReady ? (DelayedTenkanSenkouA + DelayedKijunSenkouA) / 2 : decimal.Zero,
                senkouA => DelayedTenkanSenkouA.IsReady && DelayedKijunSenkouA.IsReady,
                () =>
            {
                Tenkan.Reset();
                Kijun.Reset();
            });

            SenkouB = new FunctionalIndicator <IndicatorDataPoint>(
                name + "_SenkouB",
                input => SenkouB.IsReady ? (DelayedMaximumSenkouB + DelayedMinimumSenkouB) / 2 : decimal.Zero,
                senkouA => DelayedMaximumSenkouB.IsReady && DelayedMinimumSenkouB.IsReady,
                () =>
            {
                Tenkan.Reset();
                Kijun.Reset();
            });

            Tenkan = new FunctionalIndicator <IndicatorDataPoint>(
                name + "_Tenkan",
                input => Tenkan.IsReady ? (TenkanMaximum + TenkanMinimum) / 2 : decimal.Zero,
                tenkan => TenkanMaximum.IsReady && TenkanMinimum.IsReady,
                () =>
            {
                TenkanMaximum.Reset();
                TenkanMinimum.Reset();
            });

            Kijun = new FunctionalIndicator <IndicatorDataPoint>(
                name + "_Kijun",
                input => Kijun.IsReady ? (KijunMaximum + KijunMinimum) / 2 : decimal.Zero,
                kijun => KijunMaximum.IsReady && KijunMinimum.IsReady,
                () =>
            {
                KijunMaximum.Reset();
                KijunMinimum.Reset();
            });
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a new IchimokuKinkoHyo indicator from the specific periods
        /// </summary>
        /// <param name="name">The name of this indicator</param>
        /// <param name="tenkanPeriod">The Tenkan-sen period</param>
        /// <param name="kijunPeriod">The Kijun-sen period</param>
        /// <param name="senkouAPeriod">The Senkou A Span period</param>
        /// <param name="senkouBPeriod">The Senkou B Span period</param>
        /// <param name="senkouADelayPeriod">The Senkou A Span delay</param>
        /// <param name="senkouBDelayPeriod">The Senkou B Span delay</param>
        public IchimokuKinkoHyo(string name, int tenkanPeriod = 9, int kijunPeriod = 26, int senkouAPeriod = 26, int senkouBPeriod = 52, int senkouADelayPeriod = 26, int senkouBDelayPeriod = 26)
            : base(name)
        {
            TenkanMaximum         = new Maximum(name + "_TenkanMax", tenkanPeriod);
            TenkanMinimum         = new Minimum(name + "_TenkanMin", tenkanPeriod);
            KijunMaximum          = new Maximum(name + "_KijunMax", kijunPeriod);
            KijunMinimum          = new Minimum(name + "_KijunMin", kijunPeriod);
            SenkouBMaximum        = new Maximum(name + "_SenkouBMaximum", senkouBPeriod);
            SenkouBMinimum        = new Minimum(name + "_SenkouBMinimum", senkouBPeriod);
            DelayedTenkanSenkouA  = new Delay(name + "DelayedTenkan", senkouADelayPeriod);
            DelayedKijunSenkouA   = new Delay(name + "DelayedKijun", senkouADelayPeriod);
            DelayedMaximumSenkouB = new Delay(name + "DelayedMax", senkouBDelayPeriod);
            DelayedMinimumSenkouB = new Delay(name + "DelayedMin", senkouBDelayPeriod);


            SenkouA = new FunctionalIndicator <TradeBar>(
                name + "_SenkouA",
                input => computeSenkouA(senkouAPeriod, input),
                senkouA => DelayedTenkanSenkouA.IsReady && DelayedKijunSenkouA.IsReady,
                () =>
            {
                Tenkan.Reset();
                Kijun.Reset();
            });

            SenkouB = new FunctionalIndicator <TradeBar>(
                name + "_SenkouB",
                input => computeSenkouB(senkouBPeriod, input),
                senkouA => DelayedMaximumSenkouB.IsReady && DelayedMinimumSenkouB.IsReady,
                () =>
            {
                Tenkan.Reset();
                Kijun.Reset();
            });


            Tenkan = new FunctionalIndicator <TradeBar>(
                name + "_Tenkan",
                input => ComputeTenkan(tenkanPeriod, input),
                tenkan => TenkanMaximum.IsReady && TenkanMinimum.IsReady,
                () =>
            {
                TenkanMaximum.Reset();
                TenkanMinimum.Reset();
            });

            Kijun = new FunctionalIndicator <TradeBar>(
                name + "_Kijun",
                input => ComputeKijun(kijunPeriod, input),
                kijun => KijunMaximum.IsReady && KijunMinimum.IsReady,
                () =>
            {
                KijunMaximum.Reset();
                KijunMinimum.Reset();
            });
        }
        /// <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 + 1);

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

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

            AroonDown = new FunctionalIndicator <IndicatorDataPoint>(name + "_AroonDown",
                                                                     input => ComputeAroonDown(downPeriod, min, input),
                                                                     aroonDown => min.IsReady,
                                                                     () => min.Reset()
                                                                     );
        }
Esempio n. 6
0
 /// <summary>
 ///     Resets this indicator to its initial state
 /// </summary>
 public override void Reset()
 {
     base.Reset();
     _wfvMaximum.Reset();
 }
Esempio 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();
 }