TotalProfit

 

my example 

---------------------------------------------------------------------

void OnTick()

  {

//---

             int Ticket = 99254128;

             double Price;

   //doc Price cua Order 99354218

            if (OrderSelect(Ticket,SELECT_BY_TICKET,MODE_TRADES))

   {

             Price = OrderOpenPrice();

             Comment("a total ordre "  + (string)Ticket + " = " + (string)Price);

   }

   // tinh tong proift cua cac order 

             double TotalProfit = 0.0;

             int TotalOrders = OrdersHistoryTotal();

             for (int i = 0 ; i < TotalOrders ;i ++)

   {

             if (OrderSelect(i,SELECT_BY_TICKET,MODE_TRADES) )

   {

            TotalProfit += OrderProfit();

   

   }

   }

   //comment

           Comment ("a total profit = " + (string)TotalProfit);

    //------------------------------------------------------------------------------------------

 

help me do it 

01/ the number of each type of orders 

02/ the total swap of all types of market orders

thanks 

Files:
 

Just look into the mql4 reference: top line of the index tab just enter "Order" and you can see all order entries.

There you find OrderType and OrderSwap...

 
             double TotalProfit = 0.0;

             int TotalOrders = OrdersHistoryTotal();    //This is the number of CLOSED trades

             for (int i = 0 ; i < TotalOrders ;i ++)

   {

             if (OrderSelect(i,SELECT_BY_TICKET,MODE_TRADES) )    //You cannot use SELECT_BY_TICKET for index numbers only actual
                                                                  //ticket numbers
                                                                  //MODE_TRADES checks OPEN trades
   {

            TotalProfit += OrderProfit();
 
I do not check the market 
today 
 
GumRai:
 //MODE_TRADES checks OPEN trades
If you select by ticket number, mode is ignored. Selects open and closed tickets.
 
thanks you
 
gooly:

Just look into the mql4 reference: top line of the index tab just enter "Order" and you can see all order entries.

There you find OrderType and OrderSwap...

I do not know the specific 

 

 OrderType and OrderSwap...

on the order of a few lines of my
 
meta4:

I do not know the specific 

 

 OrderType and OrderSwap...

on the order of a few lines of my
All you need you can read in the reference: Editor->Help->MQL4 Reference -> (tab) Index -> enter Order (or e.g. OrderSwap) Enter.
 

demo photos you please help me 

thanks 

 
gooly:
All you need you can read in the reference: Editor->Help->MQL4 Reference -> (tab) Index -> enter Order (or e.g. OrderSwap) Enter.

I can not apply 

 OrderType

 int order_type;

  if(OrderSelect(12, SELECT_BY_POS)==true)
    {
     order_type=OrderType();
     // ...
    }
  else
    Print("OrderSelect() returned error - ",GetLastError());

 

and OrderSwap... 

 if(OrderSelect(order_id, SELECT_BY_TICKET)==true)

    Print("Swap for the order #", order_id, " ",OrderSwap());
  else
    Print("OrderSelect failed error code is",GetLastError());

 

on MT4

Build 735

 

 

 

 
meta4:

I can not apply 

 OrderType

 int order_type;

  if(OrderSelect(12, SELECT_BY_POS)==true)
    {
     order_type=OrderType();
     // ...
    }
  else
    Print("OrderSelect() returned error - ",GetLastError());

 

and OrderSwap... 

 if(OrderSelect(order_id, SELECT_BY_TICKET)==true)

    Print("Swap for the order #", order_id, " ",OrderSwap());
  else
    Print("OrderSelect failed error code is",GetLastError());

 

on MT4

Build 735

 

 

 

Files:
orderswap.mq4  2 kb
Reason: