Different Currency Order

To add comments, please log in or register
frank75
111
frank75  

Hi

I attached an EA on many charts .

why on EUR-CAD open order of GBPAUD ?

 EURCAD,M15: close #273335799 buy 0.05 GBPAUD at 1.81952 sl: 1.81833 tp: 1.82452 at price 1.81938

Alain Verleyen
38661
Alain Verleyen  
frank75:

Hi

I attached an EA on many charts .

why on EUR-CAD open order of GBPAUD ?

 EURCAD,M15: close #273335799 buy 0.05 GBPAUD at 1.81952 sl: 1.81833 tp: 1.82452 at price 1.81938

It's nopt an open order, it's a close.

Fix your code.

William Roeder
20207
William Roeder  
Using OrdersTotal directly and/or no Magic number filtering on your OrderSelect loop means your code is incompatible with every EA (including itself on other charts and manual trading.)
          Symbol Doesn't equal Ordersymbol when another currency is added to another seperate chart . - MQL4 and MetaTrader 4 - MQL4 programming forum
frank75
111
frank75  
ok  unique magic number for each chart .  thank you  :)

William Roeder
20207
William Roeder  
frank75: is not correct ?
  1. When you post code please use the CODE button (Alt-S)! (For large amounts of code, attach it.) Please edit your post.
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  2. 'no Magic number filtering on your OrderSelect loop means your code is incompatible with every other EA (and manual trading.)"

  3. In the presence of multiple orders (one EA multiple charts, multiple EAs, manual trading,) while you are waiting for the current operation (closing, deleting, modifying) to complete, any number of other operations on other orders could have concurrently happened and changed the position indexing:
    1. For non-FIFO (US brokers,) (or the EA only opens one order per symbol,) you can simply count down in a position loop, and you won't miss orders. Get in the habit of always counting down.
                Loops and Closing or Deleting Orders - MQL4 and MetaTrader 4 - MQL4 programming forum
      For FIFO (US brokers,) and you (potentially) process multiple orders per symbol, you must count up and on a successful operation, reprocess all positions (set index to -1 before continuing.)
    2. and check OrderSelect in case earlier positions were deleted.
                What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
                Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
    3. and if you (potentially) process multiple orders, must call RefreshRates() after server calls if you want to use the Predefined Variables (Bid/Ask) or OrderClosePrice() instead, on the next order/server call.

  4. Check your return codes for errors, report them and you would know why. Don't just silence the compiler, it is trying to help you.
              What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
    Only those functions that return a value (e.g. iClose, MarketInfo, etc.) must you call ResetLastError before in order to check after.
frank75
111
frank75  

i try this buot not work correctly

for( int i = 0 ; i < OrdersTotal() ; i++ )
           {
            OrderSelect( i, SELECT_BY_POS, MODE_TRADES );
            if( OrderSymbol() == Symbol()
             && OrderMagicNumber() == ute_MagicID )
               {
                if (OrderType() == OP_BUY &&   (  diff_low_1_0 > 15*Point
                                              
                                                )
                                               )
               
                                             
                      {
                    
                       if(OrderClose(OrderTicket(),ute_lot,OrderClosePrice(),3,Red))
                         num_ordini_buy = 0;
                         else(Print("ERR.BUY CLOSE"));
                    
                       }  }
               
Konstantin Nikitin
7859
Konstantin Nikitin  
OrderSelect( i, SELECT_BY_POS, MODE_TRADES );
if( !OrderSelect( i, SELECT_BY_POS, MODE_TRADES ) ) continue;
OrderSelect
for( int i = 0 ; i < OrdersTotal() ; i++ )
for( int i = OrdersTotal()-1 ; i >= 0 ; i-- )
OrderClose closes the order. This reduces the array. Therefore, the search from the senior to the younger.
William Roeder
20207
William Roeder  
In the presence of multiple orders (one EA multiple charts, multiple EAs, manual trading,) while you are waiting for the current operation (closing, deleting, modifying) to complete, any number of other operations on other orders could have concurrently happened and changed the position indexing:
  1. For non-FIFO (US brokers,) (or the EA only opens one order per symbol,) you can simply count down in a position loop, and you won't miss orders. Get in the habit of always counting down.
              Loops and Closing or Deleting Orders - MQL4 and MetaTrader 4 - MQL4 programming forum
    For FIFO (US brokers,) and you (potentially) process multiple orders per symbol, you must count up and on a successful operation, reprocess all positions (set index to -1 before continuing.)
  2. and check OrderSelect in case earlier positions were deleted.
              What are Function return values ? How do I use them ? - MQL4 and MetaTrader 4 - MQL4 programming forum
              Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
  3. and if you (potentially) process multiple orders, must call RefreshRates() after server calls if you want to use the Predefined Variables (Bid/Ask) or OrderClosePrice() instead, on the next order/server call.
To add comments, please log in or register