Esempio n. 1
0
 private void button3_Click(object sender, EventArgs e)
 {
     //buy
     if (mytrade.direction != -1 && my_instrument_data.candle_series.Count > 0 && cd != null)
     {
         //mytrade = new trade_single();
         //mytrade.str_instrumentid = my_instrument_data.instrument_name;
         //mytrade.direction = 1;
         //mytrade.dt = cd.dt;
         //mytrade.open_price = cd.close;
         //mytrade.lots = 1;
         mytrade.direction = 1;
         trade_single ts = new trade_single();
         ts.str_instrumentid = my_instrument_data.instrument_name;
         ts.direction        = 1;
         ts.dt         = cd.dt;
         ts.open_price = cd.close;
         ts.lots       = mytrade.get_lots();
         mytrade.trades.Add(ts);
         chart1.Series["price"].Points[pos].Label = "^";
         tool_status.Text = "多头仓位!" + mytrade.t_lots;
     }
     else
     {
         //tool_status.Text = "请先平仓!";
     }
 }
Esempio n. 2
0
        public void addnewtrade(trade_single mytrade)
        {
            if (mytrade != null)
            {
                double profit = (mytrade.close_price - mytrade.open_price) * mytrade.direction * mytrade.lots;
                if (profit > 0)
                {
                    winfunds += profit;
                    wins     += mytrade.lots;
                }
                else
                {
                    losefunds += profit;
                    loses     += mytrade.lots;
                }

                totalfunds += profit;
                totaltrades++;
                //wins += (mytrade.close_price - mytrade.open_price) * mytrade.direction > 0 ? 1 : 0;
                trades.Add(mytrade);
            }
        }