Download MetaTrader 5

TotalProfit

To add comments, please log in or register
Have you found a good programmer? Make a targeted order!
meta44
48
meta44 2014.10.17 05:37 

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:
Carl Schreiber
6580
Carl Schreiber 2014.10.17 06:29  

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...

Keith Watford
Moderator
9603
Keith Watford 2014.10.17 07:15  
             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();
meta44
48
meta44 2014.10.18 16:12  
I do not check the market 
today 
whroeder1
14470
whroeder1 2014.10.18 17:35  
GumRai:
 //MODE_TRADES checks OPEN trades
If you select by ticket number, mode is ignored. Selects open and closed tickets.
meta44
48
meta44 2014.10.21 16:27  
thanks you
meta44
48
meta44 2014.10.22 04:30  
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
Carl Schreiber
6580
Carl Schreiber 2014.10.22 07:35  
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.
meta44
48
meta44 2014.10.23 02:07  

demo photos you please help me 

thanks 

meta44
48
meta44 2014.10.29 14:50  
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

 

 

 

meta44
48
meta44 2014.10.29 14:53  
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:
12
To add comments, please log in or register