Counting buy and sell orders of History and put into comment

To add comments, please log in or register
Raphael Schwietering
9031
Raphael Schwietering  

Hi,

i tried to count buy and sell orders of History of an magic number.

I tried this out but it seems that it is not working well.


int count_order()
  {
   int count=OrdersHistoryTotal();
   for(int i=0;i<count;i++)
     {
      if(OrderSelect(i,SELECT_BY_POS, MODE_HISTORY)==true)
        {
         if(OrderSymbol()==Symbol()&& OrderMagicNumber()==Magic_Number)
           {
            count=count+1;
            //count++;
           }
        }
     }
   return(count);
  }

in the ontick function i add this.

           Comment("Buy Trades: ",count_order());  

It looks like it is counting all of the history. With open and close.

Keith Watford
Moderator
20477
Keith Watford  
int count_order()
  {
   int count=0;
   int total=OrdersHistoryTotal();
   for(int i=0;i<total;i++)
     {
      if(OrderSelect(i,SELECT_BY_POS, MODE_HISTORY)==true)
        {
         if(OrderSymbol()==Symbol()&& OrderMagicNumber()==Magic_Number)
           {
            count++;
           }
        }
     }
   return(count);
  }
Raphael Schwietering
9031
Raphael Schwietering  
Keith Watford:

Now its counting ALL BUY AND SELL. I want only get the BUY Orders and only SELL ORDERS

Keith Watford
Moderator
20477
Keith Watford  
Raphael Schwietering:

Now its counting ALL BUY AND SELL. I want only get the BUY Orders and only SELL ORDERS

Wow! Then add an additional check for either buy or sell orders and count them. Use either Global variables or pass variables to the function.

Raphael Schwietering
9031
Raphael Schwietering  
Keith Watford:

Wow! Then add an additional check for either buy or sell orders and count them. Use either Global variables or pass variables to the function.

thanks now i have working it.

can you help me out how to get the profit of closed trades?i think there must be small changes

To add comments, please log in or register