Discussion of article "Limitations and Verifications in Expert Advisors"

 

New article Limitations and Verifications in Expert Advisors is published:

Is it allowed to trade this symbol on Monday? Is there enough money to open position? How big is the loss if Stop Loss triggers? How to limit the number of pending orders? Was the trade operation executed at the current bar or at the previous one? If a trade robot cannot perform this kind of verifications, then any trade strategy can turn into a losing one. This article shows the examples of verifications that are useful in any Expert Advisor.

The messages of the CheckVolumeValue.mq5 that checks the volume to be correct.

Author: MetaQuotes

 

useful article

 
I agree, a lot of useful stuff... Please, do not consider it difficult, please explain the concept of "Trading Session" and "Quotation Session".
 

I understand that a trading session differs from a quotation session in that you can already place orders.

but quotations are not going on yet, i.e. trading is not taking place, but orders can be placed.

Well, it is clear that quotations are going on, which means that trades on this instrument are taking place.


correct me if I'm wrong

 
In the trading session you can trade, in the quotation session prices are received as in the trading session, but you cannot trade.
 
Rosh:
In the trading session you can trade, in the quote session prices come in as in the trading session, but you cannot trade.

Thank you, that makes sense.
 
Due to a change in the MQL5 language, now the maximum allowed cumulative volume per one symbol should be obtained in this way:
//--- get the character limit on volume
   double max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_LIMIT);

Theold variant was like this and it should not be used anymore:

//--- get the character limit on volume
   double max_volume=AccountInfoDouble(ACCOUNT_LIMIT_VOLUME);


The article has been corrected and the new code of Check_Order_And_Volume_Limits.mq5 Expert Advisor has been attached.

 

Due to changes in MQL5, now the maximal overall volume allowed for one symbol can be obtained as following:

//--- get symbol limitation for volume
   double max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_LIMIT);

Do not use the old variant! It was like this:

//--- get symbol limitation for volume
   double max_volume=AccountInfoDouble(ACCOUNT_LIMIT_VOLUME);
The article has been corrected and the new Check_Order_And_Volume_Limits.mq5 expert code has been attached to it.
 

(build 306)

void OnStart()
{
double max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_LIMIT);
}

 

compile errors: 

 

 'SYMBOL_VOLUME_LIMIT' - undeclared identifier test.mq5 4 46
'SymbolInfoDouble' - no one of the overloads can be applied to the function call test.mq5 4 20

 

Quote from the article:"To get the opening time of the last bar you can use the SeriesInfoInteger() function, which needs to be given the symbol name, timeframe and the SERIES_LASTBAR_DATE property".

In an earlier version of the reference book there was an example of getting the last bar open time using the CopyTime function, roughly like this:

datetime lastbar_time[1];

CopyTime(Symbol(),0,0,1,lastbar_time);

Question: which of these two options for getting the last bar open time is preferable in terms of speed of information retrieval and efficiency of use?

 
Yedelkin:

Quote from the article:"To get the last bar open time, you can use the SeriesInfoInteger() function, which needs to be given the symbol name, timeframe and SERIES_LASTBAR_DATE property."

In an earlier version of the Reference Manual there was an example of getting the last bar opening time using the CopyTime function, like this:

Question: which of these two options for getting the last bar open time is preferable in terms of speed of information retrieval and efficiency of use?

They should be equivalent in terms of time, but the option SERIES_LASTBAR_DATE with looks better.