Errors, bugs, questions - page 2021

 

Playing the bug

  1. Go to Metaquotes-Demo.
  2. Only AUDJPY is in the market overview and open its chart.
  3. Reload the terminal and wait for a full-fledged connection - quotes are coming.
  4. Run the script on the chart

void OnStart()
{  
  for (int i = 0; i < 5; i++)
    Print(SymbolInfoDouble(_Symbol, SYMBOL_TRADE_TICK_VALUE));
}


The result is as follows

2017.10.05 09:02:27.460 Test6 (AUDJPY,M1)       0.0
2017.10.05 09:02:27.460 Test6 (AUDJPY,M1)       0.0
2017.10.05 09:02:27.460 Test6 (AUDJPY,M1)       0.0
2017.10.05 09:02:27.460 Test6 (AUDJPY,M1)       0.0
2017.10.05 09:02:27.460 Test6 (AUDJPY,M1)       0.0


Restart.

2017.10.05 09:02:32.028 Test6 (AUDJPY,M1)       0.8868393047179851
2017.10.05 09:02:32.028 Test6 (AUDJPY,M1)       0.8868393047179851
2017.10.05 09:02:32.028 Test6 (AUDJPY,M1)       0.8868393047179851
2017.10.05 09:02:32.028 Test6 (AUDJPY,M1)       0.8868393047179851
2017.10.05 09:02:32.028 Test6 (AUDJPY,M1)       0.8868393047179851


I.e.SYMBOL_TRADE_TICK_VALUE returns zeros on first run if Sleep() is not used;


HI On the subject of the invisible symbol in Market Watch. If you try to open USDJPY chart (press Enter and enter "USDJPY") before the start of the script, it will not work. If after running the script it works. Although the Market Watch has not changed.

 
fxsaber:

Playing the bug

  1. Go to Metaquotes-Demo.
  2. Only AUDJPY is in the market overview and open its chart.
  3. Reload the terminal and wait for a full-fledged connection - quotes are coming.
  4. Run the script on the chart


The result is as follows


Restart.


I.e.SYMBOL_TRADE_TICK_VALUE returns zeros on first run if Sleep() is not used;


HI On the subject of the invisible symbol in Market Watch. If you try to open USDJPY chart (press Enter and enter "USDJPY") before the start of the script, it will not work. If after running the script it works. Although the Market Watch has not changed.

Add this loop to the beginning of the script

   for(int i = 0; i < SymbolsTotal(true); i++)
     Print(SymbolName(i, true));

And see how many symbols are printed.

On the first run, accessing AUDJPY only adds AUDUSD and USDJPY to the market overview and only on the second call through these pairs gets the symbol property. This is what is causing the problem with OrderCalcMargin in my case.

 
fxsaber:

It has been written about many times. They don't correct it for some reason.

Got an answer from the service desk. They will fix it.
 

Hello everyone!

Help for a beginner, please.

The function to find the price maximum is executed. How is it possible to calculate and return to the code the BAR NUMBER with a certain price maximum?

 
Alexey Viktorov:

Add a loop like this to the beginning of the script

And see how many characters are printed.

On the first run, accessing AUDJPY only adds AUDUSD and USDJPY to the market overview and only on the second call through these pairs gets the symbol property. This is what is causing the problem with OrderCalcMargin in my case.

I think it'll work out how to do that.

Anatoli Kazharski:
I received the answer from the Service Desk. They are going to fix it.

Thank you.

 

Regarding the bug "around" OrderCalcMargin() made an Application to the SR

 
Kirill Belousov:

It is hard to be sure when there is adirect contradiction in the MQL4/5 help:

...Please remember that parameters are passed backwards in the function, i.e. the last parameter is calculated and passed first, then the penultimate one, and so on. The parameter that comes first after the opening parenthesis is calculated and passed in turn.


..
.Note thatthe order of expressions x1,..., xn is guaranteed.

What is the contradiction here? It is backwards and that's it. There is no converse statement.
 
Alexey Navoykov:
What is the contradiction? It's backwards and that's it. There is no contrary statement.

- These two recommendations are in separate sections of the help.

When you read under

"Calling a function with arguments x1, x2,..., xn"

theorder of the expressions x1,....,xn is guaranteed, which order are you thinking of?

About the order x1,...,xn or about the order xn,....,x1 ?

 
Kirill Belousov:

- These two recommendations are in separate sections of the help.

When you read under

"Calling a function with arguments x1, x2,..., xn"

theorder of the expressions x1,....,xn is guaranteed, which order are you thinking of?

The order x1,...,xn or the order xn,....,x1 ?

Yes, you're right, it's confusing.

However, I think it's bad practice to lay down the logic of one's algorithm on a particular ordering of arguments in any case. All the more so when these right-to-left calculations confuse understanding of the code. That's why if you want to apply it, you should do it only in some non-critical places like printout.

 
Kirill Belousov:

The order of calculating expressions in Print() is from right to left. Sort of... Bye... Also checked it beforehand :)

MQL5 Reference\Language basics\Operationsand expressions\Other operations

Function call with arguments x1, x2,..., xn

Please note, that the order of expressions x1,..., xn is guaranteed.

It demonstrates once again the usefulness of the C++ key word inline (there was an opinion here that it is supposedly obsolete).
Among other things, inline actually means that the programmer refuses to use the order of calculating function parameters and if the compiler decides to make an inline function inline, the compiler can use the forward order of calculation as a more efficient (the reverse order of calculation is obviously efficient only for callable functions).
At the same time, if the compiler decides to embed a non-inline function, it should use the (general) reverse order of evaluation, even if this leads to a loss of efficiency (because the programmer assumed this order without having declared the function inline)

inline would also be appropriate in MQL, where the computing order cannot be controlled explicitly

Reason: