Is it possible to create an EA/script to calculate total lot size for a specific price point?

 

Hey guys

this is what I am trying to achieve-

I want an indicator/EA/script that will give me the total lot size of each type of order at a given price point. For example if I type in price 1.3425 it should give me 4 results-

1.total lot size for pending buy orders,

2.total lot size for pending sell orders,

3.total lot size for active buy orders

4. total lot size for active sell orders

for that specific entry price. Important to note that there might be more than 1 order for each type. So it has to add the different lot sizes to give me the total.

For example, I might have 3 pending buy orders at that entry price with lot size .01, .05 and .09. I want it to give me the sum of that as 1.5 which is the total lot size used. Same for the other 3 kind of orders.

I would appreciate some expert opinion if this can be done at all. I wanted to hear from you guys before posting in the freelance section.


If you know of something off the shelf (mql5 marketplace) that will do this you can tell me in private.

Thanks guys for your time

Tk

 
tagifts5:

Hey guys

this is what I am trying to achieve-

I want an indicator/EA/script that will give me the total lot size of each type of order at a given price point. For example if I type in price 1.3425 it should give me 4 results-

1.total lot size for pending buy orders,

2.total lot size for pending sell orders,

3.total lot size for active buy orders

4. total lot size for active sell orders

for that specific entry price. Important to note that there might be more than 1 order for each type. So it has to add the different lot sizes to give me the total.

For example, I might have 3 pending buy orders at that entry price with lot size .01, .05 and .09. I want it to give me the sum of that as 1.5 which is the total lot size used. Same for the other 3 kind of orders.

for mt4, explicitly double value price.

void CountLot(double pPrice, double& activeBuy, double& activeSell, double& pendingBuy, double& pendingSell){
   activeBuy = 0;
   activeSell = 0;
   pendingBuy = 0;
   pendingSell = 0;
   for(int order = OrdersTotal()-1; order >= 0; order--){
      if(OrderSelect(order,SELECT_BY_POS) && OrderSymbol()==_Symbol && OrderOpenPrice()==pPrice) {
         if(OrderType()==OP_BUY) activeBuy += OrderLots();
         else if(OrderType()==OP_BUYLIMIT) pendingBuy += OrderLots();
         else if(OrderType()==OP_BUYSTOP) pendingBuy += OrderLots();
         else if(OrderType()==OP_SELL) activeSell += OrderLots();
         else if(OrderType()==OP_SELLLIMIT) pendingSell += OrderLots();
         else if(OrderType()==OP_SELLSTOP) pendingSell += OrderLots();
      }
   }
}
 
You may want to add a margin so that it counts orders within 1 pip or 1 point of each other
 
Mohamad Zulhairi Baba:

for mt4, explicitly double value price.

Thank you so much for your time and effort. I will definitely look into it and try to make sense of it.

In the meantime someone told me searching like this is risky, but didn't mention what kind risk involved? Does anyone else knowif searching like this could cause any problems?

Thanks guys I appreciate all of your time.

 
tagifts5:

Thank you so much for your time and effort. I will definitely look into it and try to make sense of it.

In the meantime someone told me searching like this is risky, but didn't mention what kind risk involved? Does anyone else knowif searching like this could cause any problems?

Thanks guys I appreciate all of your time.

don't know what kind of risky term someone told you.
as @Keith Watford mention, you need to add some margin in search value, as my code search for exact value.

 
Mohamad Zulhairi Baba:

don't know what kind of risky term someone told you.
as @Keith Watford mention, you need to add some margin in search value, as my code search for exact value.

Thanks again Mohamad you guys have been really helpful.
 
Also sending you a pm Mohamad, hope that is ok.