Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6. - page 9
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
You could write if((b-a)*(c-a)*(d-a)>0), but not necessarily faster. Logical AND is binary multiplication, it's just another notation of the same expression, the only difference is the size of the variable types. a>b is a boolean variable, 4 bytes, and b-a, if they are double, the difference will be double (8 bytes), and this multiplication is at least 2 times longer.
Invaluable advice.
Let me explain. You can rewrite your expression as if(((a>b)*(a>c)*(a>d)==1), because expressions in brackets take values 0 or 1 (and they, in turn, are defined in define in the precompiler as false and true).Thanks - I think this will work faster
Guys, please advise.
In strategy test mode, I can't change the numbers in the optimisation properties:
Minimum balance 200
Maximum profit 10000
etc.
What is the problem?
Can you tell me what values can return init, start and deinit and what do they mean?
I tried to search through the forum but couldn't find it. There is no this information in the Handbook. Probably, it is the confidential information. : )))(Emotional text deleted... )
As I'm guessing - "0" - it all went well... But, as their type is interger, apparently there can be more than just 2 values...
Can you tell me what values can return init, start and deinit and what do they mean?
I tried to search through the forum but couldn't find it. There is no this information in the Handbook. Probably, it is the confidential information. : )))(Emotional text deleted... )
As I'm guessing - "0" - it all went well... But, since their type is interger, apparently there can be more than just 2 values...
This has been discussed quite recently. Reference:
There are 3 functions with predefined names in MQL4:
init() - function called during module initialization. If it is missing, no function is called during initialization.
start() - the main function. It is called at the Expert Advisors after the receipt of the next tick. For custom indicators it is called during the recalculation after the indicator is attached to the chart, when the client terminal is opened (if the indicator is attached to the chart), and also after the coming of the next tick. In scripts it is executed immediately after attaching to the chart and initialization. If there is no start() function in the module, this module (Expert Advisor, script or custom indicator) cannot be launched.
deinit() - the function that is called during the module deinitialization. If it is absent, no function is called during deinitialization.
Predefined functions can have parameters. However, when these functions are called by the client terminal, no parameters will be passed from the outside, but the default values will be used.
The start(), init() and deinit() functions can be called from anywhere in the module according to the general rules, along with other functions.
It is not desirable to call start() or trade from the init() function, because at the moment of module's initialization chart data, market prices, etc. may not be ready. The init() and deinit() functions should terminate their work as quickly as possible and in no case get stuck trying to start full operation before the start() function is called.
OK, then I'll try to clarify the question.
For example, I want to check some parameters at initialization stage and depending on result: either pass to Start stage or not.
If I understood your comment correctly, Vadim, then initialisation result will not matter (in this case) and function Start will be started?
then you need to call the init from the start.
Why do you have to go through all this trouble? Global variables have not been cancelled yet...
Ok, then I'll try to clarify the question.
For example, I want to check some parameters at initialization stage and depending on result: either pass to Start stage or not.
If I understood your comment correctly, Vadim, the result of initialization would not matter (in this case) and the Start function would be started?
Rustam replied:
then you have to call the init from start yourself.
Why such a complication? Nobody cancelled global variables yet...
Rustam replied:
You declare the variables globally and initialise them as needed. All functions in one module can see the global variables.Yes, unless it's a check to restrict access to the program, for example.
then you need to call the init from the start.
Why do you have to go through all this trouble? Global variables have not been cancelled yet...
Wouldn't it be easier to check with a flag? Of course...
Wouldn't it be easier to check it with a flag? Certainly global...
No, it is not easier. Because if there was a negative flag (or a global variable), the check still needs to be run. Both the flag and the global variable will only work in the positive case. And some functions are still needed at start (although, it's different here).
Whichever way you look at it, start anyway: either via redo of "inite", which is just as annoying, or via redo of required functions.