Questions from Beginners MQL5 MT5 MetaTrader 5 - page 282
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
amavladi:
I want to understand the mechanics of loops so I can write a complex EA. The operator "return" throws me to a new "start" I do not always need it.
Thanks for the reply anyway.
You're welcome. The point is that if you want to understand the "mechanics" with the help of "third parties", then you need to formulate the problem to those very "third parties", i.e. describe what you would like to get from the algorithm, not what you got.
"The loop loops" is not a problem, because if there is nothing in the loop except the continue operator, then it is bound to loop until the loop condition becomes false.
I.e., you should not ask silly questions like: "what doesn't work in non-working code". After all, even a drunken hedgehog knows that non-working code doesn't work because it's non-working. But no one without telepathic powers, except the author of the code, can understand what should have worked in the working code.
HELP!
I am looking for good people on this site, please advise me of my mistakes. I just started to learn MQL4and wrote a simple Expert Advisor that opens an order and then closes it with a smalltakeprofit.I tried to check it in strategy tester and found out that my for and while statements loop gets looped if written like this:
//--------------------------------------------------------------------
while (Ask<=Level)
{ RefreshRates();
continue;
}
Well here everything seems to be simple.
The strategy tester generates a tick, calls start() and waits until this function finishes to generate the next tick.
So, if you want your robot not to hang in the tester, get away from such a construction. In your case, the Ask price will not change until it exits from start().
And when the return command is received, the function start will terminate, and the tester will understand that the next tick should be generated.
Moreover, not in the strategy tester, but in the real mode, your code will work as you expect, because RefreshRates will update the Ask price.
Your code works fine, but for the strategy tester it enters an infinite loop.
Using return will help here. When you gain more experience you will get rid of such constructions. Good luck to you.
That is, you should not ask silly questions like "what doesn't work in non-working code". After all, even a drunken hedgehog knows that non-working code does not work because it does not work. But no one without telepathic powers, except the author of the code, can understand what should have worked in the working code.
You're welcome. The point is that if you want to understand the "mechanics" with the help of "third parties", then you need to formulate the problem to those same "parties", i.e. to describe what you would like to get from the algorithm, not what you got.
"The loop loops" is not a problem, because if there is nothing in the loop but the continue operator, it is bound to loop until the loop condition becomes false.
I.e., you should not ask silly questions like: "what doesn't work in non-working code". After all, even a drunken hedgehog knows that non-working code doesn't work because it's non-working. But no one without telepathic powers, except the author of the code, can understand what should have worked in the working code.
I don't like it when newbies get a lot of dirt thrown on them.
A pig finds dirt everywhere © Folk proverb
Where did you find the dirt? If you found it, ask a moderator.
Does the metaphor of the drunken hedgehog bring any positivity to the problem?
Ask the administration to add a ban on metaphors and hedgehogs to the rules.
A pig finds dirt everywhere © Folk proverb
Where did you find the dirt? If you find it, go to a moderator.
Ask the administration to add a ban on metaphors and hedgehogs to the rules.
And why moderators and admins... It's a matter of breeding, professional ethics, tact, tolerance, humanity in the end... ...admins can't help.
And if you don't fully understand the problem, you'd better not give advice... Sometimes it's better to chew... Although showing off at the expense of others is your right...
It's all about upbringing, professional ethics, tact, tolerance, humanity in the end...
Mm-hmm. The kindergarten and the noblewomen's institute all rolled into one.
So why don't we skip the personal stuff and keep answering questions from the newbies? Otherwise, we get a kind of fluderasty from supporters of humanitarian approaches in a purely technical topic.
P.S. For "third-party" admirers of the expressions: drunken hedgehog, screwball, fluderasty and so on. (although we are in a purely technical topic), allow myself to give a little reference to Fyodor Mikhailovich Dostoyevsky, who in his novel "The Idiot" through Prince Myshkin says a very strange thing: "Beauty will save the world! And to you Eugene, I beg you to say hello to Moldova, even though I live in another country, but I was born in Kishinev.
There's no telepathic thing )))) I think everyone has made the same mistakes when they want to "catch" a price for, say, a trawl... including me about 6 years ago.
By the way, the topic is for newbies and it's not "strictly technical".
I'll say hello.
Good luck.
There's no telepathic thing )))) I think everyone has made the same mistakes when they want to "catch" a price for, say, a trawl... including me about 6 years ago.
By the way, the topic is for newbies and it's not "strictly technical".
I'll say hello.
Good luck.
About telepathy and "purely technical" - I am for Mr.Reshetov: ))).
Good luck to you too.