Error trying to enter orders: failed sell limit 1.00 WDO @ N at 4166 [Invalid price]

 

I tried to read other topics in the forum, but unfortunately no solution solved my problem ...

I'm trying to leave an order in stone, for when the market reaches the price it will be executed.

But it turns out that when I make the order as in the function below, it pops up the message I put in the invalid price title, and tested using the ask or bid price, it works, but not as expected, if for example the market is in 4160 and I understand sending the order at 4180, it executes instantly, even if I put request.price = ask + 20, which from what I understand would be the solution, I don't know what to do anymore ...

Here's my role:

void ordemPedra(double preco){

request.action = TRADE_ACTION_PENDING;

        request.symbol = _Symbol;

request.volume = 1;

request.magic = 123;

request.type_time = ORDER_TIME_DAY;

request.deviation = 1;

preco = NormalizeDouble(preco,1);

request.price=preco;

request.type = ORDER_TYPE_BUY_LIMIT;

//enviar ordem

if(!OrderSend(request,result))

    Comment("OrderSend error ",GetLastError(), "  comment ", result.comment);

}
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Trade Operation Types
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Trade Operation Types
  • www.mql5.com
Trading is done by sending orders to open positions using the OrderSend() function, as well as to place, modify or delete pending orders. Each trade order refers to the type of the requested operation. Trading operations are described in the ENUM_TRADE_REQUEST_ACTIONS enumeration...
 
Natã Pereira:

I tried to read other topics in the forum, but unfortunately no solution solved my problem ...

I'm trying to leave an order in stone, for when the market reaches the price it will be executed.

But it turns out that when I make the order as in the function below, it pops up the message I put in the invalid price title, and tested using the ask or bid price, it works, but not as expected, if for example the market is in 4160 and I understand sending the order at 4180, it executes instantly, even if I put request.price = ask + 20, which from what I understand would be the solution, I don't know what to do anymore ...

  1. Please post only in English on this forum. Use the automatic translation tool if needed. Use simple language structure when using mechanical translation.

  2. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum
              Messages Editor

  3. You can't place a pending order at Ask/Bid.

 
William Roeder:
  1. ...

  2. ...
  3. You can't place a pending order at Ask/Bid.

Yes you can on this centralized market. It's not like Forex.
 
Natã Pereira:

I tried to read other topics in the forum, but unfortunately no solution solved my problem ...


I'm trying to leave an order in stone, for when the market reaches the price it will be executed.


But it turns out that when I make the order as in the function below, it pops up the message I put in the invalid price title, and tested using the ask or bid price, it works, but not as expected, if for example the market is in 4160 and I understand sending the order at 4180, it executes instantly, even if I put request.price = ask + 20, which from what I understand would be the solution, I don't know what to do anymore ...


Here's my role:


void orderStone (double price) {

request.action = TRADE_ACTION_PENDING ;

request.symbol = _Symbol;

request.volume = 1;

request.magic = 123;

request.type_time = ORDER_TIME_DAY;

request.deviation = 1;

price = NormalizeDouble (price, 1);

request.price = price;

request.type = ORDER_TYPE_BUY_LIMIT;

// send order

if (! OrderSend (request, result))

Comment ("OrderSend error", GetLastError (), "comment", result.comment);

}

Your post is confusing. Your title talk about SELL LIMIT but your code snippet is using BUY LIMIT.

If it's a BUY LIMIT at ASK or ASK +20, of course it executes immediately, the market is already at that price or better.  A BUY LIMIT price should be below the market if you want to wait the market to trigger it. If you want to place a pending above the market  and wait the market to reach it you have to use a BUY STOP.

Your title also talked about WDO@N but this symbol is not tradable, it's an aggregation symbol.

And finally using NormalizeDouble (price, 1) is not the right way to normalize a price, WDO prices is moving by 0.5 step.

 

Right,


I'm sorry, I made the post on the wrong forum.

 
Natã Pereira:

This is an English language forum.

Please only post in English.

Use the site's translation tool if necessary.

I have used the translation tool to edit your post - next time do it yourself.


Use the code button (Alt + S) when posting code

I have edited your post - next time do it yourself.

Reason: