Download MetaTrader 5
To add comments, please log in or register
Code Base will help you in mastering your theoretical skills. Come and learn!
giulio
138
giulio 2010.04.12 22:40 

hi guys only an advice: i need to check the number of pending order ( for the currency and for the type of order )

i have tried in this way:


for (int i=0; i<ordertotal() ;i++)
orderselect(i,select by pos);
if(ordersymbol()==symbol() and ordertype==op_sell )
x++
break


if x=0 ===>>>> no orders for this currency and this type order


but it doesnt go. if i use total=ordertotal () i can check only the number of pending orders while i need to check that there is only one order type BUY for EUR USD . have u some suggestion??

FARHANG
141
FARHANG 2010.04.12 22:53  
int NOofBuy=0;
for(int i= OrdersTotal() - 1; i>=0; i--)       
{
    if(OrderSelect(i,SELECT_BY_POS)==true)
    {
   int Tip=OrderType();                
   if (Tip==0)
     {
   NOofBuy++;
         if (NOofBuy>1)
         {
         Alert("more than one buy orders open);
         break;
         }
     }
   }
}
Alexander
2441
Alexander 2010.04.12 23:42  
int x;
for (int i=0; i<OrdersTotal() ;i++)
{
OrderSelect(i,SELECT_BY_POS);
if(OrderSymbol()==Symbol() && OrderType==OP_SELL )
x++;
}
Just a little correction.
gordon
2322
gordon 2010.04.13 02:41  
giulioron:

... i need to check the number of pending order ...

For pending orders u need to check that OrderType() is one of the following:

OP_BUYLIMIT2Buy limit pending position.
OP_SELLLIMIT3Sell limit pending position.
OP_BUYSTOP4Buy stop pending position.
OP_SELLSTOP5Sell stop pending position.
giulio
138
giulio 2010.04.13 10:12  

first at all, thanks for support

roger, for example, with your suggestion

int x;
for (int i=0; i<OrdersTotal() ;i++)
{
OrderSelect(i,SELECT_BY_POS);
if(OrderSymbol()==Symbol() && OrderType==OP_SELL )
x++;
}


in my EA, i want to buy ...for example, if there is " n "orders of this EA ( eur/usd and BUY ) regarding some conditions.

so i could use your variable "x" to verify the number of orders. not??

if x=n
.....
....

if x=n+1
....
....

i have tried but it doesnt go. it's strange because in fact the logical is correct and "x" should be verify the number of orders, the currency and the type .

i am wrong something?
Brian Dee - Random Trader
1764
Brian Dee - Random Trader 2010.04.13 11:19  

G
Check out this EA https://www.mql5.com/en/code/8714
for a function that counts by OrderType and OrderSymbol
Good Luck
-BB-

giulio
138
giulio 2010.04.13 22:15  

barrow thanks but it doesnt solve my problem

i have tried with the roger's suggestion ...........

but when i check x=1 ======> for example buy with lot 0.2

x=2 ===> buy with lot 0.3
x=3 ==> buy with lot 0.4

seems that the program doesnt see the function x

if i use x=ordertotal() ......it ìs ok but obviously i need to check also the currancy and the type of order

have u an advice??? i can undestand which is the block

cloudbreaker
1574
cloudbreaker 2010.04.14 10:30  
Have you declared x as an integer before attempting to increment it?
In other words do you have "int x" anywhere in your code?

CB
giulio
138
giulio 2010.04.14 11:05  

yes....i have put INT X at the beginning of program.... the problem is that i have to do something if x=1 or x=2 or x=3...

Alexander
2441
Alexander 2010.04.14 22:06  
int x;
for (int i=0; i<OrdersTotal() ;i++)
{
OrderSelect(i,SELECT_BY_POS);
if(OrderSymbol()==Symbol() && OrderType==OP_SELL )
x++;
}
double lot;
if(x==1)lot=0.2;
else if(x==2)lot=0.3;
else if(x==3)lot=0.4;
if(lot!=0)OrderSend(...,lot,...);
giulio
138
giulio 2010.04.15 09:05  

i will try again Roger. :-))))))))))) i continue to thanks u :-))

but i have just tried in similar way and it seems that the program doesnt recognize X=1 or X=2 ....

i will inform u this evening

/ /12
To add comments, please log in or register