Errors, bugs, questions - page 2936

 
x572intraday:

Result:

What is the odd unsettled number? Not found or googled in Help. Doesn't look likeEMPTY_VALUE.

Some kind of rubbish.

Set value

int Arr[1]={0};
 
Vitaly Muzichenko:

Some rubbish

Set the value.

Not for practice, but purely out of theoretical curiosity. Another number (9xxx - I can't remember exactly) looked more like rubbish and appeared only once and couldn't reproduce it anymore, while the number above was constant and repeated from time to time. (I wonder if it is the same for you and others?) I don't care about it, the main thing is that other programmers don't stumble over it painfully.

 
x572intraday:

It wasn't for practice, but purely out of theoretical curiosity. Another number (9xxx - I don't remember exactly) was more like rubbish and it appeared only once and could not be reproduced anymore, while the number above was constant and repeated from time to time. (I wonder if it's the same for you and others?) I don't care about it, the main thing is that other programmers don't stumble over it painfully.

I have "0", checked it several times

 
Vitaly Muzichenko:

I got a 0, checked several times.

Hmm... I don't know how one circumstance relates to the other, but I ran it as an indicator on different currency pairs - numbers are climbing differently (on each instrument the same number is repeated with each tick ), there was even a zero. It is strange. But it looks like without initialising with its own number it really is rubbish.

 
x572intraday:

Hmm... I don't know how one circumstance relates to the other, but I ran it as an indicator on different currency pairs - numbers are climbing differently (on each instrument the same number is repeated with each tick ), there was even a zero. It is strange. But it seems that without initialising with its own number it really is rubbish.

Re-checked it again by inserting the code by ticks

in mt4 it's always 0.

in mt5 yes, 0 is extremely rare, the number is 511026368

 
x572intraday:

Hmm... I don't know how one circumstance relates to the other, but I ran it as an indicator on different currency pairs - numbers are climbing differently (on each instrument the same number is repeated with each tick), there was even a zero. It is strange. But it seems that without initialization with its own number it really is rubbish.

The array (and all the other variables) is allocated memory when creating it. If the array is not initialized, whatever is left there from past uses=trash.

If you don't change values from the program, nothing happens to this memory, rubbish keeps its value.

In MT4, all variables and arrays are forced to be initialized with zero.

 

CExpert.TradeEventOrderTriggered() not called

When working with FORTS market, BCS-Demo server, some instability of CExpert.TradeEventOrderTriggered() call has appeared when pending orders are triggered.
The code of the CExpert::CheckTradeState method of the MQL5 standard library doesn't take into account possible asynchronous reception of information about positions, orders, deals and history.

1446://--- check triggering of a pending order
1447:   if(hist_ord_tot==m_hist_ord_tot+1 && ord_tot==m_ord_tot-1)
1448:     {
1449:      //--- triggering of a pending order
1450:      if(deal_tot==m_deal_tot+1)

When the code is executed on historical data, the conditions work correctly. When working with real data, there might be situations where the information about changes of positions, deals, orders, and history is not obtained at the same time, and the order in which the information is obtained is random.

Log of calls of the bool CExpert::CheckTradeState(void) method. One call ofCheckTradeState() corresponds with 2 lines " CheckTradeState: .....".

//Сработал отложенный ордер открытия позиции
CheckTradeState: hist_ord_tot = 613 ord_tot = 0 deal_tot = 544 pos_tot = 1
CheckTradeState: m_hist_ord_tot = 613 m_ord_tot = 1 m_deal_tot = 543 m_pos_tot = 0
CheckTradeState: hist_ord_tot = 614 ord_tot = 1 deal_tot = 544 pos_tot = 1
CheckTradeState: m_hist_ord_tot = 614 m_ord_tot = 1 m_deal_tot = 544 m_pos_tot = 1

//Сработал отложенный ордер открытия позиции 
CheckTradeState: hist_ord_tot = 615 ord_tot = 1 deal_tot = 546 pos_tot = 1
CheckTradeState: m_hist_ord_tot = 615 m_ord_tot = 1 m_deal_tot = 545 m_pos_tot = 0
CheckTradeState: hist_ord_tot = 615 ord_tot = 0 deal_tot = 546 pos_tot = 1
CheckTradeState: m_hist_ord_tot = 615 m_ord_tot = 1 m_deal_tot = 546 m_pos_tot = 1
CheckTradeState: hist_ord_tot = 616 ord_tot = 0 deal_tot = 546 pos_tot = 1
CheckTradeState: m_hist_ord_tot = 616 m_ord_tot = 0 m_deal_tot = 546 m_pos_tot = 1

You can see from the log:
1. When a pending order triggers, the history length is updated later than the information about deals, orders and positions, which leads to failure to meet the 1st condition in the code.
2. Possible unsynchronization of receiving information about changes in the number of orders, deals and positions, which leads to the impossibility to meet the 2nd condition in the code (if you can somehow bypass the first problem and perform the first if). Perhaps this desynchronization occurred when an order was executed in 2 steps (in parts: 1 lot+1 lot), but in that case why the number of deals +1, and not +2.

I got stuck with this code:

//--- establishment of the checkpoint history of the trade
   bool isSyncMode = MQLInfoInteger(MQL_TESTER) || MQLInfoInteger(MQL_OPTIMIZATION) || MQLInfoInteger(MQL_VISUAL_MODE);
   if(!isSyncMode)
      HistorySelect(m_beg_date,TimeCurrent());
   else
      HistoryPoint(true);
//---
   return(res);

The point of the block: if in asynchronous mode we have got to the end of procedure, that is possible when history is not loaded, we fetch history, but we don't memorize values of orders quantities, etc.

P.S. It seems that this part of the standard library is underdeveloped. Especially disconcerting is a code fragment written 3 times in a row.

1458: res=TradeEventOrderTriggered();
1459: //--- establishment of the checkpoint history of the trade
1460: HistoryPoint(true);
1461: return(res);

I am writing here hoping that the problem will be noticed and something will be corrected somewhere.

Документация по MQL5: Стандартная библиотека
Документация по MQL5: Стандартная библиотека
  • www.mql5.com
Стандартная библиотека - Справочник MQL5 - Справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
Looked at the size of EX5 EA files in the Market. All the ones I've looked at are under 200 Kb. What makes you achieve such small sizes? A simple code?
 
fxsaber:
I have looked at the sizes of EX5 Expert Advisor files in the Market. All of them are smaller than 200 KB. What allows you to achieve such a small size? A simple code?

I think the authors are geniuses, 90% of top sellers have no questions about the platform at all - so they write the codes with a natural instinct ))))


here's the question:

I'm plugging in data:

#resource "Common\\Files\\EURUSD_tick.bin" as const MqlTick HistoryData[]

I get an error:

resource file 'Common\Files\EURUSD_tick.bin' not found

cannot open resource file .....\\\\MQL5\Experts\Virtual\Common\Files\EURUSD_tick.bin' (3)

If I place the file in the folder EA or in the Files folder, everything is OK.


Is it possible that the resource cannot be mounted from the Common folder? -Or do I need to specify another path?

 
Igor Makanu:

I think the authors are geniuses, 90% of the top sellers have no questions about the platform at all - so they write the codes with innate knowledge ))))

For questions other accounts.

You can not connect the resource from the folder Common? -or do you need another way to prescribe?

I do not know.

Reason: