public override void GetData(ref object Prototype, IIndicatorValues Ind)
        {
            int fastPeriod = (int)this.IndicatorParameters.List[0];
            int slowPeriod = (int)this.IndicatorParameters.List[1];

            decimal fast = 0.0M;
            decimal slow = 0.0M;

            decimal fastEmaAlpha = (2.0M / (Decimal)(fastPeriod + 1.0M));
            //Decimal slowEmaAlpha = (2.0M / (Decimal)((int)Math.Round(fastPeriod * RATIO, 0) + 1.0M));
            Decimal slowEmaAlpha = (2.0M / (Decimal)(slowPeriod + 1.0M));

            if (Ind.Bar.CurrentBar > 1)
            {
                fast = (fastEmaAlpha * Ind.Bar[0].Close) + ((1.0M - fastEmaAlpha) * Ind.EmaPair(fastPeriod, slowPeriod)[1].Fast);
                slow = (slowEmaAlpha * Ind.Bar[0].Close) + ((1.0M - slowEmaAlpha) * Ind.EmaPair(fastPeriod, slowPeriod)[1].Slow);
            }
            else
            {
                fast = Ind.Bar[0].Close;
                slow = Ind.Bar[0].Close;
            }

            (Prototype as EMAPair).Fast = fast;
            (Prototype as EMAPair).Slow = slow;
        }
        public override decimal GetProximateDistance(IIndicatorValues Ind, object NextValue)
        {
            return(Ind.ATR(ATR_PERIOD)[0].Value * ATR_PROXIMITY_MULTIPLE);

            //int fastPeriod = (int)this.IndicatorParameters.List[0];
            //int slowPeriod = (int)this.IndicatorParameters.List[1];

            //List<decimal> ranges = new List<decimal>();
            //decimal lastValue = 0.0M;

            //if (Ind.Bar.CurrentBar >= (fastPeriod + 1))
            //{
            //    for (int i = 1; i < fastPeriod; i++)
            //    {
            //        lastValue = Ind.EmaPair(fastPeriod, slowPeriod)[i].Fast;
            //        ranges.Add((decimal)Math.Abs((double)lastValue - (double)Ind.EmaPair(fastPeriod, slowPeriod)[i + 1].Fast));
            //    }
            //}

            //ranges.Add((decimal)Math.Abs((NextValue as EMAPair).Fast - lastValue));

            //if (lastValue == 0.0M)
            //    return 0.0M;
            //else
            //    return (ranges.Count > 0) ? ranges.Average() : 0.0M;
        }
Exemple #3
0
        public override decimal GetProximateDistance(IIndicatorValues Ind, object NextValue)
        {
            return(Ind.ATR(ATR_PERIOD)[0].Value * ATR_PROXIMITY_MULTIPLE);

            //int period = (int)this.IndicatorParameters.List[0];

            //List<decimal> ranges = new List<decimal>();
            //decimal lastValue = 0.0M;

            //if (Ind.Bar.CurrentBar >= (period + 1))
            //{
            //    for (int i = 1; i < period; i++)
            //    {
            //        lastValue = Ind.MamaFama(period)[i].MAMA;
            //        ranges.Add((decimal)Math.Abs((double)lastValue - (double)(Ind.MamaFama(period)[i + 1].MAMA)));
            //    }
            //}

            //ranges.Add((decimal)Math.Abs((double)((NextValue as MamaFama).MAMA) - (double)lastValue));

            //if (lastValue == 0.0M)
            //    return 0.0M;
            //else
            //    return (ranges.Count > 0) ? ranges.Average() : 0.0M;
        }
Exemple #4
0
        public override void GetData(ref object Prototype, IIndicatorValues Ind)
        {
            int period = (int)this.IndicatorParameters.List[0];

            decimal alpha = 0.0M;

            decimal mama = 0.0M;
            decimal fama = 0.0M;

            if (Ind.Bar.CurrentBar == 1)
            {
                mama = ((Ind.Bar[0].High + Ind.Bar[0].Low) / 2.0M);
                fama = mama;
            }
            else if (Ind.Bar.CurrentBar <= 6)
            {
                alpha = (2.0M / (period + 1.0M));
                mama  = (alpha * ((Ind.Bar[0].High + Ind.Bar[0].Low) / 2.0M)) + ((1.0M - alpha) * Ind.MamaFama(period)[1].MAMA);
                fama  = (0.5M * alpha * mama) + ((1.0M - (0.5M * alpha)) * Ind.MamaFama(period)[1].FAMA);
            }
            if (Ind.Bar.CurrentBar > 6)
            {
                decimal fastAlpha  = (2.0M / (period + 1.0M));
                decimal deltaPhase = Ind.MESA()[0].DeltaPhase;

                alpha = fastAlpha / deltaPhase;

                mama = (alpha * ((Ind.Bar[0].High + Ind.Bar[0].Low) / 2.0M)) + ((1.0M - alpha) * Ind.MamaFama(period)[1].MAMA);
                fama = (0.5M * alpha * mama) + ((1.0M - (0.5M * alpha)) * Ind.MamaFama(period)[1].FAMA);
            }

            (Prototype as MamaFama).MAMA  = mama;
            (Prototype as MamaFama).FAMA  = fama;
            (Prototype as MamaFama).Alpha = alpha;
        }
Exemple #5
0
        public override void GetAll(IIndicatorValues Ind)
        {
            int     atrPeriod         = (int)this.IndicatorParameters.List[0];
            decimal atrMultiple       = (decimal)this.IndicatorParameters.List[1];
            decimal proximityFraction = (decimal)this.IndicatorParameters.List[2];

            if (!Ind.DoubleZeros(atrPeriod, atrMultiple, proximityFraction).IsPopulated)
            {
                int oldCurrentBar = Ind.Bar.CurrentBar;

                for (int i = 1; i <= Ind.Bar.MaxBar; i++)
                {
                    Ind.Bar.CurrentBar = i;

                    object prototype = null;
                    if (i == 1)
                    {
                        prototype = new DoubleZeros();
                    }
                    else
                    {
                        prototype = (DoubleZeros)Ind.DoubleZeros(atrPeriod, atrMultiple, proximityFraction)[1].Clone();
                    }

                    Get(ref prototype, Ind);

                    Ind.DoubleZeros(atrPeriod, atrMultiple, proximityFraction)[0] = (DoubleZeros)prototype;

                    Ind.DoubleZeros(atrPeriod, atrMultiple, proximityFraction).IsPopulated = true;                     // set here so instance is guaranteed to exits
                }

                Ind.Bar.CurrentBar = oldCurrentBar;
            }
        }
Exemple #6
0
        public override void GetAll(IIndicatorValues Ind)
        {
            if (!Ind.MESA().IsPopulated)
            {
                int oldCurrentBar = Ind.Bar.CurrentBar;
                for (int i = 1; i <= Ind.Bar.MaxBar; i++)
                {
                    Ind.Bar.CurrentBar = i;

                    object prototype = null;
                    if (i == 1)
                    {
                        prototype = new MESA();
                    }
                    else
                    {
                        prototype = (MESA)Ind.MESA()[1].Clone();
                    }

                    Get(ref prototype, Ind);

                    Ind.MESA()[0] = (MESA)prototype;

                    Ind.MESA().IsPopulated = true;                     // set here so instance is guaranteed to exits
                }

                Ind.Bar.CurrentBar = oldCurrentBar;
            }
        }
Exemple #7
0
        public override void GetAll(IIndicatorValues Ind)
        {
            int period = (int)this.IndicatorParameters.List[0];

            if (!Ind.ATR(period).IsPopulated)
            {
                int oldCurrentBar = Ind.Bar.CurrentBar;
                for (int i = 1; i <= Ind.Bar.MaxBar; i++)
                {
                    Ind.Bar.CurrentBar = i;

                    object prototype = null;
                    if (i == 1)
                    {
                        prototype = new ATR();
                    }
                    else
                    {
                        prototype = (ATR)Ind.ATR(period)[1].Clone();
                    }

                    Get(ref prototype, Ind);

                    Ind.ATR(period)[0] = (ATR)prototype;

                    Ind.ATR(period).IsPopulated = true;                     // set here so instance is guaranteed to exits
                }

                Ind.Bar.CurrentBar = oldCurrentBar;
            }
        }
Exemple #8
0
        public override void Get(ref object Prototype, IIndicatorValues Ind)
        {
            int period          = (int)this.IndicatorParameters.List[0];
            int smoothingPeriod = (int)this.IndicatorParameters.List[1];

            decimal cti = 1.0M;

            if (Ind.Bar.CurrentBar > (period + 1))
            {
                List <double> logChanges = new List <double>();

                // TODO: why is this <0 at times??
                for (int i = 0; i < period; i++)
                {
                    logChanges.Add(Math.Log((double)Ind.Bar[i].Close / (double)Ind.Bar[i + 1].Close));
                }

                cti = (decimal)Math.Log((double)Ind.Bar[0].Close / (double)Ind.Bar[period].Close)
                      / (decimal)(Utilities.StandardDeviation(logChanges) * Math.Sqrt(period));

                if (Ind.Bar.CurrentBar > (period + 2))
                {
                    decimal alpha = (2.0M / (smoothingPeriod + 1.0M));
                    cti = (alpha * cti) + ((1.0M - alpha) * Ind.CTI(period, smoothingPeriod)[1].Value);
                }
            }

            (Prototype as CTI).Value = cti;
        }
Exemple #9
0
        public override void GetAll(IIndicatorValues Ind)
        {
            int     period       = (int)this.IndicatorParameters.List[0];
            decimal thresholdADX = (decimal)this.IndicatorParameters.List[1];

            int oldCurrentBar = Ind.Bar.CurrentBar;

            for (int i = 1; i <= Ind.Bar.MaxBar; i++)
            {
                Ind.Bar.CurrentBar = i;

                object prototype = null;
                if (i == 1)
                {
                    prototype = new ADX(thresholdADX);
                }
                else
                {
                    prototype = (ADX)Ind.ADXExponential(period, thresholdADX)[1].Clone();
                }

                Get(ref prototype, Ind);

                Ind.ADXExponential(period, thresholdADX)[0] = (ADX)prototype;

                Ind.ADXExponential(period, thresholdADX).IsPopulated = true;                 // set here so instance is guaranteed to exits
            }

            Ind.Bar.CurrentBar = oldCurrentBar;
        }
Exemple #10
0
        public override void GetAll(IIndicatorValues Ind)
        {
            int     period = (int)this.IndicatorParameters.List[0];
            int     firstSmoothingPeriod  = (int)this.IndicatorParameters.List[1];
            int     secondSmoothingPeriod = (int)this.IndicatorParameters.List[2];
            decimal thresholdPercentage   = (decimal)this.IndicatorParameters.List[3];

            if (!Ind.SlowStochastic(period, firstSmoothingPeriod, secondSmoothingPeriod, thresholdPercentage).IsPopulated)
            {
                int oldCurrentBar = Ind.Bar.CurrentBar;
                for (int i = 1; i <= Ind.Bar.MaxBar; i++)
                {
                    Ind.Bar.CurrentBar = i;

                    object prototype = null;
                    if (i == 1)
                    {
                        prototype = new Stochastic(thresholdPercentage);
                    }
                    else
                    {
                        prototype = (Stochastic)Ind.SlowStochastic(period, firstSmoothingPeriod, secondSmoothingPeriod, thresholdPercentage)[1].Clone();
                    }

                    Get(ref prototype, Ind);

                    Ind.SlowStochastic(period, firstSmoothingPeriod, secondSmoothingPeriod, thresholdPercentage)[0] = (Stochastic)prototype;

                    Ind.SlowStochastic(period, firstSmoothingPeriod, secondSmoothingPeriod, thresholdPercentage).IsPopulated = true;                     // set here so instance is guaranteed to exits
                }

                Ind.Bar.CurrentBar = oldCurrentBar;
            }
        }
        public override void GetAll(IIndicatorValues Ind)
        {
            IDivergentIndicator studyIndicator      = (IDivergentIndicator)this.IndicatorParameters.List[0];
            IDivergentIndicator divergenceIndicator = (IDivergentIndicator)this.IndicatorParameters.List[1];

            if (!Ind.Divergence(studyIndicator, divergenceIndicator).IsPopulated)
            {
                int oldCurrentBar = Ind.Bar.CurrentBar;
                for (int i = 1; i <= Ind.Bar.MaxBar; i++)
                {
                    Ind.Bar.CurrentBar = i;

                    object prototype = null;
                    if (i == 1)
                    {
                        prototype = new Divergence();
                    }
                    else
                    {
                        prototype = (Divergence)Ind.Divergence(studyIndicator, divergenceIndicator)[1].Clone();
                    }

                    Get(ref prototype, Ind);

                    Ind.Divergence(studyIndicator, divergenceIndicator)[0] = (Divergence)prototype;

                    Ind.Divergence(studyIndicator, divergenceIndicator).IsPopulated = true;                     // set here so instance is guaranteed to exits
                }

                Ind.Bar.CurrentBar = oldCurrentBar;
            }
        }
Exemple #12
0
        public override void Get(ref object Prototype, IIndicatorValues Ind)
        {
            int     period              = (int)this.IndicatorParameters.List[0];
            int     smoothingPeriod     = (int)this.IndicatorParameters.List[1];
            decimal thresholdPercentage = (decimal)this.IndicatorParameters.List[2];

            Decimal pfe   = Decimal.MinValue;
            Decimal alpha = 2.0M / (smoothingPeriod + 1.0M);

            Decimal directPath  = 0.0M;
            Decimal complexPath = 0.0M;

            if (Ind.Bar.CurrentBar > (period + 1))
            {
                for (int i = 0; i < period; i++)
                {
                    complexPath += (decimal)Math.Sqrt(Math.Pow((double)(Ind.Bar[i].Close - Ind.Bar[i + 1].Close), 2) + 1.0);
                }

                directPath = (decimal)Math.Sqrt(Math.Pow((double)(Ind.Bar[0].Close - Ind.Bar[period].Close), 2) + Math.Pow((double)period, 2));

                Decimal tmpFE = Math.Sign(Ind.Bar[0].Close - Ind.Bar[period].Close) * Math.Round((directPath / complexPath) * 100.0M, 0);
                pfe = (alpha * tmpFE) + ((1.0M - alpha) * Ind.PFE(period, smoothingPeriod, thresholdPercentage)[1].Value);
            }
            else
            {
                pfe = 0.0M;
            }

            (Prototype as PFE).Value = pfe;
        }
        public override void GetAll(IIndicatorValues Ind)
        {
            int     period             = (int)this.IndicatorParameters.List[0];
            int     volatilityPeriod   = (int)this.IndicatorParameters.List[1];
            decimal volitilityMultiple = (decimal)this.IndicatorParameters.List[2];
            decimal marginThreshold    = (decimal)this.IndicatorParameters.List[3];
            decimal proximityMultiple  = (decimal)this.IndicatorParameters.List[4];

            if (!Ind.VolatilityChannel(period, volatilityPeriod, volitilityMultiple, marginThreshold, proximityMultiple).IsPopulated)
            {
                int oldCurrentBar = Ind.Bar.CurrentBar;
                for (int i = 1; i <= Ind.Bar.MaxBar; i++)
                {
                    Ind.Bar.CurrentBar = i;

                    object prototype = null;
                    if (i == 1)
                    {
                        prototype = new VolatilityChannel(marginThreshold);
                    }
                    else
                    {
                        prototype = (VolatilityChannel)Ind.VolatilityChannel(period, volatilityPeriod, volitilityMultiple, marginThreshold, proximityMultiple)[1].Clone();
                    }

                    Get(ref prototype, Ind);

                    Ind.VolatilityChannel(period, volatilityPeriod, volitilityMultiple, marginThreshold, proximityMultiple)[0] = (VolatilityChannel)prototype;

                    Ind.VolatilityChannel(period, volatilityPeriod, volitilityMultiple, marginThreshold, proximityMultiple).IsPopulated = true;                     // set here so instance is guaranteed to exits
                }

                Ind.Bar.CurrentBar = oldCurrentBar;
            }
        }
Exemple #14
0
        public override void Get(ref object Prototype, IIndicatorValues Ind)
        {
            IDivergentIndicator divergentIndicator = (IDivergentIndicator)this.IndicatorParameters.List[0];

            (Prototype as Trends).PeakToPeak = divergentIndicator.GetPeakToPeakLine(0, Ind);
            (Prototype as Trends).DipToDip   = divergentIndicator.GetDipToDipLine(0, Ind);
        }
Exemple #15
0
        public override void Get(ref object Prototype, IIndicatorValues Ind)
        {
            GetData(ref Prototype, Ind);

            decimal proximateDistance = GetProximateDistance(Ind, Prototype);

            foreach (PriceRangeBarrierProperty barrierProperty in (Prototype as PriceRangeBarrierPropertiesBase).Properties)
            {
                barrierProperty.ProximateDistance = proximateDistance;
            }
        }
        public override void Get(ref object Prototype, IIndicatorValues Ind)
        {
            int period = (int)this.IndicatorParameters.List[0];

            decimal adxRelative = 0.0M;

            if (Ind.Bar.CurrentBar > period)
            {
                adxRelative = (Ind.ADXExponential(period, UNNEEDED_ADX_THRESHOLD)[0].ADXValue - Ind.ADXExponential(period, UNNEEDED_ADX_THRESHOLD)[period].ADXValue);
            }

            (Prototype as ADXRelative).Value = adxRelative;
        }
        protected override String GetPresentDetail(IOutputInstant Instant, IIndicatorValues Data, IndicatorParameters IndicatorParameters)
        {
            VPFEChannel channel = Data.VPFEChannel(IndicatorParameters)[Instant.ExposureDate];

            if (channel != null)
            {
                return(String.Format("{0}|{1}|{2}|{3}|{4}|", channel.Lower, channel.Mid, channel.Upper, (int)channel.Oscillation, channel.Oscillation));
            }
            else
            {
                return(String.Format("{0}|{1}|{2}|{3}|{4}|", "", "", "", "", ""));
            }
        }
Exemple #18
0
        protected override string GetPresentDetail(IOutputInstant Instant, IIndicatorValues Data, IndicatorParameters IndicatorParameters)
        {
            Stochastic stochastic = Data.SlowStochastic(IndicatorParameters)[Instant.ExposureDate];

            if (stochastic != null)
            {
                return(String.Format("{0}|{1}|{2}|{3}|", stochastic.PercentageK, stochastic.PercentageD, (int)stochastic.Oscillation, stochastic.Oscillation));
            }
            else
            {
                return(String.Format("{0}|{1}|{2}|{3}|", "", "", "", ""));
            }
        }
        protected override string GetPresentDetail(IOutputInstant Instant, IIndicatorValues Data, IndicatorParameters IndicatorParameters)
        {
            MomentumRelative momRelative = Data.MomentumRelative(IndicatorParameters)[Instant.ExposureDate];

            if (momRelative != null)
            {
                return(String.Format("{0}|{1}|{2}|", momRelative.Value, (int)momRelative.Direction, momRelative.Direction));
            }
            else
            {
                return(String.Format("{0}|{1}|{2}|", "", "", ""));
            }
        }
Exemple #20
0
        public override void Get(ref object Prototype, IIndicatorValues Ind)
        {
            int period = (int)this.IndicatorParameters.List[0];

            Decimal atr = 0.0M;

            if (Ind.Bar.CurrentBar > 1)
            {
                atr = ((Ind.ATR(period)[1].Value * (period - 1)) + Ind.TrueRange(TRUE_RANGE_PERIOD)[0].Value) / period;
            }

            (Prototype as ATR).Value = atr;
        }
        public override void Get(ref object Prototype, IIndicatorValues Ind)
        {
            int period = (int)this.IndicatorParameters.List[0];

            decimal momentum = 0.0M;

            if (Ind.Bar.CurrentBar > (period))
            {
                momentum = (Ind.Bar[0].Close - Ind.Bar[period].Close);
            }

            (Prototype as MomentumAbsolute).Value = momentum;
        }
Exemple #22
0
        protected override string GetPresentDetail(IOutputInstant Instant, IIndicatorValues Data, IndicatorParameters IndicatorParameters)
        {
            Trends trends = Data.Trends(IndicatorParameters)[Instant.ExposureDate];

            if (trends != null)
            {
                return(String.Format("{0}|{1}|", (int)trends.Direction, trends.Direction));
            }
            else
            {
                return(String.Format("{0}|{1}|", "", ""));
            }
        }
        protected override string GetPresentDetail(IOutputInstant Instant, IIndicatorValues Data, IndicatorParameters IndicatorParameters)
        {
            ADXRelative adx = Data.ADXExponentialRelative(IndicatorParameters)[Instant.ExposureDate];

            if (adx != null)
            {
                return(String.Format("{0}|{1}|{2}|", adx.Value, (int)adx.Trendiness, adx.Trendiness));
            }
            else
            {
                return(String.Format("{0}|{1}|{2}|", "", "", ""));
            }
        }
