Download MetaTrader 5
To add comments, please log in or register
Read the Forum and improve your rating!
GoodvinJ
28
GoodvinJ 2015.07.28 15:10 

Hello!

There is something strange with my EA.

I'm using this function for position selection:

bool SelectBotPosition()
{
   int ordersCount = OrdersTotal();
  
   for (int i = 0; i < ordersCount; i++)
   {
      if (OrderSelect(i, SELECT_BY_POS))
      {
         if (OrderSymbol() == Symbol() && OrderMagicNumber() == BotMagic)
         {
            Print("order type ", OrderType());
            switch (OrderType())
            {
               case OP_BUY:
               case OP_SELL:
                  return true;
            }
         }
      }
   }

   return false;
}
And it prints "order type 4" i.e. OP_BUYSTOP, but EA never creates a BUYSTOP order, moreover I see opened position in the Trades window:

2015.07.28 15:59:59.833    '3087888': order was opened : #2466572 buy 0.01 EURUSD.q at 1.10500 sl: 0.00000 tp: 0.00000
2015.07.28 15:59:59.692    '3087888': order buy market 0.01 EURUSD.q sl: 0.00000 tp: 0.00000

It should be OP_BUY. What's wrong?

I'm using terminal ver. 840.

whroeder1
13644
whroeder1 2015.07.29 13:13  
goodvinj it prints "order type 4" i.e. OP_BUYSTOP, but EA never creates a BUYSTOP order,
Apparently it does.
There are no mindreaders here. Print out all relevant information, like ticket number, and find out.
GoodvinJ
28
GoodvinJ 2015.07.29 18:44  

There is no BUYSTOP orders nor in the trades list nor in the history.

History contains BUY/SELL orders only.

whroeder1
13644
whroeder1 2015.07.29 18:48  
There won't be stop/limits in history (except deleted ones.) They become buy/sell when they trigger.
GoodvinJ
28
GoodvinJ 2015.07.29 19:06  

OK, anyway when EA prints "order type 4" there is only BUY trade, journal contains lines

2015.07.28 15:59:59.833    '3087888': order was opened : #2466572 buy 0.01 EURUSD.q at 1.10500 sl: 0.00000 tp: 0.00000

2015.07.28 15:59:59.692    '3087888': order buy market 0.01 EURUSD.q sl: 0.00000 tp: 0.00000

for the current BUY position.

GoodvinJ
28
GoodvinJ 2015.07.30 10:45  

I've added a ticket number to the log.

Now the journal contains:

2015.07.30 11:07:18.200    '3087888': order was opened : #2487443 buy 0.01 EURUSD.q at 1.09818 sl: 0.00000 tp: 0.00000
2015.07.30 11:07:17.607    '3087888': order buy market 0.01 EURUSD.q sl: 0.00000 tp: 0.00000

And the EA prints

2015.07.30 11:07:18.763    MyEA EURUSD.q,M5: ticket 2487443, type 4

messages.

So again.. How is it possible?

GoodvinJ
28
GoodvinJ 2015.08.16 19:37  

Looks like a broker-specific issue.

/
To add comments, please log in or register