Download MetaTrader 5
To add comments, please log in or register
Deposit to your account via WebMoney
jtubbs13791
71
jtubbs13791 2014.12.06 15:07 

the function below only calculates the dollar amount of the last open trade. I am looking to calculate the dollar amount of all open trades for the currency the EA is on. I can not find what I am doing wrong. can I get some help? thanks in advance.

double LastBuyProfit()
   {
   for(int iPos=OrdersTotal()-1; iPos>=0; iPos--)
      {//loop end to beginning
      if(OrderSelect(iPos,SELECT_BY_POS,MODE_TRADES)==TRUE)
         {//we found a ticket number
         if(OrderSymbol()==Symbol () &&
            OrderMagicNumber()==MagicNumber &&
            OrderType()==OP_BUY
            )
            {//we found a buy order
            return(OrderProfit()+OrderSwap()+OrderCommission());
            }
         }
      }
   return(0.00);
   }
whroeder1
13641
whroeder1 2014.12.06 15:21  
jtubbs13791: the function below only calculates the dollar amount of the last open trade. I am looking to calculate the dollar amount of all open trades for the currency the EA is on. I can not find what I am doing wrong. can I get some help? thanks in advance.
  1. Don't double post

  2. return(OrderProfit()+OrderSwap()+OrderCommission());
    You are returning the first trade you find. If you want all open trade, sum them and return the sum.
/
To add comments, please log in or register