예제 #1
0
        private bool CheckupTest(ref ChartPointsPredition CPsP)//, List<ChartPoint> LCPointsToPredict, double spread)
        {
            if (CPsP.Type == ChartPointsPredition.Kind.Uncertain)
            {
                return(false);
            }

            List <ChartPoint> LCPointsToPredict = DLSCPoints[CPsP.Product].GetRange(CPsP.Position, CPsP.Ahead);


            this.CheckupTendencyToday(ref CPsP);
            // this.CheckupTendencyComplementary(ref CPsP);
            this.CheckupStrengthFactor(ref CPsP);


            bool bStrike = false;

            double dRealTendency = 50;

            if (CPsP.Type == ChartPointsPredition.Kind.Down)
            {
                dRealTendency = ANALYSIS.Tendency(LCPointsToPredict, false);

                if (CPsP.Tendency < 50 && dRealTendency < 50)
                {
                    bStrike = true;
                }
            }
            else if (CPsP.Type == ChartPointsPredition.Kind.Up)
            {
                dRealTendency = ANALYSIS.Tendency(LCPointsToPredict, true);

                if (CPsP.Tendency > 50 && dRealTendency > 50)
                {
                    bStrike = true;
                }
            }

            CPsP.Strike = bStrike;
            //CPsP.Accuracity = Accuracity;
            return(true);
        }
예제 #2
0
        private void CheckupTendencyComplementary(ref ChartPointsPredition CPsP)
        {
            List <ChartPoint> LCPToday = ARCHIVE.GetDATA(CPsP.TimeFrame, CPsP.Product, CPsP.DTOriginal.Date, CPsP.DTOriginal);

            int iPosition = ANALYSIS.ExtremumComplementaryPosition(LCPToday, LCPToday.Count, (double)CPsP.Deep / 2);
            //int iPositionBefore = ANALYSIS.ExtremumComplementaryPosition(LCPToday, iPosition + 1, (double)CPsP.Deep / 2);
            int iShiftCount = LCPToday.Count - iPosition;

            if (iShiftCount <= 0 || iPosition >= LCPToday.Count || iPosition - iShiftCount < 0)
            {
                CPsP.ExtremumConplementaryDistance = -1;
                CPsP.TendencyComplementary         = 50;
                return;
            }
            else
            {
                //List<double> LDChanges = (from CP in LCPToday select CP.Change).ToList(); int iCount = LDChanges.Count - iPosition; CPsP.TendencyComplementary = ANALYSIS.Tendency(LDChanges, iPosition, iCount);

                List <ChartPoint> LDCPRanged       = LCPToday.GetRange(iPosition, iShiftCount);
                List <ChartPoint> LDCPRangedBefore = LCPToday.GetRange(iPosition - iShiftCount, iShiftCount);


                double dTendency       = ANALYSIS.Tendency(LDCPRanged);
                double dTendencyBefore = ANALYSIS.Tendency(LDCPRangedBefore);

                if (dTendency < 50 && dTendencyBefore > 50 || dTendency > 50 && dTendencyBefore < 50)
                {
                    CPsP.ExtremumConplementaryDistance = -1;
                    CPsP.TendencyComplementary         = 50;
                    return;
                }

                CPsP.ExtremumConplementaryDistance = (LDCPRanged.Last().Time - LDCPRanged[0].Time).TotalMinutes;
                CPsP.TendencyComplementary         = (dTendency / dTendencyBefore) * 100;
            }
        }
예제 #3
0
        private void TimrAutoTrader_Tick(object sender, EventArgs e)
        {
            //if (ThrdAutoTread != null && ThrdAutoTread.IsAlive) return;

            List <ChartPointsPredition> LCPsPSimulated = this.LCPsPTestSelected.OrderByDescending(CPsP => CPsP.Resolution).ToList();


            if (LCPsPSimulated.Count < 1)
            {
                return;
            }

            ChartPointsPredition CPsPBest = null;

            List <Deals> LDeals = ODBlotter.GetData;

            for (int i = 0; i < LCPsPSimulated.Count; i++)
            {
                if (!LCPsPSimulated[i].IsActual)
                {
                    continue;
                }
                //if ((LCPsPSimulated[i].Tendency <= 50 && LCPsPSimulated[i].TendencyToday >= 50) ||  (LCPsPSimulated[i].Tendency >= 50 && LCPsPSimulated[i].TendencyToday <= 50)) continue;

                bool found = false;
                for (int i2 = 0; i2 < LDeals.Count; i++)
                {
                    try
                    {
                        if (LDeals[i2].PRODUCT == LCPsPSimulated[i].Product)
                        {
                            found = true;
                            break;
                        }
                    }
                    catch
                    {
                        found = true;
                        break;
                    }
                }

                if (!found)
                {
                    CPsPBest = LCPsPSimulated[i];
                    break;
                }
            }

            if (CPsPBest == null)
            {
                return;
            }

            string       product   = CPsPBest.Product;
            DateTime     DTLastGMT = CPsPBest.DTOriginal.AddMinutes(ABBREVIATIONS.ToMinutes(TimeFrame.ONE_MINUTE));
            List <Rates> LRAll     = ORBlotter.Archive.Get(product, DTLastGMT);

            // double dExecutionDataCount = (double)(ABBREVIATIONS.GreenwichMeanTime - DTLastGMT).TotalSeconds / 5;

            if (LRAll == null || LRAll.Count < 7)//dExecutionDataCount)
            {
                if (LRAll != null)
                {
                    TsslInfo2.Text = "Missing Execution Data ";               // +LRAll.Count + " / " + (int)dExecutionDataCount;
                }
                return;
            }



            //double dMin = 0, dMax = 0;  if (!this.Extrema(product, 60, ref dMin, ref dMax)) return;
            //List<ChartPoint> LCPAll = ARCHIVE.GetDATA(TFrame, product, ABBREVIATIONS.GreenwichMeanTime.Date);
            //double dTendencyGlobal = ANALYSIS.Tendency(LCPAll, -1, false);
            //double dTendencyLoacl = ANALYSIS.Tendency(LCPAll, 15, true);

            bool bBUY = false;

            if (CPsPBest.Type == ChartPointsPredition.Kind.Up)
            {
                bBUY = true;
            }

            int iLRCount = LRAll.Count;

            bool   bMatch = true;
            double dTendencyNow, dTendencyPrev;


            if (bBUY)
            {
                dTendencyPrev = 0;
            }
            else
            {
                dTendencyPrev = 100;
            }

            int iOFFTendencies = 0; int iOKTendencies = 0;
            int iSteps = 2;

            for (int i = iLRCount - 1; i > 2 && iSteps-- > 0; i /= 2)
            {
                dTendencyNow = ANALYSIS.Tendency(LRAll, i);

                if (bBUY && dTendencyNow < dTendencyPrev)
                {
                    bMatch = false;
                    break;
                }
                else if (!bBUY && dTendencyNow > dTendencyPrev)
                {
                    bMatch = false;
                    break;
                }

                dTendencyPrev = dTendencyNow;
                if ((dTendencyPrev >= 50 && bBUY) || (dTendencyPrev <= 50 && !bBUY))
                {
                    ++iOFFTendencies;
                }
                else
                {
                    ++iOKTendencies;
                }
            }

            double dOPRatio = ((double)iOFFTendencies / (iOFFTendencies + iOKTendencies)) * 100;

            //if (dOPRatio >= 40) return;

            if (!bMatch)
            {
                return;         // && dOPRatio > 40
            }
            this.Action(product, bBUY);



            Thread ThrdBeep = new Thread(delegate() { Console.Beep(250, 100); }); ThrdBeep.Start();
        }