int OpenSellOrders(double Level) { int sellorders=0; int selllimit=0; int sellstop=0; int totalsell=0; NormalizeDouble(Level,_Digits-1); for (int i=0; i<OrdersTotal(); i++) { if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) if(NormalizeDouble(OrderOpenPrice(),_Digits-1) == Level) { if(OrderType() == OP_SELL) sellorders++; if(OrderType() == OP_SELLLIMIT) selllimit++; if(OrderType() == OP_SELLSTOP) sellstop++; } totalsell = sellorders+selllimit+sellstop; } return(totalsell); }
pipPod:
Thanks a ton pipPod!!! I've been banging my head over this for past two days... this is finally working for me now!!!
itzmyself:
Thanks a ton pipPod!!! I've been banging my head over this for past two days... this is finally working for me now!!!
You're welcome.
Thanks a ton pipPod!!! I've been banging my head over this for past two days... this is finally working for me now!!!
You can convet it to MQL5? I Test but error. Please.
int OpenSellOrders(double Level) { int sellorders=0; int selllimit=0; int sellstop=0; int totalsell=0; NormalizeDouble(Level,_Digits-1); for (int i=0; i<OrdersTotal(); i++) { long OrderType = OrderGetInteger(ORDER_TYPE); if (OrderSelect(OrderGetTicket(i))) if(NormalizeDouble(ORDER_PRICE_OPEN,_Digits-1) == Level) { if(OrderType == ORDER_TYPE_SELL) sellorders++; if(OrderType == ORDER_TYPE_SELL_LIMIT) selllimit++; if(OrderType == ORDER_TYPE_SELL_STOP) sellstop++; } totalsell = sellorders+selllimit+sellstop; } Print(Level,"price",totalsell); return(totalsell); }
Ernst Van Der Merwe #:
You're welcome.
You're welcome.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
I am trying to get a total count of buy (open buy + buylimit + buystop) and sell (open sell + selllimit + sellstop) orders at a particular price level.
The following function code seems to get the count correctly in some instances but shows a zero count in other cases. I am not able to figure out what is causing the issue!
int OpenBuyOrders(double Level)
{
int buyorders=0;
int buylimit=0;
int buystop=0;
int totalbuy=0;
for (int i=0; i<OrdersTotal(); i++)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
if(OrderOpenPrice() == Level)
{
if(OrderType() == OP_BUY) buyorders++;
if(OrderType() == OP_BUYLIMIT) buylimit++;
if(OrderType() == OP_BUYSTOP) buystop++;
}
totalbuy= buyorders+buylimit+buystop;
}
return(totalbuy);
}
int OpenSellOrders(double Level)
{
int sellorders=0;
int selllimit=0;
int sellstop=0;
int totalsell=0;
for (int i=0; i<OrdersTotal(); i++)
{
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
if(OrderOpenPrice() == Level)
{
if(OrderType() == OP_SELL) sellorders++;
if(OrderType() == OP_SELLLIMIT) selllimit++;
if(OrderType() == OP_SELLSTOP) sellstop++;
}
totalsell = sellorders+selllimit+sellstop;
}
return(totalsell);
}