Download MetaTrader 5

invalid request - 10013

To add comments, please log in or register
nikolaynik
9
nikolaynik  

Hello to everyone!

Can anybody make it clear for me, why this amazingly sophisticated code does not work?

So, the deal is I am dropping that Script onto my Graph, and as a result I get a Messege:

Invalid request - 10013. To tell the truth this messege is not able to clarify anything for me.

If you, my dear friends, can open my eyes and may make this code work, please help me, I will really appreciate that.

 
//+------------------------------------------------------------------+
//|                                                          Nik.mq5 |
//|                        Copyright 2016, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2016, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"

int STP = 40;
int TKP = STP*6;
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
  {
//---
      if( PositionSelect( Symbol() ) == true ){
      Print( "You've got some position" );
      return;
    }
    Print( "You don't have positions" );
    MqlTradeRequest mrequest;
    MqlTradeResult  mresult;  
    MqlTick latest_price;
    MqlTradeCheckResult cres;
    
    
    if(!SymbolInfoTick(_Symbol,latest_price)){
      Alert("Ошибка получения последних котировок - ошибка:",GetLastError(),"!!");
      return;
    }
    mrequest.action = TRADE_ACTION_DEAL;                                 // немедленное исполнение
    mrequest.price  = NormalizeDouble( latest_price.bid, _Digits);          // последняя цена ask
    mrequest.sl     = NormalizeDouble( latest_price.ask - STP * _Point, _Digits); // Stop Loss
    mrequest.tp     = NormalizeDouble( latest_price.ask + TKP * _Point, _Digits); // Take Profit
    mrequest.symbol = _Symbol;                                         // символ
    mrequest.volume = 0.1;                                            // количество лотов для торговли
//  mrequest.magic  = 12345;                                        // Magic Number
    mrequest.type   = ORDER_TYPE_BUY;                                     // ордер на покупку
    mrequest.type_filling = ORDER_FILLING_IOC;                          // тип исполнения ордера - все или ничего
    mrequest.deviation=30;              
    if( OrderCheck( mrequest, cres ) ){
      Print( "Check is successful" );
      int res = OrderSend( mrequest, mresult);
    }
    else{
      Print( "Check is down - ", cres.retcode );    
      Print( "price - ", mrequest.price );    
      Print( "StopLoss - ", mrequest.sl);    
      Print( "TakeProfit - ", mrequest.tp );    
    }
    Print(__FUNCTION__,": ",mresult.comment," код ответа ",mresult.retcode); 

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

 


Alain Verleyen
Moderator
32811
Alain Verleyen  

Change this line :

   MqlTradeRequest mrequest={0};
nikolaynik
9
nikolaynik  
Alain Verleyen:

Change this line :

Thanks a lot. Checking is completed successfully. You are a magician)))
To add comments, please log in or register