Order History

 

Hello, i try to get out the pips of the closed trades, i had the idea, to count the difference between order openprice and orderclose preise

 

void OnTick()
  {


  
   double Profit_Buy;
   double Profit_Sell;
   double Profit;
// retrieving info from trade history 


   for(i=0;i<OrdersHistoryTotal();i++)
     {
        Select = OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
        if(OrderSymbol() ==_Symbol)
        {
         Profit = OrderOpenPrice()-OrderClosePrice();
         if (OrderType() == OP_BUY ) Profit ++;
         if (OrderType() == OP_SELL) Profit ++;

    
        }
}

Print(Profit);


  }  

 

can someone tell me, why this isnt working?

 

amando 

 
amando:

Hello, i try to get out the pips of the closed trades, i had the idea, to count the difference between order openprice and orderclose preise

 

 

can someone tell me, why this isnt working?

 

amando 

void OnTick()
  {


  
   double Profit_Buy;
   double Profit_Sell;
   double Profit;
// retrieving info from trade history 


   for(i=0;i<OrdersHistoryTotal();i++)
     {
        Select = OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
        if(OrderSymbol() ==_Symbol)
        {
         Profit = Profit + OrderOpenPrice()-OrderClosePrice();
         if (OrderType() == OP_BUY ) Profit ++;
         if (OrderType() == OP_SELL) Profit ++;

    
        }
}

Print(Profit);


  }  
 

Thats all? Shame on my head,

in this case, then this must also work right?

 

 

void OnTick()
  {


  
   double Profit_Buy;
   double Profit_Sell;
   double Profit;
// retrieving info from trade history 


   for(i=0;i<OrdersHistoryTotal();i++)
     {
        Select = OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
        if(OrderSymbol() ==_Symbol)
        {
         //Profit = Profit + OrderOpenPrice()-OrderClosePrice();
         if (OrderType() == OP_BUY ) Profit_Buy = Profit_Buy + OrderClosePrice()-OrderOpenPrice();
         if (OrderType() == OP_SELL) Profit_Sell = Profit_Sell + OrderOpenPrice() - OrderClosePrice();

    
        }
}

   Print(Profit_Buy);
   Print(Profit_Sell);


  }  
 
https://www.mql5.com/en/forum/91432/page2#comment_2662036
!!! Helping for free by coding of simple mql4(5) task.
!!! Helping for free by coding of simple mql4(5) task.
  • reviews: 17
  • www.mql5.com
You can write tasks here. Screenshots with examples of what do you want are obligated...
 

Thanks for help, both is working,

 

i have another question to this, how i insert de actual day? means to collect the pips from today (servertime)

 
amando:

Thanks for help, both is working,

 

i have another question to this, how i insert de actual day? means to collect the pips from today (servertime)

 

for(i=OrdersHistoryTotal();i>=0;i--) 

     { 

if(OrderCloseTime()<iTime(Symbol(),PERIOD_D1,0)) break; 

 

no, i tryed this and get no result

 

void OnTick()
  {


  
   double Profit_Buy;
   double Profit_Sell;
// retrieving info from trade history 


   for(i=OrdersHistoryTotal();i>=0;i--) 
     {
         if(OrderCloseTime()<iTime(Symbol(),PERIOD_D1,0)) break; 
        Select = OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
        if(OrderSymbol() ==_Symbol  )
        {
       
         if (OrderType() == OP_BUY ) Profit_Buy = Profit_Buy + OrderClosePrice()-OrderOpenPrice();
         if (OrderType() == OP_SELL) Profit_Sell = Profit_Sell + OrderOpenPrice() - OrderClosePrice();

    
        }
}

   Print(Profit_Buy);
   Print(Profit_Sell);

  }  
 
amando:

no, i tryed this and get no result

 

      switch(TimeDayOfWeek(TimeCurrent()))
        {
         case 0:// Sunday

            break;

         case 1:// Monday

            break;

         case 2:// Tuesday

            break;

         case 3:// Wednesday

            break;

         case 4:// Thursday

            break;

         case 5:// Friday

            break;

         case 6:// Saturday

            break;
        }

Please be clear about what you want to do.

Pips from each order? pips from all orders? pips from buy orders today? pips from sell orders today? pips from buy and sell orders today? pips from order or orders yesterday?

Be specific.

 
amando:

no, i tryed this and get no result

 

And what "no" resoult do you have?
 

its just 0

 

Profit_buy = 0

Profit_Sell = 0

 
amando:

its just 0

 

Profit_buy = 0

Profit_Sell = 0

:))))

        Select = OrderSelect(i,SELECT_BY_POS,MODE_HISTORY);
        if(OrderSymbol() ==_Symbol  )
        {
if(OrderCloseTime()<iTime(Symbol(),PERIOD_D1,0)) break; 

    

Reason: