Error 129 from open order in EA

 

I have only one chart open, the AUDUSD window. This is where the EA is running.

When a certain condition is met, the EA will attempt to open a position for a different pair, for example the EURUSD.

The result is always a 129 error.

Here is my code--

iTicket=OrderSend("EURUSD",OP_BUY,0.1,Ask,3,0,0,"myEA",iMagicNbr,0,CLR_NONE);
if(iTicket > 0)
{
if(OrderSelect(iTicket,SELECT_BY_TICKET,MODE_TRADES)) Print("EURUSD BUY order opened : ",OrderOpenPrice());
}
else
{
Print("EURUSD BUY open error: ",GetLastError());
}

Any ideas??

Thanks.

 
michaelB:

I have only one chart open, the AUDUSD window. This is where the EA is running.

When a certain condition is met, the EA will attempt to open a position for a different pair, for example the EURUSD.

The result is always a 129 error.

Here is my code--

iTicket=OrderSend("EURUSD",OP_BUY,0.1,Ask,3,0,0,"myEA",iMagicNbr,0,CLR_NONE);
if(iTicket > 0)
{
if(OrderSelect(iTicket,SELECT_BY_TICKET,MODE_TRADES)) Print("EURUSD BUY order opened : ",OrderOpenPrice());
}
else
{
Print("EURUSD BUY open error: ",GetLastError());
}

Any ideas??

Thanks.

Difficult to see with just a small portion of your code.

129 = Invalid Price.

Try a RefreshRates() call directly before your open.

 
michaelB:

I have only one chart open, the AUDUSD window. This is where the EA is running.

...

iTicket=OrderSend("EURUSD",OP_BUY,0.1,Ask,3,0,0,"myEA",iMagicNbr,0,CLR_NONE);

Apparently you're trying to enter long EURUSD position at AUDUSD Ask price.

 
michaelB:

I have only one chart open, the AUDUSD window..

You have to use MarketInfo.


Your code:

iTicket=OrderSend("EURUSD",OP_BUY,0.1,Ask,3,0,0,"myEA",iMagicNbr,0,CLR_NONE);


Right code:

iTicket=OrderSend("EURUSD",OP_BUY,0.1,MarketInfo("EURUSD",MODE_ASK),3,0,0,"myEA",iMagicNbr,0,CLR_NONE);


Cheers

 

Aargh, didn't notice that.

What you could do - if you've just attached the wrong EA to the wrong chart is to replace "EURUSD" in the order open to Symbol().

That way your EA will be multi-purpose, if that's what you want. By multi-purpose, I mean you'd attach the same EA on all your charts and it would just place orders in the symbol of whatever chart its attached to.

In that case, the code would be:

iTicket=OrderSend(Symbol(),OP_BUY,0.1,Ask,3,0,0,"myEA",iMagicNbr,0,CLR_NONE);

 
ggekko wrote >>

You have to use MarketInfo.

Your code:

Right code:

Cheers

GGEKKO--

my EA is all better now, great solution.

Thank you, thank you, thank you.

Reason: