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
Sorry, but why shouldn't work:
So my EA is always in the while-loop and doesn't need any tick.
The whole thing around PostMessageA() was posted only as a response to the sentence "call start() from init()" earlier in this thread. I could not let this stand uncommented. "call start() from init()" is plain wrong on so many levels and therefore I had to comment on it and also provide a proper solution to achieve the same, namely forcing a call of start() from within init() even on weekends.
For the problem of starting MT4 in a disconnected state it does not provide a solution. Although I also do not understand what the use case of this might be, since it is the connection which comes and goes while metatrader itself should be easily kept running 24/7 with no interruption. And even when it is restarted at the weekend, with the PostMessageA() in init() it will immediately resume the loop in start() as soon as the connection comes back after the restart, even without a tick and then it will again keep running forever until the next (accidental) restart.
Sorry, but why shouldn't work:
So my EA is always in the while-loop and doesn't need any tick.
yep, Because you did not restart the terminal While you have no connection to the internet, but if you do restart the terminal while you don't have an Internet connection the AE does not come to the loop without one tick, no matter what you do, even if you use PostMessageA() or call Start () from init(), the only way to do this is with a script, because script's are running Regardless if tick or not
Anyway thanks everyone for trying to help. I decided to get my hands a little dirty and run an external program to run the script, end of story.
Regardless, the function IsConnected() Still makes me laugh, If such a simple thing he does not cover
The whole thing around PostMessageA() was posted only as a response to the sentence "call start() from init()" earlier in this thread. I could not let this stand uncommented. "call start() from init()" is plain wrong on so many levels and therefore I had to comment on it and also provide a proper solution to achieve the same, namely forcing a call of start() from within init() even on weekends.
For the problem of starting MT4 in a disconnected state it does not provide a solution. Although I also do not understand what the use case of this might be, since it is the connection which comes and goes while metatrader itself should be easily kept running 24/7 with no interruption. And even when it is restarted at the weekend, with the PostMessageA() in init() it will immediately resume the loop in start() as soon as the connection comes back after the restart, even without a tick and then it will again keep running forever until the next (accidental) restart.
Thanks for your interjection 7Bit, it's useful to know better methods, i have been running an EA succesfully as I described above in an attempt to solve a problem that was causing me significact issues. Terminal could regularly lose connection but for an unknown reason fail to regain it. It took me to manually rescan servers in terminal before it would re connect. Initially I just thought it a fluke of timming, but too often to be fluke, I could wait an hour, not regain connection and then the instance I clicked rescan, it would reconnect. My solution was to continuosly test connection status... if it lost connection give it 5 mins to reconnect scream form the rooftops in alers, emails and logs that it's happening and then it closes terminal and restarts. That worked in the majority of occasions. From time to time, there was a legitimate connection problem and as the EA won't initialise without connection I'm stuck in a hole. I've looked at methods to solve this all of which are methods outside MT4 and therefore outside my current IT capabilities. Fortunatley, I have moved brokers and not had any issues with my current providor... so working on this more is low on the priority list.
But it can happen that connection is lost and MT4 fails to reconnect when the connection is indeed available. A terminal restart doesn't phase my EA's, but sitting without a connection for an hour does!.
V
Fortunatley, I have moved brokers and not had any issues with my current providor... so working on this more is low on the priority list.
I have not seen this with my broker yet, so it really might happen only with some brokers. The connection is lost sometimes for a few seconds once or twice a day but always immediately reconnects.
For quickly hacking together an external application that can monitor and remote control another windows application (clicking buttons, menu commends etc.) I recommend AutoIT. Its an easy to learn BASIC like scripting language that is very centered around exactly this type of things.
I have not seen this with my broker yet, so it really might happen only with some brokers. The connection is lost sometimes for a few seconds once or twice a day but always immediately reconnects.
For quickly hacking together an external application that can monitor and remote control another windows application (clicking buttons, menu commends etc.) I recommend AutoIT. Its an easy to learn BASIC like scripting language that is very centered around exactly this type of things.
Thanks for that, I will look it up
V
the function IsConnected() Still makes me laugh, If such a simple thing he does not cover
I thought the problem was with MT4 delaying init() after a restart until it is fully connected?
What does this suddenly have to do with IsConnected()? IsConnected() seems to work as intended. It will return true when connected and false when disconnected. I don't see what is so laughable about that.
I thought the problem was with MT4 delaying init() after a restart until it is fully connected?
What does this suddenly have to do with IsConnected()? IsConnected() seems to work as intended. It will return true when connected and false when disconnected. I don't see what is so laughable about that.
because
if (!IsConnected()) should return false & As long as not coming a new tick IsConnected() can't be checked Because of this, that is why it makes me laugh
As long as not coming a new tick IsConnected() can't be checked Because of this, that is why it makes me laugh
It can be checked, just run the check in an infinite loop. how to start this loop when starting the terminal during a connection outage is a completely separate problem. Once you got your loop running it will do what is expected.
Your problem has nothing to do with the IsConnected() function. With the same argument you could also complain about Print() or Alert() or any other function that you cannot call because you could not start the entire code in the first place because of some completely different reason.