SYMBOL()

 

HI GUYS I HAVE SOME PROBLEMS REGARDING THE CLOSURE OF THE ORDERS. I EXPLAIN:

I USE THIS RULES:

FOR (I=0,Z=0;I<ORDERTOTAL();I++)
ORDERSELECT(I,SELECT BY POS)
IF(ORDERSYMBOL()==SYMBOL() && ORDERTYPE==OPBUY)
Z++

......

IF (Z=1 )
ORDERSELECT(TICKET,SELECT BY POS,MODE TRADES)
IF( CONDITIONS)

ORDERCLOSE


IF(Z=2)
........
.....




THE PROBLEM IS THAT THE OPEN PRICE IS OK BUT THEN THE ORDER IS CLOSED IMMEDIATELY. TAKE IN ACCOUNT THAT I HAVE ALREADY 5 ORDERS OPENED WITH OTHER CURRENCY. DURING THE OPTIMIZATION IS ALL OK.

WHAT COULD IT BE THE PROBLEM?? MAYBE I HAVE TO SUBSTITUTE SYMBOL() WITH EUR USD ???? OR MAYBE SELECT BY TICKET????

 

when closing orders you want to count-down (loop backwards) through the ordertotals() list

 

but if i write : ordersymbol()== "eurusd" for example .....it's right???

or maybe the problem could be that in each my EA I use the same variable to identify the orders ( ticket, ticket2, ticket3....).

maybe i have to change them???

 
giulioron wrote >>

but if i write : ordersymbol()== "eurusd" for example .....it's right???

or maybe the problem could be that in each my EA I use the same variable to identify the orders ( ticket, ticket2, ticket3....).

maybe i have to change them???


OrderSymbol()==Symbol() is ok, will compare the Symbol from the chart with the symbol from the order.
Same EA in different Pairs -->> use unique MagicNumber to identify maybe, but Symbol() should solve.
You have 2 OrderSelect ... is not neccesary in normal case, when logic to close is in the same loop how the first OrderSelect.
Maybe your logic for IF( CONDITIONS) does not work like you aspect?
Post the code for the complete Part and someone can help you.

for(int i=OrdersTotal()-1; i>=0; i--) 
      {
       OrderSelect(i, SELECT_BY_POS, MODE_TRADES);
       if(OrderSymbol()==Symbol())
       {
       if (OrderMagicNumber() == MagicN)
       {
if (OrderProfit()>0.0&&VolaB1>MaxVola&&VolaA1<VolaB1&&VolaA2>VolaB2)
         {
         Print("Close Buy by Vola");
         OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),5,0);
         continue;
        }
}
}
}
 

ok later i will post the code becasue its rally strange. i use 5 EA but for 5 different currency ( only in EUR USD i use on one chart the EA for sell and for another chart the EA for call)

in adding i have 4 order opened...but i think that that's not a problem becasue i check with symbol() and type order. i post the code and then we will see

grazieeeeeeeeeeee

Reason: