This code has been modified from another one. I would like to fix this code and convert it to an "indicator" instead of being an "EA" ... I hope it is not hard to do ... Also 1 important thing about it, it creates a loop in my computer that freezes not only MT4 but the whole network goes down, I am not sure what creates this loop or cause this freeze but every time I use this EA it works fine the first time but then it freezes MT4 and the network if I tried to use it again.
Thanks in advance
This code has been modified from another one. I would like to fix this code and convert it to an "indicator" instead of being an "EA" ... I hope it is not hard to do ... Also 1 important thing about it, it creates a loop in my computer that freezes not only MT4 but the whole network goes down, I am not sure what creates this loop or cause this freeze but every time I use this EA it works fine the first time but then it freezes MT4 and the network if I tried to use it again.
Thanks in advance
This code has been modified from another one. I would like to fix this code and convert it to an "indicator" instead of being an "EA" ... I hope it is not hard to do ... Also 1 important thing about it, it creates a loop in my computer that freezes not only MT4 but the whole network goes down, I am not sure what creates this loop or cause this freeze but every time I use this EA it works fine the first time but then it freezes MT4 and the network if I tried to use it again.
Thanks in advance
I think it can not be converted to an indicator.
while (index >=0 && OrderSelect (index,SELECT_BY_POS,MODE_TRADES)==true){ ⋮ if(checkOrderClose == false){ ⋮ if (errorCode …) break; else continue; } index--; }
On a non-fatal error you continue. The index doesn't change and you have an infinite loop. Replace your while loops with for loops.
if(checkOrderClose == false) { int errorCode = GetLastError(); if (errorCode == 1 || errorCode == 2 || errorCode == 5 || errorCode == 6 || errorCode == 64 || errorCode == 65 || errorCode == 132 || errorCode == 133 || errorCode == 139) break; else continue; }
Also don't post code with long lines of code, break then up as above.
Also don't post code with long lines of code, break then up as above.
I am not quite sure if I understood :)
I am not quite sure if I understood :)
You see this?
if (errorCode == 1 || errorCode == 2 || errorCode == 5 || errorCode == 6 || errorCode == 64 || errorCode == 65 || errorCode == 132 || errorCode == 133 || errorCode == 139) break; else continue;
Well on my laptop screen your line of code doesn't fit the screen. This means that I have to scroll across to read the whole line.
No problem if you keep your lines shorter.
if (errorCode == 1 || errorCode == 2 || errorCode == 5 || errorCode == 6 || errorCode == 64 || errorCode == 65 || errorCode == 132 || errorCode == 133 || errorCode == 139) break; else continue;Often I can't be bothered to read people's code when the lines are too long. I am not the only one.
You see this?
Well on my laptop screen your line of code doesn't fit the screen. This means that I have to scroll across to read the whole line.
No problem if you keep your lines shorter.
Often I can't be bothered to read people's code when the lines are too long. I am not the only one.I got you know ... sorry about this ... I think it is a simple code ... I edited it myself ...
but it creates this freeze when I use it more than 1 time :)
I have to restart computer to regain computer stability again ... any idea what creates this issue?
Thanks in advance
I got you know ... sorry about this ... I think it is a simple code ... I edited it myself ...
but it creates this freeze when I use it more than 1 time :)
I have to restart computer to regain computer stability again ... any idea what creates this issue?
Thanks in advance
William has already given you the answer in post #4
On a non-fatal error you continue. The index doesn't change and you have an infinite loop. Replace your while loops with for loops.
thank you
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use