Presenting the book "MQL5 Programming for Traders" - page 2

 
MetaQuotes #:

Author recommends useless ideas from 1990.

MQL5 compiler extremely efficient and most of the old tricks absolutely useless now.
That is a plausible answer.
Thanks 
 
Dr Matthias Hammelsbeck #:

Hi,

very good book, very helpful. 

Nevertheless I have one question: in chapter "Increment and decrement" you write:

Postfix form may be useful for more compact writing of expressions combining a reference to the preceding value of the operand and its side modification (two separate statements would be required to make an alternative record of the same). In all other cases, it is recommended to use the prefix form (it does not create a temporary copy of the "old" value).


But in some header files in MQL5/Include/MQL5Book you are using the postfix form in for - loops and not the prefix form:

Why not the prefix form? I do not understand.

Matthias

You can find a lot discussions of the matter in the net. Just to recap:

If you do not need the previous value, make it a habit to use pre-increment. Being consistent even with builtin types, you'll get used to it and do not run risk of suffering unecessary performance loss if you ever replace a builtin type with a custom type. On the other hand, the tradition developed of using post-increment when the expression value is not used, especially in for loops. Some find post-increment easier to read, since the "subject" (i) precedes the "verb" (++), just like in English, and as in C++ name itself.

 

Hi,

I cannot emphasize enough: the book is very helpful!

Nevertheless today I stumbled over a strange behaviour of the strategy tester when I simply include the file  MQL5Book/PositionMonitor.mqh into a mini expert advisor:

#include <MQL5Book/PositionMonitor.mqh>
int OnInit() {
   return INIT_SUCCEEDED;
}


Starting this EA in the strategy tester I get the following message/warning:

2024.01.06 15:58:49.521 2023.11.27 00:00:00   Unresolved int value as enum: 8 for MonitorInterface<ENUM_POSITION_PROPERTY_INTEGER,ENUM_POSITION_PROPERTY_DOUBLE,ENUM_POSITION_PROPERTY_STRING>::TradeState

Strange?? Can somebody help?

Matthias

BTW: I'm using Metatrader Build 4040

 
Dr Matthias Hammelsbeck #:

Hi,

I cannot emphasize enough: the book is very helpful!

Nevertheless today I stumbled over a strange behaviour of the strategy tester when I simply include the file  MQL5Book/PositionMonitor.mqh into a mini expert advisor:


Starting this EA in the strategy tester I get the following message/warning:

Strange?? Can somebody help?

Matthias

BTW: I'm using Metatrader Build 4040

That's normal. This is just a warning saying that the numbering of constants in the built-in enums have a gap. This happened due to historical reasons (after some MQL5 updates, which excluded old constants not used anymore), and do not produce any negative effect.

 
Thank you to Stanislav Korotky and MetaQuotes for releasing the 'MQL5 Programming for Traders' book. It's a fantastic resource for traders and programmers alike. Greatly appreciated!
 
Thanks Stanislav Korotky for the detailed book.
I liked your clear explanation about floating point numbers format and the related mathematical functions provided by the platform. 

 
Dr Matthias Hammelsbeck #:

Can I download this book as pdf file?

You can now download the book as a single file (PDF or CHM, at the moment). The links are shown in the left-side panel under the list of topics.

MQL5 Programming Book PDF and CHM

 
Stanislav Korotky #:

You can now download the book as a single file (PDF or CHM, at the moment). The links are shown in the left-side panel under the list of topics.


That is great! Thank you

 
Dr Matthias Hammelsbeck #:

Hi,

I cannot emphasize enough: the book is very helpful!

Nevertheless today I stumbled over a strange behaviour of the strategy tester when I simply include the file  MQL5Book/PositionMonitor.mqh into a mini expert advisor:


Starting this EA in the strategy tester I get the following message/warning:

Strange?? Can somebody help?

Matthias

BTW: I'm using Metatrader Build 4040

Also getting this now. I cant run this in Strategy Tester, but running it on the charts are fine

This was still working last year

How do we fix this?

 
Alister John Witbooy #:

Also getting this now. I cant run this in Strategy Tester, but running it on the charts are fine

This was still working last year

How do we fix this?

What's your problem exactly? The post you quoted is about unimportant warning (due to changes in MQL5) which does not affect EA work - both tester and online runs should be ok.

Reason: