MQL4 - automated forex trading   /  

Forum

Login | Register | Language: ru cn en
Post Your News in Blogs and Become Famous!

how to check the number of orders

Back to topics list  | 1 2 To post a new topic, please log in or register
avatar
51
giulioron 2010.04.13 00: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??

 
The Statistic Analysis of Market Movements and Their Prognoses
The present article contemplates the wide opportunities of the statistic approach to marketing. Unfortunately, beginner traders deliberately fail to apply the really mighty science of statistics. Meanwhile, it is the only thing they use subconsciously while analyzing the market. Besides, statistics can give answers to many questions.
avatar
47
farhang 2010.04.13 00: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;
         }
     }
   }
}

avatar
2552
Roger 2010.04.13 01: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.
avatar
Moderator
2029
gordon 2010.04.13 04: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.
 
avatar
51
giulioron 2010.04.13 12: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?
 
avatar
Moderator
1936
avatar
51
giulioron 2010.04.14 00: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

 
avatar
1397
cloudbreaker 2010.04.14 12: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
 
avatar
51
giulioron 2010.04.14 13: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...

avatar
2552
Roger 2010.04.15 00: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,...);
avatar
51
giulioron 2010.04.15 11: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

 
Back to topics list   | 1 2  

To add comments, please log in or register