Zhunko: This is passing the parameter by reference. No one is stopping you from calling init() where you want it, according to your condition.
Then again we must solve the issue of control of this moment. After all, in order to know "where it should be", you need to know it. And you can find it out through a flag, for example. It turns out, for example, that flag will be in global:
gInitTrue = false;
In init(), assign a value at the very end of the function:
gInitTrue = true;
And we will control the start at the very beginning of the function:
if (gInitTrue != true)
init();
Am I understanding this correctly? Or is there something else to consider?
But more to the point? It's been discussed that INIT can fail in case of, for example, disconnects or other similar situations. Because it does not re-initialise the data itself afterwards, in case of contingencies, and it only runs once! So, this is not quite a correct way of doing it.
There is no time limit for init(), theoretically calculations may run for several seconds/minutes. It doesn't make sense to break a connection here. I.e., owl has been launched on a chart -> a tick has come -> calculations in init() have started (at this time there may be many ticks or a connection failure) -> the Expert Advisor for the first operation start() and so it is waiting for a new tick.
how should the code be correctly written so that if the specified stop loss or take profit is less than the minimum stop, then make them equal and use the stops as the minimum stop. ?
webip: how should the code be correctly written so that if the specified stop loss or take profit is less than the minimum stop, then make them equal and use the stops as the minimum stop. ?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
hoz:
It's the same as:
I can't figure out how to implement the logic with the least amount of effort.
If(...) set a stop order;
If(the order's lifetime>time) withdraw the order, and if(...) set a new order;
The difficulty is that there may be several positions which are already open, and how do we fight them all? What is the easiest way?
Thank you!
This is passing the parameter by reference.
No one is stopping you from calling init() where you want it, according to your condition.
Then again we must solve the issue of control of this moment. After all, in order to know "where it should be", you need to know it. And you can find it out through a flag, for example. It turns out, for example, that flag will be in global:
gInitTrue = false;In init(), assign a value at the very end of the function:
gInitTrue = true;And we will control the start at the very beginning of the function:
Am I understanding this correctly? Or is there something else to consider?But more to the point? It's been discussed that INIT can fail in case of, for example, disconnects or other similar situations. Because it does not re-initialise the data itself afterwards, in case of contingencies, and it only runs once! So, this is not quite a correct way of doing it.
how should the code be correctly written so that if the specified stop loss or take profit is less than the minimum stop, then make them equal and use the stops as the minimum stop. ?
Can you tell me a little code? Opened file.... Which function can be used to write a recording, save it and then close it...
https://docs.mql4.com/ru/files
Can you tell me a little code? Opened file.... What functions can be used to write a record, save it, and then close it...