Errors, bugs, questions - page 445

 
komposter:

To follow up on the normalisation of the lot

Guys, why theorise?

For laughs and not to get rusty in the head.

Everything has to be in moderation. My version has been working with real money for more than 5 years, with different brokers, account types, and instruments, and I have never made a mistake.
I have never made a mistake. And I will never make one. Never mind, we are not serious.
 
komposter:

The step should be a multiple of min. lot.

What makes you so sure? Practice - I understand, but not the limitation of the engine.
The arguments of the parties are clear. In any case, I sincerely appreciate the sympathy. :)

Swan:

Looked, all instruments are traded at the same time in the championship accounts. Register)

Yeah seems to have registered. That's the one I'm catching this error on.

Swan:

Might give it another try:

if(current price == 0.0) return;

Thanks for the idea! I will have to try this option. :)

 

voix_kas:

Yeah, I think I'm registered. That's where I'm catching this error.

There is a minute bar on GBPCHF 2011.01.03 at 00:00. Have you not contacted servicedesk?
 
Swan:
On GBPCHF 2011.01.03 at 00:00 there is a minute bar. Have you contacted servicedesk?

I didn't go to the SD.

Here's the situation. I am writing a multi-currency EA. I put it on Eurobucks chart and try to track all of the valid currency pairs passed to the Expert Advisor as a parameter.

Lack of methodology/documentation. Here are a few questions for example:

1. Why can the price be zero? After all, by that time (2011.01.03 00:00:00) the last known price (both Bid and Ask) still existed? On what principles does the terminal give this.

2. there is a quotation session. How is it, in principle, different from a trading session? It is logical to assume that it is possible to trade during the second one. And if we cannot trade during the first (quotation) session, then why do quotations change? The quotes change because of, excuse me for this interpretation, "disbalance of supply and demand".

3. Suppose we received a Tick on one currency pair. In the same event we try to "see" the state of another pair. Where is the guarantee that the last quote that came for the other pair is still valid? What is the lifetime of a quote? The most rational explanation is checking of the last quotation with the simultaneous check of lot volume in the market. I.e. as I see it: N quote of eurusd is received. It does not come for nothing, but an option is placed at this quote for a certain volume. Those who want to buy/sell are snapping up the pie. At some moment, it (the cake) finishes and this quote "stops to live". Then the terminal gives the next (less attractive) quotation. And if there is no quotation at all (no one wants to sell/buy currency)? Then the price is equal to zero?

Anyway, I am not a stock market/forex expert.

I would be grateful if someone could give me a detailed answer to the questions voiced. How is it really like, and how are these or those situations presented in the MT5 terminal?

 
voix_kas:

I didn't go to the SD.

Here's the situation. I am writing a multi-currency EA. I put it on Eurobucks chart and try to track all of the valid currency pairs passed to the Expert Advisor as a parameter.

Lack of methodology/documentation. Here are a few questions for example:

1. Why can the price be zero? After all, by that time (2011.01.03 00:00:00) the last known price (both Bid and Ask) still existed? On what principles does the terminal give this.

2. there is a quotation session. How is it, in principle, different from a trading session? It is logical to assume that it is possible to trade during the second one. And if we cannot trade during the first (quotation) session, then why do quotations change? The quotes change because of, excuse me for this interpretation, "disbalance of supply and demand".

3. Suppose we received a Tick on one currency pair. In the same event we try to "see" the state of another pair. Where is the guarantee that the last quote that came for the other pair is still valid? What is the lifetime of a quote? The most rational explanation is checking of the last quotation with the simultaneous check of lot volume in the market. I.e. as I see it: N quote of eurusd is received. It does not come for nothing, but an option is placed at this quote for a certain volume. Those who want to buy/sell are snapping up the pie. At some moment, it (the cake) finishes and this quote "stops to live". Then the terminal gives the next (less attractive) quotation. And if there is no quotation at all (no one wants to sell/buy currency)? Then the price is equal to zero?

Anyway, I am not a stock market/forex expert.

I would be grateful if someone could give me a detailed answer to the questions voiced. How it is in reality, and how these or those situations are represented in the MT5 terminal?

Let us deal with it point by point. An Expert Advisor is multicurrency, so it should behave accordingly.

1. Let's exclude the main possible problem of getting the 0 price - the list of symbols that are supposed to be traded selectively selected (i.e., you do not need to worry about the availability of the necessary symbols in MarketWatch)?

2. On trading and quoting sessions, the comment has already been given by developers (in particular, Rashid Umarov commented it here). About a situation when there is a quote, but you cannot trade - is quite normal (especially for the stock market). Also nobody guarantees that the quotes will be updated during a trading session. 3.

3. about the glass - and where to get the glass (most importantly, what to put in it) in the Forex market? For questions the answers are like this (if everything is ok and there is a connection to the server):

(a) "Last Quote" (information about the last tick) is valid from the time a tick occurs until a new tick appears. In the terminal, the time of the last quote can be viewed in the "market overview".

b) If you collect information about ticks only in the handler OnTick() of a multicurrency Expert Advisor, no one can guarantee, that between ticks of the main pair there won't be a dozen of ticks of other pairs. Because depending on a pair and trading activity on it, between ticks may pass from a fraction of a second to several minutes.

Of course for the Forex market (especially for EURUSD) it isn't very essential, but it must be remembered and taken into account in the Expert Advisor's logic.

c) You can programmatically determine the time of the last quote by analyzing the structure of MqlTick and comparing the time of the last quote with a certain value, you can easily determine the relevance of a quote.

struct MqlTick
  {
   datetime     time;          // Время последнего обновления цен
   double       bid;        // Текущая цена Bid
   double       ask;        // Текущая цена Ask
   double       last;       // Текущая цена последней сделки (Last)
   ulong        volume;     // Объем для текущей цены Last
  };

d) As I've already mentioned above, you should monitor the connection with the server and if possible, check/receive quotes not only in OnTick(), but also in OnTimer().

 

Let's go in reverse. Under what circumstances can the price (bid/ask) take on zero values in the terminal?

Then comes the second question. Well, we found out that the last quote for this symbol was received 2 seconds/minutes/hour ago. The trading session did not close. How can we avoid the "no price" error?

Документация по MQL5: Получение рыночной информации / SymbolInfoSessionQuote
Документация по MQL5: Получение рыночной информации / SymbolInfoSessionQuote
  • www.mql5.com
Получение рыночной информации / SymbolInfoSessionQuote - Документация по MQL5
 
voix_kas:

Let's go in reverse. Under what circumstances can price (bid/ask) take on zero values in the terminal?

Then comes the second question. Well, we found out that the last quote for this symbol was received 2 seconds/minutes/hour ago. The trading session did not close. How can we not get a "no price" error?

Did you, when you received a zero price, ask GetLastError?
 
stringo:
When you got the zero price, did you ask GetLastError?

Error code: 4756. You can see it in the screenshot.

Furthermore. Here is the same error received. At the same time, the marketwatch shows the presence of the price and the tool is synchronized in the logs.

 
voix_kas:

Error code: 4756. You can see it in the screenshot.

Furthermore. Here is the same error received. While the marketwatch shows price availability and the tool is synchronised in the logs.

You need an error code after "no price...", not after "failed...".
 
uncleVic:
You need the error code after "no price...", not after "failed...".
  ...
  // Формирование торгового приказа.
  MqlTradeResult TradeResult;
  MqlTradeRequest TradeRequest;

  TradeRequest.action = TRADE_ACTION_DEAL;
  TradeRequest.symbol = Instrumet;
  TradeRequest.volume = NormalizeDouble(Volume, 8);
  TradeRequest.price = SymbolInfoDouble(Instrumet, SYMBOL_ASK);
  TradeRequest.sl = 0;
  TradeRequest.tp = 0;
  TradeRequest.deviation = Deviation;
  TradeRequest.type = ORDER_TYPE_BUY;
  TradeRequest.type_filling = TypeFilling;

  // Отправка торгового приказа.
  ResetLastError();
  if (!IsTradeAllowed()) return;
  if (OrderSend(TradeRequest, TradeResult)) TradeResultAnalyse("Buy.OrderSend", TradeResult.retcode);
  else Print("Buy.OrderSend = false! Код ошибки: \'", _LastError, "\'.");

And how do I catch the error code at the point you indicate? I register the error on the last line of the above code.

This error does not appear if the following term is added just before this code:

if(!NormalizeDouble(SymbolInfoDouble(Instrumet, SYMBOL_ASK), 8)) return;
Reason: