예제 #1
0
        public IList <double> Execute(ISecurity source)
        {
            int            count       = source.Bars.Count;
            IList <double> source1     = ADXHelper.CalcDIP(source, this.ParPeriod, (IMemoryContext)this.Context);
            IList <double> source2     = ADXHelper.CalcDIM(source, this.ParPeriod, (IMemoryContext)this.Context);
            IList <double> doubleList1 = ADXHelper.CalcADX(source1, source2, this.ParPeriod, (IMemoryContext)this.Context);

            this.Context?.ReleaseArray((Array)source1);
            this.Context?.ReleaseArray((Array)source2);
            IList <double> closePrices = source.GetClosePrices(this.Context);
            IList <double> doubleList2 = Series.EMA(closePrices, this.ParPeriod, (IMemoryContext)this.Context);
            IList <bool>   boolList1   = (IList <bool>)(this.Context?.GetArray <bool>(count) ?? new bool[count]);
            IList <bool>   boolList2   = (IList <bool>)(this.Context?.GetArray <bool>(count) ?? new bool[count]);
            IList <double> doubleList3 = (IList <double>)(this.Context?.GetArray <double>(count) ?? new double[count]);

            for (int index = 1; index < count; ++index)
            {
                double num1 = 0.0;
                double num2 = 0.0;
                double num3 = 0.0;
                double num4 = 0.0;
                double num5 = 0.0;
                double num6 = 0.0;
                boolList1[index] = doubleList1[index] > doubleList1[index - 1];
                boolList2[index] = doubleList1[index] < doubleList1[index - 1];
                if (this.ParBolTrendUp)
                {
                    num1 = AdvFazyRynkaYedinyy.GetResADX(this.ParBolTrendUp, false, closePrices[index] > doubleList2[index] && doubleList1[index] > this.KoefADXD1, boolList1[index], boolList2[index]) ? 1.0 : 0.0;
                }
                if (this.ParMenTrendUp)
                {
                    num2 = AdvFazyRynkaYedinyy.GetResADX(false, this.ParMenTrendUp, closePrices[index] > doubleList2[index] && doubleList1[index] > this.KoefADXD1, boolList1[index], boolList2[index]) ? 2.0 : 0.0;
                }
                if (this.ParBolFlet)
                {
                    num3 = AdvFazyRynkaYedinyy.GetResADX(this.ParBolFlet, false, doubleList1[index] < this.KoefADXD1, boolList1[index], boolList2[index]) ? 3.0 : 0.0;
                }
                if (this.ParMenFlet)
                {
                    num4 = AdvFazyRynkaYedinyy.GetResADX(false, this.ParMenFlet, doubleList1[index] < this.KoefADXD1, boolList1[index], boolList2[index]) ? 4.0 : 0.0;
                }
                if (this.ParBolTrendDn)
                {
                    num5 = AdvFazyRynkaYedinyy.GetResADX(this.ParBolTrendDn, false, closePrices[index] < doubleList2[index] && doubleList1[index] > this.KoefADXD1, boolList1[index], boolList2[index]) ? 5.0 : 0.0;
                }
                if (this.ParMenTrendDn)
                {
                    num6 = AdvFazyRynkaYedinyy.GetResADX(false, this.ParMenTrendDn, closePrices[index] < doubleList2[index] && doubleList1[index] > this.KoefADXD1, boolList1[index], boolList2[index]) ? 6.0 : 0.0;
                }
                doubleList3[index] = num1 > 0.0 ? num1 : (num2 > 0.0 ? num2 : (num3 > 0.0 ? num3 : (num4 > 0.0 ? num4 : (num5 > 0.0 ? num5 : (num6 > 0.0 ? num6 : 0.0)))));
            }
            return(doubleList3);
        }
예제 #2
0
        public IList <bool> Execute(ISecurity source)
        {
            int            count      = source.Bars.Count;
            IList <double> source1    = ADXHelper.CalcDIP(source, this.ParPeriod, (IMemoryContext)this.Context);
            IList <double> source2    = ADXHelper.CalcDIM(source, this.ParPeriod, (IMemoryContext)this.Context);
            IList <double> doubleList = ADXHelper.CalcADX(source1, source2, this.ParPeriod, (IMemoryContext)this.Context);

            this.Context?.ReleaseArray((Array)source1);
            this.Context?.ReleaseArray((Array)source2);
            IList <bool> boolList = (IList <bool>)(this.Context?.GetArray <bool>(count) ?? new bool[count]);

            for (int index = 0; index < count; ++index)
            {
                boolList[index] = this.ParBol ? doubleList[index] > this.ParValue : doubleList[index] < this.ParValue;
            }
            return(boolList);
        }
        public IList <bool> Execute(ISecurity source)
        {
            int            count      = source.Bars.Count;
            IList <double> source1    = ADXHelper.CalcDIP(source, this.ParPeriod, (IMemoryContext)this.Context);
            IList <double> source2    = ADXHelper.CalcDIM(source, this.ParPeriod, (IMemoryContext)this.Context);
            IList <double> doubleList = ADXHelper.CalcADX(source1, source2, this.ParPeriod, (IMemoryContext)this.Context);

            this.Context?.ReleaseArray((Array)source1);
            this.Context?.ReleaseArray((Array)source2);
            IList <bool> boolList = (IList <bool>)(this.Context?.GetArray <bool>(count) ?? new bool[count]);
            int          paRi1    = this.PARi;

            for (int paRi2 = this.PARi; paRi2 < count; ++paRi2)
            {
                boolList[paRi2] = this.ParBol ? doubleList[paRi2] > doubleList[paRi2 - paRi1] : doubleList[paRi2] < doubleList[paRi2 - paRi1];
            }
            return(boolList);
        }
예제 #4
0
        public IList <bool> Execute(ISecurity source)
        {
            int            count       = source.Bars.Count;
            IList <double> source1     = ADXHelper.CalcDIP(source, this.ParPeriod, (IMemoryContext)this.Context);
            IList <double> source2     = ADXHelper.CalcDIM(source, this.ParPeriod, (IMemoryContext)this.Context);
            IList <double> doubleList1 = ADXHelper.CalcADX(source1, source2, this.ParPeriod, (IMemoryContext)this.Context);

            this.Context?.ReleaseArray((Array)source1);
            this.Context?.ReleaseArray((Array)source2);
            IList <double> closePrices = source.GetClosePrices(this.Context);
            IList <double> doubleList2 = Series.EMA(closePrices, this.ParPeriod, (IMemoryContext)this.Context);
            IList <bool>   boolList    = (IList <bool>)(this.Context?.GetArray <bool>(count) ?? new bool[count]);

            for (int index = 0; index < count; ++index)
            {
                boolList[index] = !this.ParTrendUp || this.ParFlet || this.ParTrendDn ? (this.ParTrendUp || !this.ParFlet || this.ParTrendDn ? (this.ParTrendUp || this.ParFlet || !this.ParTrendDn ? (!this.ParTrendUp || !this.ParFlet || this.ParTrendDn ? (!this.ParTrendUp || this.ParFlet || !this.ParTrendDn ? (this.ParTrendUp || !this.ParFlet || !this.ParTrendDn ? this.ParTrendUp && this.ParFlet && this.ParTrendDn && (closePrices[index] > doubleList2[index] && doubleList1[index] > this.KoefADXD1 || doubleList1[index] < this.KoefADXD1 || closePrices[index] < doubleList2[index] && doubleList1[index] > this.KoefADXD1) : doubleList1[index] < this.KoefADXD1 || closePrices[index] < doubleList2[index] && doubleList1[index] > this.KoefADXD1) : doubleList1[index] > this.KoefADXD1) : closePrices[index] > doubleList2[index] && doubleList1[index] > this.KoefADXD1 || doubleList1[index] < this.KoefADXD1) : closePrices[index] < doubleList2[index] && doubleList1[index] > this.KoefADXD1) : doubleList1[index] < this.KoefADXD1) : closePrices[index] > doubleList2[index] && doubleList1[index] > this.KoefADXD1;
            }
            return(boolList);
        }
예제 #5
0
        public IList <bool> Execute(ISecurity source)
        {
            int            count       = source.Bars.Count;
            IList <double> source1     = ADXHelper.CalcDIP(source, this.ParPeriod, (IMemoryContext)this.Context);
            IList <double> source2     = ADXHelper.CalcDIM(source, this.ParPeriod, (IMemoryContext)this.Context);
            IList <double> doubleList1 = ADXHelper.CalcADX(source1, source2, this.ParPeriod, (IMemoryContext)this.Context);

            this.Context?.ReleaseArray((Array)source1);
            this.Context?.ReleaseArray((Array)source2);
            IList <double> closePrices = source.GetClosePrices(this.Context);
            IList <double> doubleList2 = Series.EMA(closePrices, this.ParPeriod, (IMemoryContext)this.Context);
            IList <bool>   boolList1   = (IList <bool>)(this.Context?.GetArray <bool>(count) ?? new bool[count]);
            IList <bool>   boolList2   = (IList <bool>)(this.Context?.GetArray <bool>(count) ?? new bool[count]);
            IList <bool>   boolList3   = (IList <bool>)(this.Context?.GetArray <bool>(count) ?? new bool[count]);

            for (int index = 1; index < count; ++index)
            {
                boolList3[index] = false;
                boolList1[index] = doubleList1[index] > doubleList1[index - 1];
                boolList2[index] = doubleList1[index] < doubleList1[index - 1];
                if ((this.ParBolTrendUp || this.ParMenTrendUp) && (!this.ParBolFlet && !this.ParMenFlet) && (!this.ParBolTrendDn && !this.ParMenTrendDn))
                {
                    bool resAdx = AdvFazyRynkaThree.GetResADX(this.ParBolTrendUp, this.ParMenTrendUp, closePrices[index] > doubleList2[index] && doubleList1[index] > this.KoefADXD1, boolList1[index], boolList2[index]);
                    boolList3[index] = resAdx;
                }
                else if (!this.ParBolTrendUp && !this.ParMenTrendUp && (this.ParBolFlet || this.ParMenFlet) && (!this.ParBolTrendDn && !this.ParMenTrendDn))
                {
                    bool resAdx = AdvFazyRynkaThree.GetResADX(this.ParBolFlet, this.ParMenFlet, doubleList1[index] < this.KoefADXD1, boolList1[index], boolList2[index]);
                    boolList3[index] = resAdx;
                }
                else if (!this.ParBolTrendUp && !this.ParMenTrendUp && (!this.ParBolFlet && !this.ParMenFlet) && (this.ParBolTrendDn || this.ParMenTrendDn))
                {
                    bool resAdx = AdvFazyRynkaThree.GetResADX(this.ParBolTrendDn, this.ParMenTrendDn, closePrices[index] < doubleList2[index] && doubleList1[index] > this.KoefADXD1, boolList1[index], boolList2[index]);
                    boolList3[index] = resAdx;
                }
                if ((this.ParBolTrendUp || this.ParMenTrendUp) && (this.ParBolFlet || this.ParMenFlet) && (!this.ParBolTrendDn && !this.ParMenTrendDn))
                {
                    bool resAdx1 = AdvFazyRynkaThree.GetResADX(this.ParBolTrendUp, this.ParMenTrendUp, closePrices[index] > doubleList2[index] && doubleList1[index] > this.KoefADXD1, boolList1[index], boolList2[index]);
                    bool resAdx2 = AdvFazyRynkaThree.GetResADX(this.ParBolFlet, this.ParMenFlet, doubleList1[index] < this.KoefADXD1, boolList1[index], boolList2[index]);
                    boolList3[index] = resAdx1 || resAdx2;
                }
                else if ((this.ParBolTrendUp || this.ParMenTrendUp) && (!this.ParBolFlet && !this.ParMenFlet) && (this.ParBolTrendDn || this.ParMenTrendDn))
                {
                    bool resAdx1 = AdvFazyRynkaThree.GetResADX(this.ParBolTrendUp, this.ParMenTrendUp, closePrices[index] > doubleList2[index] && doubleList1[index] > this.KoefADXD1, boolList1[index], boolList2[index]);
                    bool resAdx2 = AdvFazyRynkaThree.GetResADX(this.ParBolTrendDn, this.ParMenTrendDn, closePrices[index] < doubleList2[index] && doubleList1[index] > this.KoefADXD1, boolList1[index], boolList2[index]);
                    boolList3[index] = resAdx1 || resAdx2;
                }
                else if (!this.ParBolTrendUp && !this.ParMenTrendUp && (this.ParBolFlet || this.ParMenFlet) && (this.ParBolTrendDn || this.ParBolTrendDn))
                {
                    bool resAdx1 = AdvFazyRynkaThree.GetResADX(this.ParBolFlet, this.ParMenFlet, doubleList1[index] < this.KoefADXD1, boolList1[index], boolList2[index]);
                    bool resAdx2 = AdvFazyRynkaThree.GetResADX(this.ParBolTrendDn, this.ParMenTrendDn, closePrices[index] < doubleList2[index] && doubleList1[index] > this.KoefADXD1, boolList1[index], boolList2[index]);
                    boolList3[index] = resAdx1 || resAdx2;
                }
                else if ((this.ParBolTrendUp || this.ParMenTrendUp) && (this.ParBolFlet || this.ParMenFlet) && (this.ParBolTrendDn || this.ParMenTrendDn))
                {
                    bool resAdx1 = AdvFazyRynkaThree.GetResADX(this.ParBolTrendUp, this.ParMenTrendUp, closePrices[index] > doubleList2[index] && doubleList1[index] > this.KoefADXD1, boolList1[index], boolList2[index]);
                    bool resAdx2 = AdvFazyRynkaThree.GetResADX(this.ParBolFlet, this.ParMenFlet, doubleList1[index] < this.KoefADXD1, boolList1[index], boolList2[index]);
                    bool resAdx3 = AdvFazyRynkaThree.GetResADX(this.ParBolTrendDn, this.ParMenTrendDn, closePrices[index] < doubleList2[index] && doubleList1[index] > this.KoefADXD1, boolList1[index], boolList2[index]);
                    boolList3[index] = resAdx1 || resAdx2 || resAdx3;
                }
            }
            return(boolList3);
        }