示例#1
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();
        }
示例#2
0
        private void TimrControls_Tick(object sender, EventArgs e)
        {
            int InLbxPairs = LbxCCYPairs.Items.Count;
            int InLbxDeals = LbxDealsOpened.Items.Count;

            List <Rates> LRATES  = ORBlotter.GetData;
            List <Deals> LDEALS  = ODBlotter.GetData;
            int          LRCount = LRATES.Count;


            if (InLbxPairs < LRCount)
            {
                if (InLbxPairs > 0)
                {
                    LbxCCYPairs.Items.Clear();
                }


                for (int i = 0; i < LRCount; i++)
                {
                    LbxCCYPairs.Items.Add(LRATES[i].CCY_Pair);
                }
            }

            if (LbxDealsOpened.SelectedIndex >= 0)
            {
                Deals DEAL = ODBlotter.Get(LbxDealsOpened.SelectedItem.ToString());

                TbxDealPair.Text = DEAL.PRODUCT;

                if (DEAL.BUY)
                {
                    TbxDealKind.Text = "BUY ";
                }
                else
                {
                    TbxDealKind.Text = "SELL";
                }

                TbxDealProfitOrLoss.Text = AUTOTREADER.ConvertToUSD(DEAL.PRODUCT, DEAL.BUY, ACCOUNT.CalculateProfitOrLoss(DEAL, ORBlotter.Get(DEAL.PRODUCT))) + "";

                ChartPointPredition CPP = AUTOTREADER.TryGet(DEAL.PRODUCT, TimeFrame.ONE_MINUTE);


                if (CPP == null || CPP.Type == ChartPointPredition.Kind.Uncertain || !CPP.IsActual)
                {
                    TbxDealPredictionKind.Text       = "Uncertain";
                    TbxDealPredictionPercentage.Text = "";
                    TbxDealPredictionValue.Text      = "";
                }
                else
                {
                    if (CPP.Type == ChartPointPredition.Kind.Average)
                    {
                        TbxDealPredictionKind.Text = "Average";
                    }
                    else if (CPP.Type == ChartPointPredition.Kind.Down)
                    {
                        TbxDealPredictionKind.Text = "Down";
                    }
                    else if (CPP.Type == ChartPointPredition.Kind.Up)
                    {
                        TbxDealPredictionKind.Text = "Up";
                    }

                    TbxDealPredictionPercentage.Text = Math.Round(CPP.Propability, 2).ToString();
                    TbxDealPredictionValue.Text      = Math.Round(CPP.Change, 5).ToString();
                }
            }



            if (this.IsConnected())
            {
                this.UpdateMargin();
                this.UpdateAction();
            }

            if (!OSBlotter.IsLoaded)
            {
                BtnAutoTrader.Enabled = false;
                BtnBuy.Enabled        = false;
                BtnClose.Enabled      = false;
                BtnSell.Enabled       = false;
            }
            else
            {
                BtnAutoTrader.Enabled = true;
                BtnBuy.Enabled        = true;
                BtnClose.Enabled      = true;
                BtnSell.Enabled       = true;
            }
        }
示例#3
0
        private void TimrAutoTraderSquare_Tick(object sender, EventArgs e)
        {
            if (ODBlotter.COUNT == 0)
            {
                return;
            }
            else
            {
                TimeFrame    TFrame = TimeFrame.ONE_MINUTE;
                List <Deals> LDeals = ODBlotter.GetData.ToList();

                for (int i = 0; i < LDeals.Count; i++)
                {
                    Deals  DEAL    = LDeals[i];
                    string product = DEAL.PRODUCT;
                    List <ChartPointsPredition> LCPsPSimulated = this.LCPsPTestSelected.OrderByDescending(CPsP => CPsP.Resolution).ToList();
                    ChartPointsPredition        CPsPrediction  = null;
                    List <Rates> LRAll = ORBlotter.Archive.TryGet(product);

                    for (int i2 = 0; i2 < LCPsPSimulated.Count; i2++)
                    {
                        if (LCPsPSimulated[i2].Product == product)
                        {
                            CPsPrediction = LCPsPSimulated[i2];
                            break;
                        }
                    }



                    double dMinDeal = 0, dMaxDeal = 0;
                    if (!this.Extrema(DEAL, 10, ref dMinDeal, ref dMaxDeal))
                    {
                        return;
                    }

                    bool   bBUY                 = DEAL.BUY;
                    Rates  RATE                 = ORBlotter.Get(DEAL.PRODUCT);
                    double onePip               = Math.Pow(10, -RATE.Decimals);
                    int    iSpread              = ANALYSIS.SpreadPips(DEAL, RATE.Decimals, true) + 2;
                    double dLevel               = (double)iSpread;
                    bool   bLooseWarning        = false;
                    double dGainLoosePercentage = 75;
                    double dStartSpread         = (double)(DEAL.ASK - DEAL.BID) / onePip;

                    if (CPsPrediction != null && CPsPrediction.IsActual)
                    {
                        if ((bBUY && CPsPrediction.Type == ChartPointsPredition.Kind.Down) ||
                            (!bBUY && CPsPrediction.Type == ChartPointsPredition.Kind.Up))
                        {
                            DEAL.LooseWaring     = true;
                            dGainLoosePercentage = 85;
                        }
                        else if ((!bBUY && CPsPrediction.Type == ChartPointsPredition.Kind.Down) ||
                                 (bBUY && CPsPrediction.Type == ChartPointsPredition.Kind.Up))
                        {
                            dGainLoosePercentage = 60;
                        }
                    }

                    if (bBUY)
                    {
                        double dPLMax = (double)(dMaxDeal - DEAL.ASK) / onePip;
                        double dPLNow = (double)(RATE.BID - DEAL.ASK) / onePip;



                        if (dPLMax > 0 && dPLNow > 0)
                        {
                            double dGainPercentage = ((double)(dPLNow + dStartSpread) / (dPLMax + dStartSpread)) * 100;

                            if (dGainPercentage < dGainLoosePercentage || DEAL.LooseWaring)
                            {
                                bLooseWarning = true;
                            }
                        }
                    }
                    else//sell for bid, buy for ask
                    {
                        double dPLMin = (double)(DEAL.BID - dMinDeal) / onePip;
                        double dPLNow = (double)(DEAL.BID - RATE.ASK) / onePip;


                        if (dPLMin > 0 && dPLNow > 0)
                        {
                            double dGainPercentage = ((double)(dPLNow + dStartSpread) / (dPLMin + dStartSpread)) * 100;

                            if (dGainPercentage < dGainLoosePercentage || DEAL.LooseWaring)
                            {
                                bLooseWarning = true;
                            }
                        }
                    }

                    if (bLooseWarning)
                    {
                        this.CloseDeal(DEAL);
                        Thread ThrdBeep = new Thread(delegate() { Console.Beep(200, 50); Console.Beep(200, 50); }); ThrdBeep.Start();
                    }
                    return;
                }
            }
        }