Exemple #24
0
        protected override string GetPresentDetail(IOutputInstant Instant, IIndicatorValues Data, IndicatorParameters IndicatorParameters)
        {
            Complexity fc = Data.Complexity(IndicatorParameters)[Instant.ExposureDate];

            if (fc != null)
            {
                return(String.Format("{0}|", fc.FractalComplexity));
            }
            else
            {
                return(String.Format("{0}|", ""));
            }
        }
        public override void Get(ref object Prototype, IIndicatorValues Ind)
        {
            int period = (int)this.IndicatorParameters.List[0];

            decimal relativeMomentum = 0.0M;

            if (Ind.Bar.CurrentBar > period)
            {
                relativeMomentum = (Ind.MomentumAbsolute(period)[0].Value - Ind.MomentumAbsolute(period)[period].Value);
            }

            (Prototype as MomentumRelative).Value = relativeMomentum;
        }
Exemple #26
0
        protected override string GetPresentDetail(IOutputInstant Instant, IIndicatorValues Data, IndicatorParameters IndicatorParameters)
        {
            RSI rsi = Data.RSI(IndicatorParameters)[Instant.ExposureDate];

            if (rsi != null)
            {
                return(String.Format("{0}|{1}|{2}|", rsi.Value, (int)rsi.Oscillation, rsi.Oscillation));
            }
            else
            {
                return(String.Format("{0}|{1}|{2}|", "", "", ""));
            }
        }
Exemple #27
0
        protected override string GetPresentDetail(IOutputInstant Instant, IIndicatorValues Data, IndicatorParameters IndicatorParameters)
        {
            CCI cci = Data.CCI(IndicatorParameters)[Instant.ExposureDate];

            if (cci != null)
            {
                return(String.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}|", cci.Value, (int)cci.Trendiness, cci.Trendiness, (int)cci.Direction, cci.Direction, (int)cci.Oscillation, cci.Oscillation));
            }
            else
            {
                return(String.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}|", "", "", "", "", "", "", ""));
            }
        }
Exemple #28
0
        protected override string GetPresentDetail(IOutputInstant Instant, IIndicatorValues Data, IndicatorParameters IndicatorParameters)
        {
            ADX adx = Data.ADXSimple(IndicatorParameters)[Instant.ExposureDate];

            if (adx != null)
            {
                return(String.Format("{0}|{1}|{2}|{3}|{4}|", adx.MinusDI, adx.PlusDI, adx.ADXValue, (int)adx.Trendiness, adx.Trendiness));
            }
            else
            {
                return(String.Format("{0}|{1}|{2}|{3}|{4}|", "", "", "", "", ""));
            }
        }
Exemple #29
0
        protected override string GetPresentDetail(IOutputInstant Instant, IIndicatorValues Data, IndicatorParameters IndicatorParameters)
        {
            ATR atr = Data.ATR(IndicatorParameters)[Instant.ExposureDate];

            if (atr != null)
            {
                return(String.Format("{0}|", atr.Value));
            }
            else
            {
                return(String.Format("{0}|", ""));
            }
        }
Exemple #30
0
        protected override string GetPresentDetail(IOutputInstant Instant, IIndicatorValues Data, IndicatorParameters IndicatorParameters)
        {
            PFE pfe = Data.PFE(IndicatorParameters)[Instant.ExposureDate];

            if (pfe != null)
            {
                return(String.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}|", pfe.Value, (int)pfe.Trendiness, pfe.Trendiness, (int)pfe.Direction, pfe.Direction, (int)pfe.Oscillation, pfe.Oscillation));
            }
            else
            {
                return(String.Format("{0}|{1}|{2}|{3}|{4}|{5}|{6}|", "", "", "", "", "", "", ""));
            }
        }