Exemplo n.º 1
0
 public void Update(Account account, double tradingRatio, TradingStatistics tradingStatistics, DateTime serverTime)
 {
     try {
         TradingAccountModel accountRow = this;
         accountRow.Balance            = account.Balance;
         accountRow.Equity             = account.Equity;
         accountRow.Hedging            = account.Hedging;
         accountRow.DayPL              = account.DayPL;
         accountRow.ID                 = account.ID;
         accountRow.IsMarginCall       = account.IsMarginCall;
         accountRow.PipsToMC           = account.PipsToMC;
         accountRow.UsableMargin       = account.UsableMargin;
         accountRow.Trades             = account.Trades;
         accountRow.TradingRatio       = tradingRatio;
         accountRow.ServerTime         = serverTime;
         accountRow.StopAmount         = account.StopAmount;
         accountRow.LimitAmount        = account.LimitAmount;
         accountRow.TradingStatistics  = tradingStatistics;
         accountRow.TakeProfit         = tradingStatistics.TakeProfitDistanceInPips;
         accountRow.CurrentGrossInPips = tradingStatistics.CurrentGrossInPips;
         accountRow.CurrentGross       = tradingStatistics.CurrentGross;
         if (accountRow.CurrentGrossInPips >= GrossToExitInPips)
         {
             RaiseCloseAllTrades();
             GrossToExitInPips = null;
         }
         if (accountRow.PL >= accountRow.TakeProfit)
         {
             RaiseCloseAllTrades();
             PipsToExit = null;
         }
         if (DayTakeProfit.HasValue && account.DayPL >= DayTakeProfit)
         {
             RaiseCloseAllTrades();
             DayTakeProfit = DayTakeProfit > 0 ? DayTakeProfit * 2 : null;
         }
         accountRow.OnPropertyChanged(
             () => accountRow.Balance,
             () => accountRow.Equity,
             () => accountRow.DayPL,
             () => accountRow.Hedging,
             () => accountRow.ID,
             () => accountRow.IsMarginCall,
             () => accountRow.PipsToMC,
             () => accountRow.PL,
             () => accountRow.Net,
             () => accountRow.UsableMargin,
             () => accountRow.Trades,
             () => accountRow.HasProfit,
             () => accountRow.TradingRatio,
             () => accountRow.StopAmount,
             () => accountRow.BalanceOnStop,
             () => accountRow.LimitAmount,
             () => accountRow.BalanceOnLimit,
             () => accountRow.StopToBalanceRatio,
             () => accountRow.ProfitPercent,
             () => accountRow.ServerTime,
             () => accountRow.OriginalBalance,
             () => accountRow.OriginalProfit
             );
         //if (OriginalProfit >= .001) RaiseCloseAllTrades();
     } catch (Exception exc) {
         Log = exc;
     }
 }
Exemplo n.º 2
0
 public TradingStatisticsEventArgs(TradingStatistics tradingStatistics = null)
 {
     this.TradingStatistics = tradingStatistics;
 }