
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
No! OnTrade is also only available on MQL5.
In MQL4, "loops" are the only way, unless you track your own data.
No! OnTrade is also only available on MQL5.
In MQL4, "loops" are the only way, unless you track your own data.
Interesting. Yes, I'm normally good at finding a solution, hence I seldom need to ask on here, but this has had me stumped. A few other people have suggested to use the
break;
after the function, but no dice. The trouble is, the result is the #4025 (Out of Memory) error, which isn't ideal. I completely get why it's doing what it's doing, it's just my lack of knowledge. If I do find solution, I'll post it on here so others can see.
No! OnTrade is also only available on MQL5.
In MQL4, "loops" are the only way, unless you track your own data.
Mql4 is such a waste of time.
But I can think on many ways without loops, even without OnTrade.
By loops I mean, doing them at each tick.
Interesting. Yes, I'm normally good at finding a solution, hence I seldom need to ask on here, but this has had me stumped. A few other people have suggested to use the
after the function, but no dice. The trouble is, the result is the #4025 (Out of Memory) error, which isn't ideal. I completely get why it's doing what it's doing, it's just my lack of knowledge. If I do find solution, I'll post it on here so others can see.
I don’t understand why it has to be so complicated. One side saying it’s a “waste of recourses” but clearly you are doing it for educational purposes. The other side is saying mlq4 is a waste of time. No chance for newbies to understand properly, no wonder why many get put off.
I know, there'll always be a divide. I'll listen to anyone on here & give anyone the opportunity to contribute their knowledge. It may be helpful or it may not be.
However, thank you for this, I'll give this a go and I'll report back on here.
Ciao ciao!
Yep, I've changed this to a continue and it's still looping crazy, this s why this is infuriating me.
...
I am now going to walk away from this for a few hours because I can feel my blood pressure rising. I will circle back to this later.
Hello,
Yes I understand because programmers must have experienced that.
so I want to help by giving you a little clue.
Actually, your EA has done its job exactly according to the logic you wrote in the algorithm.
including the repeated printing of :
.. was correct and it should have repetition as such.
I can't expect results outside of the algorithm we write in the program.
- by this way - you will definitely get a solution faster.
What can I expect from your code here :
(edit: I'm worry that you feel the code has 1 loop in for() only).
1.1. The 1st. loop is OnTick(), and the 2nd. loop is for().
1.2. The process in the second loop will be executed at every tick change.
- - - (This method will burden the computer.)
1.3. What if the process in the second loop hasn't ended but the tick value has changed rapidly?
- - - You've seen the 'out of memory'.
(which means that there are trade positions) then the process enter the second loop
- and display a message by Print();
- the EA will always return to the first loop 'OnTick()' and immediately - re-enter the second loop again.
We can't deny that result, because it's the result it should be.
My conclusion, it looks like you want to create 1 EA that manages trading positions
of various _Symbols and magic numbers simultaneously.
Unfortunately you will have to find another way to read those trading positions properly.
In such a situation, I would use OnTimer() instead of OnTick(),
and combined with each new bar change.
Feel free to experiment through different processes across multiple loops in OnTimer().
I am sure you will like it :)
Kind regards,
Yohana
If you are wanting to break out of a loop when ever a condition fails, then use "break" ...
I don't agree with your "Period" usage for Magic Number, but I have left it in there anyway.
EDIT: Please note that the above is only for explaining the functionality of the "break". As for your overall logic, I don't quite understand what you are trying to achieve so I have not tackled that. Only the "break".
If you are wanting to break out of a loop when ever a condition fails, then use "break" ...
I don't agree with your "Period" usage for Magic Number, but I have left it in there anyway.
EDIT: Please note that the above is only for explaining the functionality of the "break". As for your overall logic, I don't quite understand what you are trying to achieve so I have not tackled that. Only the "break".
Thanks Fernando,
Yes, that's fair enough. The //Do a function is actually a Chart Button through the ObjectCreate() function, to close any open position but the button itself wasn't relevant for this particular topic and forum guidelines state to only keep to the relevant bits of the code to other don't have to look for this.
The button itself is fine, but the reason for the For(..) Loop originally was;
However, I have come up with a solution which no longer uses the For(..) loop feature when the button is implemented on the chart, so as promised I will post on here shortly. Feel free to weigh in if you wish to.
Hello,
Yes I understand because programmers must have experienced that.
so I want to help by giving you a little clue.
Actually, your EA has done its job exactly according to the logic you wrote in the algorithm.
including the repeated printing of :
.. was correct and it should have repetition as such.
I can't expect results outside of the algorithm we write in the program.
- by this way - you will definitely get a solution faster.
What can I expect from your code here :
(edit: I'm worry that you feel the code has 1 loop in for() only).
1.1. The 1st. loop is OnTick(), and the 2nd. loop is for().
1.2. The process in the second loop will be executed at every tick change.
- - - (This method will burden the computer.)
1.3. What if the process in the second loop hasn't ended but the tick value has changed rapidly?
- - - You've seen the 'out of memory'.
(which means that there are trade positions) then the process enter the second loop
- and display a message by Print();
- the EA will always return to the first loop 'OnTick()' and immediately - re-enter the second loop again.
We can't deny that result, because it's the result it should be.
My conclusion, it looks like you want to create 1 EA that manages trading positions
of various _Symbols and magic numbers simultaneously.
Unfortunately you will have to find another way to read those trading positions properly.
In such a situation, I would use OnTimer() instead of OnTick(),
and combined with each new bar change.
Feel free to experiment through different processes across multiple loops in OnTimer().
I am sure you will like it :)
Kind regards,
Yohana
Hi there,
Thanks for taking the time to comment.
You've no need to worry, I'm well aware that the loop is for every tick, not just the one :)
Secondly, I'm not saying the EA is incorrect, I appreciate that this is down to my lack of knowledge and whilst I have been self-taught, have been coding for a number of years and do have a fully functioning EA, this particular feature is new so it's learning curve again. However, I have found a solution which I will post on here shortly. Feel free to weigh in if you wish.
All the best :)
Essentially, if result = true, the EA will insert a button, and start calling the functions from the top o the OnTick section so you have the running order profit/loss for that position, plus it changes colour from red to green (or vice-versa) if you go from loss to profits (or vice versa).
Feel free to feedback/discuss if you have a more efficient way of doing this, but obviously no obligation.