예제 #1
0
            public static List <CompletedTrade> ApplyRegressionFilter(int N, List <Trade> Trades)
            {
                var CloseTradesOnly = Statistics.RegressionAnalysis_OnPL(N, Trades);
                var CompTrades      = Trade.TradesOnly(Trades);
                var CompleteList    = CompletedTrade.CreateList(CompTrades);

                for (int x = 2; x < CompleteList.Count; x++)
                {
                    if (CompleteList[x - 2].CloseTrade.Extention.Slope < CompleteList[x - 1].CloseTrade.Extention.Slope &&
                        CompleteList[x - 1].CloseTrade.Extention.Slope < 0)
                    {
                        CompleteList[x].OpenTrade.Extention.OrderVol = 2;
                    }
                }
                foreach (var t in CompleteList)
                {
                    if (t.OpenTrade.Extention.OrderVol == 2)
                    {
                        t.CloseTrade.Extention.OrderVol = 2;
                    }
                    else
                    {
                        t.CloseTrade.Extention.OrderVol = 1;
                        t.OpenTrade.Extention.OrderVol  = 1;
                    }
                }

                return(CompleteList);
            }
예제 #2
0
        private void TradeToCandle()
        {
            //Laptop
            // string css = @"Data Source=ALSI-PC\;Initial Catalog=AlsiTrade;Integrated Security=True";
            //PC
            string css = @"Data Source=PIETER-PC\;Initial Catalog=AlsiTrade;Integrated Security=True";

            AlsiUtils.Data_Objects.GlobalObjects.CustomConnectionString = css;



            //  DateTime s = new DateTime(2006, 01, 01);
            //  DateTime e = new DateTime(2006, 12, 15);

            DateTime s = new DateTime(2012, 1, 1);
            DateTime e = new DateTime(2013, 12, 29);


            var prices = AlsiUtils.DataBase.readDataFromDataBase(GlobalObjects.TimeInterval.Minute_5, AlsiUtils.DataBase.dataTable.MasterMinute,
                                                                 s, e, false);

            Debug.WriteLine("Start Date " + prices[0].TimeStamp);

            //for (int x = 2; x < 50; x++)
            //{

            AlsiUtils.Strategies.Parameter_EMA_Scalp E = new AlsiUtils.Strategies.Parameter_EMA_Scalp()
            {
                A_EMA1        = 16,
                A_EMA2        = 17,
                B_EMA1        = 43,
                B_EMA2        = 45,
                C_EMA         = 52,
                TakeProfit    = 450,
                StopLoss      = -300,
                CloseEndofDay = false,
                Period        = prices.Count,
            };
            //  takep = E.TakeProfit;
            // takel = E.StopLoss;
            AlsiUtils.Statistics S = new AlsiUtils.Statistics();
            S.OnStatsCaculated += new AlsiUtils.Statistics.StatsCalculated(S_OnStatsCaculated);
            var Trades = AlsiUtils.Strategies.EMA_Scalp.EmaScalp(E, prices, false);

            Trades = S.CalcBasicTradeStats_old(Trades);

            var rr = Statistics.IntratradeToCandle(Trades);
            var RR = CompletedTrade.CreateList(rr);



            PrintTradesonly(RR);
        }
예제 #3
0
        private void start()
        {
            Cursor = Cursors.WaitCursor;
            GlobalObjects.TimeInterval t  = GlobalObjects.TimeInterval.Minute_5;
            DataBase.dataTable         dt = DataBase.dataTable.MasterMinute;
            //_FullTradeList = AlsiTrade_Backend.RunCalcs.RunEMAScalp(GetParametersSAR_EMA(), t, false, new DateTime(2012, 01, 01), new DateTime(2014, 01, 01), dt);
            _FullTradeList = AlsiTrade_Backend.RunCalcs.RunMAMAScalp(GetParametersMAMA(), t, false, new DateTime(2005, 01, 01), new DateTime(2014, 12, 31), dt);
            _FullTradeList = _Stats.CalcBasicTradeStats_old(_FullTradeList);
            NewTrades      = AlsiUtils.Strategies.TradeStrategy.Expansion.ApplyRegressionFilter(11, _FullTradeList);
            NewTrades      = _Stats.CalcExpandedTradeStats(NewTrades);
            _TradeOnlyList = CompletedTrade.CreateList(NewTrades);

            Cursor = Cursors.Default;
        }
예제 #4
0
 public async Task <IHttpActionResult> Put(CompletedTrade trade)
 {
     return(await DocumentDBRepository <CompletedTrade> .Update(trade));
 }
예제 #5
0
        private double AddTradeslayer()
        {
            var PM = GetParametersMAMA();

            _FullTradeList = AlsiUtils.Strategies.MAMA_Scalp.MAMAScalp(PM, GlobalObjects.Points, false);
            _FullTradeList = _Stats.CalcBasicTradeStats_old(_FullTradeList);
            NewTrades      = TradeStrategy.Expansion.ApplyRegressionFilter(11, _FullTradeList);
            NewTrades      = _Stats.CalcExpandedTradeStats(NewTrades);
            _TradeOnlyList = CompletedTrade.CreateList(NewTrades);



            int C = NewTrades.Count;

            for (int i = 1; i < C; i++)
            {
                var pl = from x in _FullTradeList
                         where x.TimeStamp >= NewTrades[i].OpenTrade.TimeStamp && x.TimeStamp <= NewTrades[i].CloseTrade.TimeStamp
                         select x;

                double volume    = 0;
                double volProfit = 0;
                var    PL        = pl.ToList();

                foreach (var q in PL)
                {
                    bool tookprofit = false;
                    volume = PL[0].TradeVolume;
                    TRADETRIGGER_DIC.TryGetValue(q.TimeStamp, out tookprofit);

                    if (q.Reason == Trade.Trigger.None && !tookprofit)
                    {
                        volProfit = volume * q.RunningProfit;
                    }
                    else
                    {
                        volProfit = q.RunningProfit;
                    }


                    PROF_DIC.Add(q.TimeStamp, volProfit);
                    NOTE1_DIC.Add(q.TimeStamp, q.Reason.ToString());
                    VOL_DIC.Add(q.TimeStamp, volume);
                    if (tookprofit)
                    {
                        TOTALPROFIT += volProfit;
                        break;
                    }
                    else
                    if (q.Reason == Trade.Trigger.CloseLong || q.Reason == Trade.Trigger.CloseShort)
                    {
                        TOTALPROFIT += PL.Last().RunningProfit;
                    }
                }

                var R = RSICC.Where(x => x.Stamp >= PL[0].TimeStamp && x.Stamp <= PL[PL.Count - 1].TimeStamp);
                foreach (var t in R)
                {
                    double r    = 0;
                    double v    = 0;
                    string note = "";
                    PROF_DIC.TryGetValue(t.Stamp, out r);
                    NOTE1_DIC.TryGetValue(t.Stamp, out note);
                    VOL_DIC.TryGetValue(t.Stamp, out v);
                    t.Runningprofit = r;
                    t.Note1         = note;
                    t.Volume        = v;
                }



                //End loop
            }
            return(TOTALPROFIT);
        }