Exemplo n.º 1
0
        public bool Extrema(string product, int lastMinutes, ref double min, ref double max)
        {
            List <ChartPoint> LCPoints = ARCHIVE.GetDATA(TimeFrame.ONE_MINUTE, product, ABBREVIATIONS.GreenwichMeanTime.AddMinutes(-lastMinutes));

            min = double.MaxValue;
            max = double.MinValue;
            for (int i = 0; i < LCPoints.Count; i++)
            {
                if (LCPoints[i].LOW <= min)
                {
                    min = LCPoints[i].LOW;
                }
                else if (LCPoints[i].HIGH >= max)
                {
                    max = LCPoints[i].HIGH;
                }
            }


            if (min < double.MaxValue && max > double.MinValue)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 2
0
        private void TimrSimulationTest_Tick(object sender, EventArgs e)
        {
            if (!ARCHIVE.IsLoaded || !ARCHIVE.Updated || !SIMULATION.Updated)
            {
                return;
            }

            if (ThrdPREDICTIONTEST != null && ThrdPREDICTIONTEST.IsAlive)
            {
                return;
            }

            ThrdPREDICTIONTEST = new Thread(delegate()
            {
                if (ARCHIVE.IsLoaded)
                {
                    List <string> LSProducts    = ARCHIVE.GetProducts();
                    List <string> LSSubProducts = new List <string>(new string[] { "EUR/USD" });//, "USD/JPY", "GBP/USD", "NZD/USD", "AUD/USD"


                    SIMULATION.Test(LSSubProducts);
                }
            });

            ThrdPREDICTIONTEST.Priority = ThreadPriority.Normal;// ThreadPriority.Highest;
            ThrdPREDICTIONTEST.Start();
        }
Exemplo n.º 3
0
        private void CheckupStrengthFactor(ref ChartPointsPredition CPsP)
        {
            List <ChartPoint> LCPOrigin = ARCHIVE.GetDATA(CPsP.TimeFrame, CPsP.Product, CPsP.Position - CPsP.Deep, CPsP.Deep);
            List <double>     LDOPeak   = (from CP in LCPOrigin select CP.Peak).ToList();
            List <double>     LDOBase   = (from CP in LCPOrigin select CP.Peak).ToList();

            CPsP.SetStrengthFactor(LDOPeak, LDOBase);
        }
Exemplo n.º 4
0
        public bool AlternateProduct(OpenRatesBlotter ORBlotter, TimeFrame TFrame, int count, string product, ref int shift, ref int shiftAlternative, int maxShift, ref string alternative, ref string counterAlternative)
        {
            List <string> LSProd      = ARCHIVE.GetProducts();
            int           iLCPCount   = ARCHIVE.GetDATACount(TFrame, product);
            int           iLastPoints = count;
            int           iStartIdx   = iLCPCount - iLastPoints;
            Rates         RATE        = ORBlotter.Get(product);
            int           iDecimals   = RATE.Decimals;

            double dBestCompare  = double.MinValue;
            double dWorstCompare = double.MaxValue;

            alternative = counterAlternative = "";

            foreach (string sP in LSProd)
            {
                if (sP == product)
                {
                    continue;
                }

                Rates RATESecond      = ORBlotter.Get(sP);
                int   iDecimalsSecond = RATESecond.Decimals;

                int iLCPCountSecondary         = ARCHIVE.GetDATACount(TFrame, sP);
                List <ChartPoint> LCPPrimary   = ARCHIVE.GetDATA(TFrame, product, iStartIdx, iLastPoints);
                List <ChartPoint> LCPSecondary = ARCHIVE.GetDATA(TFrame, sP, iLCPCountSecondary - iLastPoints, iLastPoints);
                int iShift = 0;

                double dCompaison = this.CompareCharts(LCPPrimary, LCPSecondary, iDecimals, iDecimalsSecond, maxShift, ref iShift);

                if (dCompaison > dBestCompare)
                {
                    dBestCompare = dCompaison;
                    alternative  = sP;
                    shift        = iShift;
                }

                if (dCompaison < dWorstCompare)
                {
                    dWorstCompare      = dCompaison;
                    counterAlternative = sP;
                    shiftAlternative   = iShift;
                }
            }


            if (shift != 0 || alternative == "" || counterAlternative == "")
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Exemplo n.º 5
0
        private void CheckupTendencyToday(ref ChartPointsPredition CPsP)
        {
            List <ChartPoint> LCPToday = ARCHIVE.GetDATA(CPsP.TimeFrame, CPsP.Product, CPsP.DTOriginal.Date, CPsP.DTOriginal);
            //List<double> LDChanges = (from CP in LCPToday select CP.Change).ToList();

            double dExtremumTodayDistance;

            CPsP.TendencyToday         = ANALYSIS.TendencyLastExtremum(LCPToday, out dExtremumTodayDistance);//ANALYSIS.Tendency(LDChanges, LDChanges.Count);
            CPsP.ExtremumTodayDistance = dExtremumTodayDistance;
        }
Exemplo n.º 6
0
        //should return expecting gains percentage time and duration
        public void Gains()
        {
            foreach (string product in ARCHIVE.GetProducts())
            {
                TimeFrame         TFrame      = TimeFrame.FIFTEEN_MINUTE;
                List <ChartPoint> LCPoints    = ARCHIVE.GetDATA(TFrame, product);
                List <ChartPoint> LCPSelected = new List <ChartPoint>(from CP in LCPoints where CP.Change > 0 select CP);

                double v  = this.AverageGainStreak(LCPSelected, TFrame);
                double v2 = this.SampleStandardDeviationGainStreak(LCPSelected, TFrame);
            }
        }
Exemplo n.º 7
0
        private void TimrArchive_Tick(object sender, EventArgs e)
        {
            if (ThrdARCHIVE == null || !ThrdARCHIVE.IsAlive)
            {
                int DataKind = ORBlotter.Count;

                if (ARCHIVE.IsLoaded)
                {
                    if (!ARCHIVE.Saving && bSaveArchive == false)
                    {
                        BtnSaveArchive.Text    = "SAVE ARCHIVE";
                        BtnSaveArchive.Enabled = true;
                    }
                    else if (bSaveArchive)
                    {
                        BtnSaveArchive.Enabled = false;
                        BtnSaveArchive.Text    = "SAVING ... ";
                    }
                }



                ThrdARCHIVE = new Thread(delegate()
                {
                    if (!ARCHIVE.IsLoaded)
                    {
                        ARCHIVE.LoadAll();
                    }

                    counterCurrentArchiveUpdates += ARCHIVE.UpdateAll(bSaveArchive);


                    if (bSaveArchive && ARCHIVE.Saved)
                    {
                        counterCurrentArchiveSaved = counterCurrentArchiveUpdates;
                        bSaveArchive = false;
                    }


                    //ARCHIVE.RepairAll();

                    ThrdARCHIVE.Abort();
                });

                ThrdARCHIVE.Start();

                double dRatio = ((double)(counterCurrentArchiveSaved + 1) / (counterCurrentArchiveUpdates + 1)) * 100;
                TSSPBArchives.Value = (int)dRatio;
            }
        }
Exemplo n.º 8
0
        public void Predict(TimeFrame TFrame, double[] IASymiliarities)
        {
            if (this.AvalaibleMeans() <= 0)
            {
                return;
            }

            //int iMinutes = ABBREVIATIONS.ToMinutes(TFrame);

            List <string> LSLiquids = ANALYSIS.GetLiquids(ARCHIVE.GetProducts(), ORBlotter, 60, 30, dSpreadFactor, TFrame); //Chooce only those products whose Activity in last 5 minutes is above 0.5 of spread //List<string> LSLiquidsLive = ANALYSIS.GetLiquidsLive(ORBlotter, 50, 3, 0.2, TFrame);

            if (LSLiquids.Count < 10 && dSpreadFactor > 0.35)
            {
                dSpreadFactor -= 0.0025;
            }
            else if (LSLiquids.Count > 20)
            {
                dSpreadFactor += 0.0025;
            }



            //List<Thread> LThrdLiquid = new List<Thread>();
            foreach (string product in LSLiquids)//ORBlotter.GetProducts)
            {
                //LThrdLiquid.Add(new Thread(delegate() {

                List <ChartPoint> LCPoints          = ARCHIVE.GetDATA(TFrame, product);
                ChartPoint        CPLAst            = LCPoints.Last();
                List <ChartPoint> LCPointsSpecified = ORBlotter.Archive.Get(product, TFrame, IASymiliarities.Length);

                if (LCPointsSpecified != null)
                {
                    ChartPointPredition      CPPrediction = ANALYSIS.PredictNextSpecified(product, LCPoints, LCPointsSpecified, TFrame, ORBlotter.Get(product).Decimals, IASymiliarities);
                    ChartPointPredition.Kind CPPKind      = CPPrediction.Prognosis();


                    if (CPPKind != ChartPointPredition.Kind.Uncertain)
                    {
                        this.TryUpdate(CPPrediction);
                    }
                }
                //  }));
                // LThrdLiquid.Last().Priority = ThreadPriority.BelowNormal;
                // LThrdLiquid.Last().Start();
            }

            //foreach (Thread Thrd in LThrdLiquid)  Thrd.Join();
        }
Exemplo n.º 9
0
        private void StartConnection()
        {
            try
            {
                if (SOCMain != null && SOCMain.Connected)
                {
                    SOCMain.Shutdown(SocketShutdown.Both);
                    Thread.Sleep(100);
                    SOCMain.Close();
                }

                IPAddress[] AIPAdresses = Dns.GetHostEntry(HOST).AddressList;
                var         ADRESS      = AIPAdresses[0];
                SOCMain = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);
                IPEndPoint IPEPMain = new IPEndPoint(ADRESS, PORT);

                SOCMain.Blocking = false;
                AsyncCallback ACallbackConnected = new AsyncCallback(OcConnect);
                //Thread.Sleep(1000);
                SOCMain.BeginConnect(IPEPMain, ACallbackConnected, SOCMain);

                var CEDAA_CreditalsWithBrandCode = CEDA_Authentification.AuthenticateCredentialsWithBrandCode(USERID, PASSWORD, BRANDCODE); //var CEDAA_Creditals = CEDA_Authentification.AuthenticateCredentials(USERID, PASSWORD); //LOGIN FOR TOKEN
                TOKEN = CEDAA_CreditalsWithBrandCode.token;                                                                                 // TOKEN  = CEDAA_Creditals.token;

                if (ORBlotter != null || PSBlotter != null || ARCHIVE != null || OSBlotter != null)
                {
                    ODBlotter.Restart(TOKEN);
                    PSBlotter.Restart(TOKEN);
                    ARCHIVE.Restart(TOKEN);
                    OSBlotter.Restart(TOKEN);
                    this.SendString(TOKEN + "\r");
                }



                //this.UpdateDeals();
                //this.UpdateAccount();
            }
            catch
            {
                try { TsslInfo.Text = "Restart Failed [" + ++iRestartFails + "]x "; }
                catch { }
                this.StartConnection();
            }
        }
Exemplo n.º 10
0
        public bool Load(string product, TimeFrame TFrame, int deep, int ahead, int count)
        {
            if (DLSCPoints.ContainsKey(product)) //if up to date, refresh data base and return
            {
                DLSCPoints[product] = ARCHIVE.GetDATA(TFrame, product);
                return(false);
            }
            else
            {
                DLSCPoints.Add(product, ARCHIVE.GetDATA(TFrame, product));
            }


            List <ChartPointsPredition> LDCPsPoints = DATABASE.Load_ChartPointsPrediction(product, ABBREVIATIONS.ToString(TFrame), deep, ahead);


            int iPosition = DLSCPoints[product].Count - count;

            if (LDCPsPoints == null || LDCPsPoints.Count == 0)
            {
                DATA.Add(product, new List <ChartPointsPredition>());
            }
            else
            {
                if (LDCPsPoints.Count > count)
                {
                    LDCPsPoints.RemoveRange(0, LDCPsPoints.Count - count);
                }

                for (int i = 0; i < LDCPsPoints.Count; i++)
                {
                    LDCPsPoints[i].Prognosis(0);
                }

                DATA.Add(product, LDCPsPoints);
            }

            return(true);
        }
Exemplo n.º 11
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;
            }
        }
