You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Either way.
if(a==0){expression} means if a is 0 then it is true, so execute {expression}.
if(a=0){expression} is equivalent to if(a){a=0;expression} if a is true, {a=0;expression}.
The second one is wrong, it should be written like this
if(a=x) { expression } assign the value of x to the variable a, and if a is not 0 after that, then execute the expression
if(a=0) { } after optimization there will be only a=0
The second one is wrong. The correct way to write it is
if(a=x) { expression } assign the value of x to the variable a, and if a is not 0 after that, execute the expression
if(a=0) { } after optimization there will be only a=0
Sorry, that's right, expressions are executed left to right.
That's why we start with assignment, and then we check for truth.
This is roughly the case:
This code not only calculates the maximum volume but also fits it exactly into the limitations of the symbol settings.It calculates it but forgets why it calculates it when it inserts it:
The value of the lot by this point is calculated so as to consume all available margin with a minimum margin.
If this value is increased by at least a volume step, there will not be enough money to open a position.
But the second line of the cited code MAKES up the value of lot in case the condition under if is fulfilled, and can increase it by much more than the value of volume step, because in reality there are volume min = 0.1 and volume step = 0.01.
And in this code below, a division by zero may occur, against which there is no protection:
If SymbolInfoDouble() returns 0, that's it. MQL5 programs terminate on division by 0, right? It cannot return 0? People here complain that informational functions quite often return 0. You cannot fall back on "it won't return 0" because, firstly, it may, and secondly, division by 0 is fatal.
There are some lesser remarks about "accuracy of entry", but they are really not too significant, i.e. they do not have such serious consequences, you can ignore them.
Anticipating possible arguments that the code is "approximate", I note: how many users of the product are able to find and competently fix such "bad places"?
For them, this is "code from the developers". An example to look up to.
Why is the "Next" button not active when all the mandatory fields are filled in?
Why is the "Next" button not active when all the mandatory fields are filled in?
It does calculate, but then it forgets what it was calculating for:
Anticipating possible arguments that the code is "approximate", I want to point out: how many users of the product can correctly fix such "bad places"?The code was approximate (copied from two pieces), but your comments are correct.
Here is the corrected version:
And why session_index++; when session_index=1 is already false:
We can't know in advance what the number of sessions per tool is. So we query each session by number. If it is true
session_exist=SymbolInfoSessionQuote(symbol,day,session_index,start,finish);
we are interested in the time of its beginning and end. If we get false - that's it, there is no session with this number.
We cannot know in advance what the number of sessions for an instrument is. Therefore we request each session by number. If it is true
we analyze the time of its beginning and end. If we get false - that's it, there is no session with this number.
A...... then why does everything end on Friday at 24:00 and in reality at 23:00?