Discussion of article "Trade Operations in MQL5 - It's Easy" - page 2

 
Valmars:
You should still review the code before publishing.

This has been fixed a long time ago, on the day of publication.
 
Valmars:

I agree, trade classes have stabilised enough now. So why, while advocating their use, the examples include functions for obtaining instrument properties instead of using methods of CSymbolInfo class. It seems inconsistent.

Clarify what you mean. If you call to write classes everywhere, some newcomers may find it complicated and incomprehensible.
 
Rosh:
This has been fixed a long time ago, back on the day of publication.
I apologise, I opened the article at once, but read it only now.
 
Rosh:
Clarify what is meant. If you call to write classes everywhere, some newcomers may find it complicated and incomprehensible.

Actually, it's not me who urges you to use'Standard Library' classes in the above quote, I only agree. Of course, it's a matter of taste.

In a little bit complex EA there are a lot of references to symbol properties and by creating once an instance of CSymbolInfo class we simplify the references to them and the perception of the programme. My opinion.

Документация по MQL5: Стандартная библиотека
Документация по MQL5: Стандартная библиотека
  • www.mql5.com
Стандартная библиотека - Документация по MQL5
 

I apologise, I didn't know where to ask this question and decided to ask it here, I think the topic is suitable.

How can I close all orders opened either only for selling or only for buying at once?

 
nskforward:

I apologise, I didn't know where to ask this question and decided to ask it here, I think the topic is suitable.

How can I close all orders opened either for selling or for buying at once?

In MetaTrader 5 there can be only one open position for each instrument. Perhaps you mean to close all positions for all instruments?
 

Hello,
When using BuyStop function in the code to trade RTS-3.13 (RIH3) futures, an error keeps occurring :
10022 TRADE_RETCODE_INVALID_EXPIRATION - Invalid order expiry date

In the specification of futures RTS-3.13 it is specified that the type of orders - Valid until cancellation. in the queue until cancelled.
I tried to use other types ORDER_TIME_DAY, ORDER_TIME_SPECIFIED, ORDER_TIME_SPECIFIED_DAY - the error does not disappear.


Part of the code:

   int    digits = (int)SymbolInfoInteger(Ticket,SYMBOL_DIGITS);// number of decimal places
   double point  = SymbolInfoDouble(Ticket,SYMBOL_POINT);       // para.
   double ask    = SymbolInfoDouble(Ticket,SYMBOL_ASK);         // current purchase price
   double price= 1000 * point;                                  // not normalised opening price
   price  = NormalizeDouble(price, digits);                     // normalise the opening price
   //price = NormalizeDouble(ask + 1000, digits); // ????
   Print("digits=", IntegerToString(digits), " point=", DoubleToString (point, 0), " ask=", DoubleToString (ask, 0),
         " price=", DoubleToString (price, 0));    
//--- everything is ready, send a pending Buy Stop order to the server 
   if(!m_Trade.BuyStop(1, price, Ticket))
     {
      Print("The BuyStop() method failed. Return code="", m_Trade.ResultRetcode(),
            ". Code description: ",m_Trade.ResultRetcodeDescription());
     }
   else
     {
      Print("The BuyStop() method executed successfully. Return code="",m_Trade.ResultRetcode(),
            " (",m_Trade.ResultRetcodeDescription(),")");
     }

In the Strategy Tester log of the entry :

2012.12.18 19:44:59   digits=0 point=1 ask=151830 price=1000
2012.12.18 19:44:59   failed buy stop 1.00 RTS-3.13 at 1000 [Invalid expiration]
2012.12.18 19:44:59   CTrade::OrderSend: buy stop 1.00 RTS-3.13 at 1000 [invalid expiration]
2012.12.18 19:44:59   Метод BuyStop() потерпел неудачу. Код возврата=10022. Описание кода: invalid expiration

What could be the problem ? Please give me a hint.
I will be grateful if you reply to mail nfo52^mail.ru, ICQ UIN: 4002787, skype: osipov52.

Thank you.

Win7 64 times, MT5, demo-account DB Otkrytie.

 
Nikos52:

Hello,
When using BuyStop function in the code to trade RTS-3.13 (RIH3) futures, an error keeps occurring :
10022 TRADE_RETCODE_INVALID_EXPIRATION - Invalid order expiry date

In the specification of futures RTS-3.13 it is specified that the type of orders - Valid until cancellation. in the queue until cancelled.
I tried to use other types ORDER_TIME_DAY, ORDER_TIME_SPECIFIED, ORDER_TIME_SPECIFIED_DAY - the error does not disappear.


Part of the code:

In the Strategy Tester log of the entry :

What could be the problem ? Please give me a hint.
I will be grateful if you reply to mail nfo52^mail.ru, ICQ UIN: 4002787, skype: osipov52.

Thank you.

Win7 64 razr., MT5 , Demo-account DB Discovery.

Similar problem on RTS-3.13 Otkritie-demo, tried everything (while limit orders are set to ORDER_TIME_SPECIFIED_DAY as written in the symbol profile) !!!!. While buy-stop order is perfectly open in the market manually. This is a terminal glitch, you should write to the developers
 
Yeah, it couldn't be simpler! They have wised up a lot of things there, and yet using standard libraries, and if without them, so to speak, from scratch???? The easiest and fastest way to programme an Expert Advisor on MQl4!!!! My EA on mql4 takes 70 lines, I rewrote it on mql5, and it turned out to be 198!!!!!!. So the title with the word "simple" is not appropriate.
Как использовать торговые классы Стандартной библиотеки при написании советника
Как использовать торговые классы Стандартной библиотеки при написании советника
  • 2010.11.10
  • Samuel
  • www.mql5.com
В статье рассказывается о том, как использовать основной функционал торговых классов Стандартной библиотеки при написании советников, в которых применяется открытие, закрытие и модификация позиции, проверка свободной маржи перед размещением торговых ордеров, размещение и удаление отложенных ордеров. Показано, как использовать торговые классы для получения свойств ордеров и сделок.
 
zlodei:
...My mql4 EA takes 70 lines, I rewrote it to mql5, and it turned out to be 198!!!!!! So the title with the word "simple" is not appropriate.
This is if the EA idea is not complicated. Imho, the more complex the idea, the more the difference in the number of code lines between MQL4 and MQL5 will be in favour of the latter. So I wouldn't be so categorical....