Errors, bugs, questions - page 662

 

Good afternoon!

Please check the correctness of the function that should determine whether an open position is "frozen".

In particular, didn't I overdo it with Ask/Bid?

bool IsPositionFrozen(const string Symbol) {
  if (!PositionSelect(Symbol)) return false;
  bool FreezTP = true, FreezSL = true;
  double FreezLevel = SymbolInfoInteger(Symbol, SYMBOL_TRADE_FREEZE_LEVEL) * SymbolInfoDouble(Symbol, SYMBOL_POINT);
  switch (PositionGetInteger(POSITION_TYPE)) {
    case POSITION_TYPE_BUY:
        if ((NormalizeDouble(PositionGetDouble(POSITION_TP), (int)SymbolInfoInteger(Symbol, SYMBOL_DIGITS)) == 0) ||
            (PositionGetDouble(POSITION_TP) - SymbolInfoDouble(Symbol, SYMBOL_BID) > FreezLevel))
          FreezTP = false;
        if ((NormalizeDouble(PositionGetDouble(POSITION_SL), (int)SymbolInfoInteger(Symbol, SYMBOL_DIGITS)) == 0) ||
            (SymbolInfoDouble(Symbol, SYMBOL_BID) - PositionGetDouble(POSITION_SL) > FreezLevel))
          FreezSL = false;
        break;
      case POSITION_TYPE_SELL:
        if ((NormalizeDouble(PositionGetDouble(POSITION_TP), (int)SymbolInfoInteger(Symbol, SYMBOL_DIGITS)) == 0) ||
            (SymbolInfoDouble(Symbol, SYMBOL_ASK) - PositionGetDouble(POSITION_TP) > FreezLevel))
          FreezTP = false;
        if ((NormalizeDouble(PositionGetDouble(POSITION_SL), (int)SymbolInfoInteger(Symbol, SYMBOL_DIGITS)) == 0) ||
            (PositionGetDouble(POSITION_SL) - SymbolInfoDouble(Symbol, SYMBOL_ASK) > FreezLevel))
          FreezSL = false;
      break;
    default: return false;
  }
  if (FreezTP || FreezSL) return true;
  else return false;
}
 
tol64:

No, everything worked correctly there on the server ( MQ demo account). That is, the stops were triggered when I was not connected. But, when I connected, the market was already closed. In the Market Watch window the time of the last tick before my connection was cut off was recorded. When requesting the history of trades by specifying TimeCurrent() as the second value, I didn't get the entire history. Although, Help for TimeCurrent() says that:

That is, I understand that this function should return the value of last arrival of quotation of one of the instruments in Market Watch window from the server, even if the connection was broken and the connection happened when the market was already closed. In my case, this didn't happen and I didn't get all of the history. I do not know whether the Market Watch should synchronize time with the server when the market is closed or not, it is not mentioned in the Help.

In that case if full history is needed you can simply add more day ahead number and it will be a guarantee that all deals will be chosen. :)

In the tester, there is a bug with the HistoryDealsTotal() function, and it appears in the Visualization mode. The time is correctly modelled there. Just a crutch helps in some cases.


Yeah, remembered the gist of it, that there was a break in communication. It seems that the terminal starts checking and downloading additional history only at tick receipt for an instrument and there is no tick at the weekend. Of course, you can update charts manually, and then the last server time will be updated. And if in the automatic mode, then you should fix the break of connection and, if it is restored during the weekend, then start the function of checking and downloading the history, CheckLoadHistory(). Use a timer.

In general, "amazing" things sometimes happen to the terminal. Here's yesterday, the laptop was working via phone as a modem. Multicurrency Expert Advisor was working in tracking mode (autotrading disabled). Went away for 15 minutes with the phone, came back, reconnected. Terminal restored the connection with the server. It seemed that I could easily download the missed quotes. But the terminal started furiously downloading the history - what else is there to do? Everything froze: market overview, trading tab, charts. The phone doesn't support 3G, it works via EDGE, so the procedure was delayed. When it reached 20 MB, I decided to check if I could trade something manually in such a condition. Tried to close the position, got a refusal due to lack of connection and that's where the downloading stopped. After reconnection everything went fine. Here is an excerpt from the terminal log:

OK 0 Network 09:45:09 '709704': authorized on MetaQuotes-Demo via Access Point Singapore
IR 0 Network 09:45:09 '709704': previous successful authorization performed from 77.35.11.181 on 2012.03.04 06:10:12
KP 0 Network 09:45:12 '709704': terminal synchronized with MetaQuotes Software Corp.
GI 0 Experts 09:45:12 expert Fractals_ (EURUSD,H1) loaded successfully
OI 0 Trades 10:43:29 '709704' : deal #8671794 sell 0.10 GBPJPY at 129.268 done (based on order #9494984) // this trade was executed by an Expert Advisor working on another computer
RM 0 Trades 10:51:22 '709704' : deal #8671842 sell 0.10 USDJPY at 81.586 done (based on order #9495037)// Similarly
KL 1 Network 12:00:38 '709704': connection to MetaQuotes-Demo lost// Gone
IE 0 Network 12:16:15 '709704': Authorised on MetaQuotes-Demo via Access Point Hong Kong// Came
IS 0 Network 12:16:15 '709704': previous successful authorization performed from 80.83.239.67 on 2012.03.04 23:45:03
OS 0 Network 12:16:18 '709704': terminal synchronized with MetaQuotes Software Corp.// Communication restored
IQ 0 Trades 12:18:12 '709704' : deal #8672388 sell 0.10 GBPCHF at 1.44540 done (based on order #9495596) // this trade was executed by an Expert Advisor working on another computer
DF 0 Trades 12:35:37 '709704' : instant buy 0.10 EURGBP at 0.83422 // I tried to close the position manually, before that the history was being downloaded
IN 2 Trades 12:35:44 '709704' : failed instant buy 0.10 EURGBP at 0.83422 [Request rejected due to lack of network connection] // Denied
JP 1 Network 12:35:44 '709704': connection to MetaQuotes-Demo lost
EI 0 Network 12:36:00 '709704': authorized on MetaQuotes-Demo via Access Point Hong Kong
IG 0 Network 12:36:00 '709704': previous successful authorization performed from 80.83.239.67 on 2012.03.05 02:16:12
PG 0 Network 12:36:08 '709704': terminal synchronized with MetaQuotes Software Corp.// Communication restored, further normal operation
MS

 
The log shows that before the interruption the terminal was working with one server, but after the interruption it connected to another server and started downloading history. It can be concluded that the history between different servers is not synchronised.
 
Valmars:

Yes, remembered the gist of it, there was a break in communication. It looks like the terminal starts reconciliation and history downloading only when a tick is received for the instrument, and there are no ticks at the weekend. Of course, you can update charts manually, and then the last server time will be updated. And if you want to use the automatic mode, then record a connection failure and, if it is restored over the weekend, start the check and download the history, CheckLoadHistory(). Use a timer.

...

Yes, it looks like there is a time update when the tick comes in, but the history was already there and it could be viewed visually. Thanks for the solution options. I'll try to reproduce a similar situation again before the weekend to try the solution options.
 

Connected to the AlpariFS-MT5 server to test the Expert Advisor under different conditions. The execution type was initially EXECUTION_MARKET - Execution of orders by market. I successfully opened/closed positions using my trading panels. Then I discovered that the Depth of Market was available in the context menu of the chart. I opened it and found out that it was possible to perform Buy/Sell operations. As a test, I bought a position and closed it there in the Dep th of Market. After that, the account execution type was changed to EXECUTION_EXCHANGE. This is clarified in MQL5 and there are only two options in the Order window drop-down list (F9): Exchange execution and Pending order. Trying to login again or reloading the terminal did not solve the problem. And now the execution type on the demo account still remains EXECUTION_EXCHANGE.

I contacted Alpari support, described the problem and clarified:

//---

Anatoly | 17:55
Am I correct to understand that on demo accounts for MT5 at the moment, the EXECUTION_MARKET option should be in place?

Sergey | 17:56
Yes, correct.

//---

Looks like it is a bug.

 

Some identifiers are not described in the help:

ORDER_FILLING_FOK, ORDER_FILLING_IOC and ORDER_FILLING_RETURN are there butORDER_FILLING_AON and ORDER_FILLING_CANCEL are not, although they all lead to the same list with a description.

 
tol64: andORDER_FILLING_AON and ORDER_FILLING_CANCEL are not, although they all lead to the same list with description.
They are already abolished, we will remove them from the indexes too.
 
Rosh:
They have already been abolished, we will remove them from the indices as well.

Thank you.

//---

This question has arisen. Is the contest server now available for tests with the same restrictions as on the contest(Volume Limit 15 lot / Volume Max 5 lot)? I tried to connect to the old account, but there is no connection to the server. I searched on all servers where Metatrader 5 is available for trading, but I didn't find VolumeLimit anywhere, and I need to test. Or will it be enough to answer the question, using an example with contest values:

I have an open position and its volume is 14 lots. If I try to place a pending order with a volume of 2 lots, the request will be rejected? Or, the order will be placed with the same size, but it will be partially executed, i.e. 1 lot, provided that the position stays with the same size(14 lots).

And vice versa. We have a 14 lot pending order set. If I try to open a position with 2 lots, the request will be declined?

 

I'm going to try my luck here, because there's silence on Kettles...

Please clarify:https://www.mql5.com/ru/forum/3775/page113#comment_160125. I am also interested in the software calculation of the required calculations.

 

Good afternoon.

How do I access the value of the built-in iADX indicator? Namely, to its value a given number of bars ago ? In mql4 it is done by setting the shift parameter.

Thanks already.

Документация по MQL5: Технические индикаторы / iADX
Документация по MQL5: Технические индикаторы / iADX
  • www.mql5.com
Технические индикаторы / iADX - Документация по MQL5