コード例 #1
0
        public void TradingLib_HistoricalTrade_HistoricalTradeTest2()
        {
            HistoricalTrade HT = new HistoricalTrade(1000, 1000000, -147.147, 999); // Creates new HistoricalTrade object with negative value

            Assert.AreEqual(HT.Amount, 147.147);                                    // Check the value is inserted as a positive
            Assert.IsTrue(!HT.IsBid);                                               // Check IsBid is false
        }
コード例 #2
0
ファイル: OKBOT.cs プロジェクト: sepanta1990/ctraderokbot
        private int getCoeficient(Symbol symbol)
        {
            var historyList = new List <HistoricalTrade>();

            foreach (HistoricalTrade trade in History)
            {
                if (string.Equals(symbol.Name, trade.SymbolName))
                {
                    historyList.Add(trade);
                }
            }

            double loss      = 0;
            int    averageTP = 25;

            if (symbol.Name.Equals("XAUUSD"))
            {
                averageTP = 500;
            }

            for (int i = historyList.Count - 1; i >= 0; i--)
            {
                HistoricalTrade trade = historyList[i];

                if (trade.GrossProfit < 0)
                {
                    loss += trade.GrossProfit;
                }
                else
                {
                    break;
                }
            }


            loss = Math.Abs(loss);


            int coef = (int)Math.Ceiling(loss / (averageTP * 1000 * symbol.PipValue));

            if (symbol.Name.Equals("XAUUSD"))
            {
                coef = (int)Math.Ceiling(loss / (averageTP * symbol.PipValue));
            }


            if (coef <= 1)
            {
                return(1);
            }
            if (coef >= 12)
            {
                return(12);
            }

            return(coef);
        }
コード例 #3
0
        public override void Parse(XmlDocument doc)
        {
            base.Parse(doc);

            this.systemid = doc.ReadString("c2xml/systemid");
            this.systemname = doc.ReadString("c2xml/systemname");

            List<HistoricalTrade> treades = new List<HistoricalTrade>();

            foreach (XmlNode item in doc.SelectNodes("c2xml/trades/trade"))
            {
                HistoricalTrade trade = new HistoricalTrade();
                trade.Parse(item);
                treades.Add(trade);
            }

            treades.Sort();

            this.Trades = treades.ToArray();
        }
コード例 #4
0
        public override void Parse(XmlDocument doc)
        {
            base.Parse(doc);

            this.systemid   = doc.ReadString("c2xml/systemid");
            this.systemname = doc.ReadString("c2xml/systemname");

            List <HistoricalTrade> treades = new List <HistoricalTrade>();

            foreach (XmlNode item in doc.SelectNodes("c2xml/trades/trade"))
            {
                HistoricalTrade trade = new HistoricalTrade();
                trade.Parse(item);
                treades.Add(trade);
            }

            treades.Sort();

            this.Trades = treades.ToArray();
        }
コード例 #5
0
ファイル: History.cs プロジェクト: paolobriones/Trading
 public void Add(HistoricalTrade trade)
 {
     trades.Add(trade);
 }