Exemplo n.º 12
0
        public List <string> GetLiquids(List <string> LSProducts, OpenRatesBlotter ORBlotter, double minPercentage, int deep, double spreadFactor, TimeFrame TFrame)
        {
            List <string> LSLiquidProducts = new List <string>();

            foreach (string product in ARCHIVE.GetProducts())
            {
                Rates             RATE          = ORBlotter.Get(product);
                int               iMinutesFrame = ABBREVIATIONS.ToMinutes(TFrame);
                List <ChartPoint> LCPoints      = ARCHIVE.GetDATA(TFrame, product);


                DateTime DTLast100 = ABBREVIATIONS.GreenwichMeanTime.AddMinutes(-deep * iMinutesFrame);

                List <ChartPoint> LCPLast100 = (from CP in LCPoints where CP.Time > DTLast100 select CP).ToList();

                if (this.LiquidPercentage(LCPLast100, RATE, spreadFactor) > minPercentage)
                {
                    LSLiquidProducts.Add(product);
                }
            }


            return(LSLiquidProducts);
        }
Exemplo n.º 13
0
 internal static HandleRef getCPtr(ARCHIVE obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
Exemplo n.º 14
0
        private void TimrSimulation_Tick(object sender, EventArgs e)
        {
            if (!ARCHIVE.IsLoaded || !ARCHIVE.Updated)
            {
                return;
            }

            //
            {
                if (!SIMULATION.Saving && !SIMULATION.Saved)
                {
                    BtnSavePredictions.Text    = "SAVE PREDICTIONS";
                    BtnSavePredictions.Enabled = true;
                }
                else if (SIMULATION.Saving)
                {
                    BtnSavePredictions.Enabled = false;
                    BtnSavePredictions.Text    = "SAVING ... ";
                }

                if (SIMULATION.Saved)
                {
                    bSavePrediction = false;
                }
            }

            if ((ThrdPREDICTION != null && ThrdPREDICTION.IsAlive) || !ARCHIVE.IsLoaded)
            {
                return;
            }

            ThrdPREDICTION = new Thread(delegate()
            {
                List <string> LSProducts    = ARCHIVE.GetProducts();                                    //LSProducts[27]
                List <string> LSSubProducts = new List <string>(new string[] { "EUR/USD", "XAU/USD" }); //, "USD/JPY", "GBP/USD", "XAU/USD" });// , "USD/CAD" , "XAG/USD" ", "AUD/USD", , "USD/CHF"

                foreach (string product in LSSubProducts)
                {
                    if (!LSProducts.Contains(product))
                    {
                        throw new Exception("Currency: " + product + " misssing in archive !");
                    }
                }

                //  LSSubProducts = LSProducts;


                /*SIMULATION.Start(TimeFrame.ONE_MINUTE, 14 * 1440, 20, 10, 10, LSSubProducts, bSavePrediction);
                 * SIMULATION1.Start(TimeFrame.FIVE_MINUTE, 14 * 1440, 20, 10, 10, LSSubProducts, bSavePrediction);
                 * SIMULATION2.Start(TimeFrame.FIFTEEN_MINUTE, 14 * 1440, 20, 10, 10, LSSubProducts, bSavePrediction);*/

                for (int i = 0; i < LTSimulation.Count; i++)
                {
                    LTSimulation[i].Join();
                }



                LTSimulation = new List <Thread>();
                LTSimulation.Add(new Thread(delegate() { SIMULATION.Start(TimeFrame.THIRTY_MINUTE, 60 * 24, 4, 2, LSSubProducts, bSavePrediction); }));//30-15,60-30,120-60
                //LTSimulation.Add(new Thread(delegate() { SIMULATION1.Start(TimeFrame.TEN_MINUTE, 42 * 1440, 30, 5, LSSubProducts, bSavePrediction); }));
                //LTSimulation.Add(new Thread(delegate() { SIMULATION2.Start(TimeFrame.FIFTEEN_MINUTE, 42 * 1440, 30, 5, LSSubProducts, bSavePrediction); }));

                /* LTSimulation.Add(new Thread(delegate() {
                 *   List<ChartPointsPredition> LCPsPNew = SIMULATION.Select(LSSubProducts);
                 *   this.Update(ref LCPsPTestSelected, LCPsPNew);
                 * }));
                 *
                 * LTSimulation.Add(new Thread(delegate()
                 * {
                 *   List<ChartPointsPredition> LCPsPNew = SIMULATION1.Select(LSSubProducts);
                 *   this.Update(ref LCPsPTestSelected1, LCPsPNew);
                 * }));*/

                for (int i = 0; i < LTSimulation.Count; i++)
                {
                    LTSimulation[i].Start();
                    LTSimulation[i].Priority = ThreadPriority.Normal;
                }



                // for (int i = 0; i < LTSimulation.Count; i++ ) LTSimulation[i].Join();
            });

            ThrdPREDICTION.Priority    = ThreadPriority.Normal;// ThreadPriority.Highest;
            TradeCurrentExecutionDelay = (int)((DateTime.Now - DTPredict).TotalSeconds + 1);
            ThrdPREDICTION.Start();
            TsslInfo2.Text = "Prediction Execution Time: " + TradeCurrentExecutionDelay + " [s]";
            DTPredict      = DateTime.Now;



            double dRatio = ((double)(SIMULATION.Saves + 1) / (SIMULATION.Predictions + 1)) * 100;

            TSSPBPredictions.Value = (int)dRatio;
        }
Exemplo n.º 15
0
        public double WeightFactor(Rates RATE, int position, int deep, int ahead, bool averange, double step, double range, int setID) //symilarity must be above 60%
        {
            string    product   = RATE.CCY_Pair;
            TimeFrame TFrame    = TimeFrame.ONE_MINUTE;
            int       iDecimals = RATE.Decimals;
            double    dPipValue = Math.Pow(10, -iDecimals);


            List <ChartPoint> LCPoints          = ARCHIVE.GetDATA(TFrame, product, 0, position);
            List <ChartPoint> LCPointsSpecified = ARCHIVE.GetDATA(TFrame, product, position - deep, deep);
            List <ChartPoint> LCPointsAll       = ARCHIVE.GetDATA(TFrame, product, 0, position + ahead);

            List <double> LDSetChange = (from CP in LCPointsAll select Math.Round(CP.Change, iDecimals)).ToList();
            List <double> LDSetPeak   = (from CP in LCPointsAll select Math.Round(CP.Peak, iDecimals)).ToList();
            List <double> LDSetBase   = (from CP in LCPointsAll select Math.Round(CP.Base, iDecimals)).ToList();

            //double dTopSubSim = 0;
            //

            List <double> LDWFactors     = new List <double>();
            List <double> LDSymilarities = new List <double>();

            double[] DAWeightFactor = new double[5];

            for (double dWF = -step * range; dWF <= step * range; dWF += step)
            {
                DAWeightFactor[setID] = dWF;

                ChartPointsPredition CPsPrediction    = new ChartPointsPredition();
                ChartPointsPredition CPsPredictionNow = new ChartPointsPredition();
                double dSymilMax = 90;
                double dSymilMin = 50;

                do
                {
                    double dSymil = (dSymilMax + dSymilMin) / 2;

                    ChartPointsPredition CPsP = null;// this.PredictNextSpecified(product, LCPoints, LCPointsSpecified, TFrame, iDecimals, dSymil, ahead, DAWeightFactor);
                    if (CPsP.Prognosis(1) != ChartPointsPredition.Kind.Uncertain)
                    {
                        CPsPredictionNow = CPsP;
                    }

                    if (CPsP.Matches < 10)
                    {
                        dSymilMax = dSymil;
                    }
                    else
                    {
                        dSymilMin = dSymil;
                    }


                    if ((dSymilMax - dSymilMin <= 1) || (CPsPredictionNow.Matches >= 10 && CPsPredictionNow.Matches < 50 && CPsPredictionNow.Analised))
                    {
                        CPsPrediction = CPsPredictionNow;
                        break;
                    }
                } while (true);

                if (CPsPrediction.Matches == 0)
                {
                    continue;
                }

                double dSimChange = this.Compare(LDSetChange, CPsPrediction.LDChange, position);
                double dSimPeak   = this.Compare(LDSetPeak, CPsPrediction.LDPeak, position);
                double dSimBase   = this.Compare(LDSetBase, CPsPrediction.LDBase, position);
                double dSubSim    = (dSimChange * dSimPeak * dSimBase) / (100 * 100);

                LDWFactors.Add(dWF);
                LDSymilarities.Add(dSubSim);
            }

            double dLESum   = 0;
            double dGESum   = 0;
            int    iGECount = 0;
            int    iLECount = 0;

            for (int i = 0; i < LDWFactors.Count; i++)
            {
                if (LDWFactors[i] > 0)
                {
                    dGESum += LDSymilarities[i];
                    ++iGECount;
                }
                else if (LDWFactors[i] < 0)
                {
                    dLESum += LDSymilarities[i];
                    ++iLECount;
                }
            }

            double dGES = dGESum / iGECount;
            double dLES = dLESum / iLECount;

            double dTobWF     = 0;
            double dTopSubSim = 0;

            if (!averange)
            {
                for (int i = 0; i < LDWFactors.Count; i++)
                {
                    if (((dGES > dLES) && LDWFactors[i] > 0 && LDSymilarities[i] > dTopSubSim) ||
                        ((dGES < dLES) && LDWFactors[i] < 0 && LDSymilarities[i] > dTopSubSim))
                    {
                        dTopSubSim = LDSymilarities[i];
                        dTobWF     = LDWFactors[i];
                    }
                }
            }
            else
            {
                double dSumWF       = 0;
                double dSumWeightWF = 0;
                for (int i = 0; i < LDWFactors.Count; i++)
                {
                    if ((dGES > dLES && LDWFactors[i] > 0) || (dGES < dLES && LDWFactors[i] < 0))
                    {
                        dSumWF       += LDWFactors[i] * LDSymilarities[i];
                        dSumWeightWF += LDSymilarities[i];
                        dTobWF        = dSumWF / dSumWeightWF;
                    }
                }
            }



            return(dTobWF);
        }
Exemplo n.º 16
0
        public double CheckSimilarity(Rates RATE, int position, int deep, int ahead, double[] DAWeightFacotrs) //symilarity must be above 60%
        {
            string    product   = RATE.CCY_Pair;
            TimeFrame TFrame    = TimeFrame.ONE_MINUTE;
            int       iDecimals = RATE.Decimals;
            double    dPipValue = Math.Pow(10, -iDecimals);


            List <ChartPoint> LCPoints          = ARCHIVE.GetDATA(TFrame, product, 0, position);
            List <ChartPoint> LCPointsSpecified = ARCHIVE.GetDATA(TFrame, product, position - deep, deep);
            List <ChartPoint> LCPointsAll       = ARCHIVE.GetDATA(TFrame, product, 0, position + ahead);

            List <double> LDSetChange = (from CP in LCPointsAll select Math.Round(CP.Change, iDecimals)).ToList();
            List <double> LDSetPeak   = (from CP in LCPointsAll select Math.Round(CP.Peak, iDecimals)).ToList();
            List <double> LDSetBase   = (from CP in LCPointsAll select Math.Round(CP.Base, iDecimals)).ToList();


            ChartPointsPredition CPsPrediction    = new ChartPointsPredition();
            ChartPointsPredition CPsPredictionNow = new ChartPointsPredition();
            double dSymilMax = 90;
            double dSymilMin = 50;

            do
            {
                double dSymil = (dSymilMax + dSymilMin) / 2;

                ChartPointsPredition CPsP = null;    // this.PredictNextSpecified(product, LCPoints, LCPointsSpecified, TFrame, iDecimals, dSymil, ahead, DAWeightFacotrs);
                if (CPsP.Prognosis(1) != ChartPointsPredition.Kind.Uncertain)
                {
                    CPsPredictionNow = CPsP;
                }

                if (CPsP.Matches < 10)
                {
                    dSymilMax = dSymil;
                }
                else
                {
                    dSymilMin = dSymil;
                }


                if ((dSymilMax - dSymilMin <= 1) || (CPsPredictionNow.Matches >= 10 && CPsPredictionNow.Matches < 50 && CPsPredictionNow.Analised))
                {
                    CPsPrediction = CPsPredictionNow;
                    break;
                }
            } while (true);

            if (CPsPrediction.Matches == 0)
            {
                return(0);
            }

            double dSimChange = this.Compare(LDSetChange, CPsPrediction.LDChange, position);
            double dSimPeak   = this.Compare(LDSetPeak, CPsPrediction.LDPeak, position);
            double dSimBase   = this.Compare(LDSetBase, CPsPrediction.LDBase, position);
            double dSubSim    = (dSimChange * dSimPeak * dSimBase) / (100 * 100);



            return(dSubSim);
        }