How to check number of trades taken on current hour?

Back to topics list To post a new topic, please log in or register
avatar
157
cashcube 2016.06.02 12:09
 

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

 

 

avatar
Moderator
3408
GumRai 2016.06.02 12:25 #
 
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);

  }
avatar
Moderator
3408
GumRai 2016.06.02 12:27 #
 

You will also have to count the open orders


avatar
157
cashcube 2016.06.03 06:09 #
 
GumRai:

You will also have to count the open orders


How can I count the open orders then is there any example code structure?
avatar
1208
FMIC 2016.06.03 07:03 #
 
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.

avatar
157
cashcube 2016.06.03 13:21 #
 
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.

 

 

 

Back to topics list  

To add comments, please log in or register