Error 10015 with a sell limit order

 
Hello

I am trying to develop an EA that uses the sell limit order. However I am facing error 10015 when the EA sends the order.

Can anyone help me find my error?

I changed the names of the variables to make the code easier to understand.

I will attach the image with the sales order entry parameters.


Thank you.


if(PositionsTotal() == 0 && OrdersTotal() == 0){
         double SL_to_take = NormalizeDouble(PriceTop-PriceBottom, _Digits);
         
         double half_SL_to_take = NormalizeDouble(SL_to_take / 2, _Digits);
         
         double sell = NormalizeDouble(PriceBottom + half_SL_to_take,_Digits);
                      
         double sl = NormalizeDouble(PriceTop,_Digits);
         
         double SL_in_Point = NormalizeDouble((sl - sell) / _Point,0);
         
         double SL_in_Digits = NormalizeDouble((sl - sell),_Digits);
               
         double tp  = NormalizeDouble(sell-(SL_in_Digits),_Digits);
         
                
         trade.SellLimit(size_of_lots(SL_in_Digits), sell, _Symbol, sl, tp, ORDER_TIME_GTC,0,0);




         //"size_of_lots(SL_in_Digits)" calculates the lot size according to the stop size in points.
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Requests to execute trade operations are formalized as orders. Each order has a variety of properties for reading. Information on them can be obtained using functions Position identifier that is set to an order as soon as it is executed. Each executed order results in a deal that opens or modifies an already existing position. The identifier of...
Files:
 
Looks like the limit price is below the bid. Check PriceTop/Bottom.
 
lippmaje:
Looks like the limit price is below the bid. Check PriceTop/Bottom.
Thanks for the reply lippmaje.

I also thought about it but the limit price is above the bid.

I'll leave another print with the prices for analysis.
Files:
 
No idea. But since it's running in the tester you're able to reproduce the issue and add debug information like bid, ask etc.
 
ThiagoMoreira #:
Thanks for the reply lippmaje.

I also thought about it but the limit price is above the bid.

I'll leave another print with the prices for analysis.

for sell stop, price should be below than current price

 
Alexey Barkalov # :

for sell stop, price should be below than current price

No, it's not like this: Basic Principles - Trading Operations

order_types

Basic Principles - Trading Operations - MetaTrader 5 Help
Basic Principles - Trading Operations - MetaTrader 5 Help
  • www.metatrader5.com
Before you proceed to study the trade functions of the platform, you must have a clear understanding of the basic terms: order, deal and position...
 
lippmaje # :
No idea. But since it's running in the tester you're able to reproduce the issue and add debug information like bid, ask etc.

Freeze levels need to be checked. And it is always useful to display two lines on the chart: the 'Bid' line and the 'Ask' line.

Reason: