Error - Volume to be closed exceeds the position volume

 

Hello everyone,


I get the following message in the journal


"

CI 0 11:06:30.255 Scripts script 3_Estrutura_Basica (PETR4,M1) loaded successfully

NH 0 11:06:30.268 Trades '11620787': exchange sell 100 PETR4 at market

QS 2 11:06:30.292 Trades '11620787': failed exchange sell 100 PETR4 at market [Volume to be closed exceeds the position volume]

PP 0 11:06:30.292 Scripts script 3_Estrutura_Basica (PETR4,M1) removed

"


void OnStart()
  {
  
  // Inicializar o Request
  MqlTradeRequest requisicao;
  
  
  
  // ordem de compra a mercado
  requisicao.action = TRADE_ACTION_DEAL; // Compra a mercado
  requisicao.type = ORDER_TYPE_SELL; // Tipo Buy
  requisicao.symbol = _Symbol; // Ativo Corrente
  requisicao.type_time = ORDER_TIME_DAY;
  //requisicao.expiration = 0; 
  requisicao.price = SymbolInfoDouble(Symbol(),SYMBOL_BID);  //Nao e necessario porque e uma ordem a mercado
  requisicao.volume = 100;
  requisicao.sl = 0;
  requisicao.tp = 0 ;
  requisicao.type_filling = ORDER_FILLING_RETURN;
  
  requisicao.comment = "Compra a mercado";
  requisicao.deviation = 5;
  requisicao.magic = 1234;
  
  MqlTradeResult result;
  
  ResetLastError();
  bool res = OrderSend(requisicao,result);
  Print("Resultado : ",res); 

  
  }
//+------------------------------------------------------------------+

Thank you for your help

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Position Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Position Properties
  • www.mql5.com
Position ticket. Unique number assigned to each newly opened position. It usually matches the ticket of an order used to open the position except when the ticket is changed as a result of service operations on the server, for example, when charging swaps with position re-opening. To find an order used to open a position, apply the...
 
Eurico Paes:

Hello everyone,


I get the following message in the journal


"

CI 0 11:06:30.255 Scripts script 3_Estrutura_Basica (PETR4,M1) loaded successfully

NH 0 11:06:30.268 Trades '11620787': exchange sell 100 PETR4 at market

QS 2 11:06:30.292 Trades '11620787': failed exchange sell 100 PETR4 at market [Volume to be closed exceeds the position volume]

PP 0 11:06:30.292 Scripts script 3_Estrutura_Basica (PETR4,M1) removed

"


Thank you for your help

You are welcome.