How to check number of trades taken on current hour?

 

Hi,

How to check number of trades taken on current hour for OP_BUY & OP_SELL.

Including Closed order & open orders?

I got this function code which checks orders are opened under certain time or not. But it doesn't counts how many. 

int FoundRecentOpenedOrder(int TF) {
   int last_order_idx = (OrdersHistoryTotal() - 1);
   if(OrderSelect(last_order_idx,SELECT_BY_POS,MODE_HISTORY))
   {
   if (OrderOpenTime() >= iTime(Symbol(), TF, 1)&& OrderType() == OP_BUY && OrderType()== OP_SELL) {
      return(TRUE);
      }}
      return(FALSE);
      
    }

 Regards

 
OrderType() == OP_BUY && OrderType()== OP_SELL

will never be true

Using 1 as the index in the iTime call will include all orders opened in the previous and current bar


int FoundRecentOpenedOrder(int TF) 
  {
   int count=0;
   int last_order_idx=(OrdersHistoryTotal()-1);
   for(;last_order_idx>=0;last_order_idx--)
      if(OrderSelect(last_order_idx,SELECT_BY_POS,MODE_HISTORY))
        {
         if(OrderOpenTime()>=iTime(Symbol(),TF,1) && (OrderType()==OP_BUY || OrderType()==OP_SELL)) 
           {
            count++;
           }
        }
   return(count);

  }
 

You will also have to count the open orders

 
GumRai:

You will also have to count the open orders


How can I count the open orders then is there any example code structure?
 
cashcube:
How can I count the open orders then is there any example code structure?

"GumRai" has already answered that and even gave you the example code for it!

However, I do have a question for you - do you have any coding experience at all? A "loop" and "counting" is one of the most basic things one has to learn for coding.

If you have no experience in coding or even just a little, then I suggest you first learn some basic skills in common languages like "C", "C++" or even "Java" before you attempt to even code an EA which is highly complex. There are plenty of resources on the Internet to help you out, including many tutorials and videos.

 
FMIC:

"GumRai" has already answered that and even gave you the example code for it!

However, I do have a question for you - do you have any coding experience at all? A "loop" and "counting" is one of the most basic things one has to learn for coding.

If you have no experience in coding or even just a little, then I suggest you first learn some basic skills in common languages like "C", "C++" or even "Java" before you attempt to even code an EA which is highly complex. There are plenty of resources on the Internet to help you out, including many tutorials and videos.

Pardon please,

I missed the coding post. That's why this misunderstanding.

Thank you both of you. Its working now. 

PS: I posted the base code. I know C, C++, but yes loop advise excepted.

Reason: