Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1292

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
Hello.
I'm a newbie, so don't scold me too much. )
https://www.mql5.com/ru/articles/100
This article gives an example of an EA which should only place a buy order if there is a buy signal and no open long positions. Similarly in the case of sell - sell conditions and no open short positions.
During the first test, we soon realized that not only one position was opened, but several positions were. The question is why?
I read the Expert Advisor's code and tried to understand and find the reason, but everything seems ok.
Hello.
I'm a newbie, so don't scold me too much. )
https://www.mql5.com/ru/articles/100This article gives an example of an EA which should only place a buy order if there is a buy signal and no open long positions. Similarly in the case of sell - sell conditions and no open short positions.
During the first test, we soon realized that not only one position was opened, but several positions were. The question is why?
I read the Expert Advisor's code and tried to understand it and find the reason.
Try to change
if(Buy_opened)
it to
The same for sell
Try replacing
to
Similarly for sale
It won't help. Read the documentation more often.
"draw a trend line, into the future"
From two points on a line, you can find the price of an arbitrary third point on that line, also in the future (and vice versa).
Hello.
Please pay attention to"Chechako ".
Need to point out errors in the code, because in the tester, EA does not open orders...
The compiler does not show any errors or warnings, the same journal shows no errors...
Hello.
I'm a newbie, so don't scold me too much. )
https://www.mql5.com/ru/articles/100
This article gives an example of an EA which should only place a buy order if there is a buy signal and no open long positions. Similarly in the case of sell - sell conditions and no open short positions.
During the first test, we soon realized that not only one position was opened, but several positions were. The question is why?
I have read the Expert Advisor's code and tried to understand it and find the reason.
I have tried to help. I am a newbie myself. Now, regarding your question. Several positions are opened because the check to open a position was performed and the check was forgotten to stop. The operator return returns control to the calling program (taken from the MQL5 Reference).
We must add return to the Expert Advisor code (highlighted in yellow):
In addition, to prevent the compiler from generating warnings, one more condition should be added in the Buy and Sell position opening conditions to check OrderSend(mrequest,mresult). This condition is defined by the if operator and should look like this
One more thing should be taken into account. Sometimes, when moving from one trading day to another at 23:59:59, an opened position closes and then, at 00:00:00, a new position opens. This is so-called rollover close and rollover open, which depends on the particular forex dealer and its trading conditions. Search the forum, there was some information about it somewhere.
Regards, Vladimir.
Hello. People need your help. I connected two zigzags with different parameters into one indicator (no errors or warnings) The problem is that the 2nd zigzag is drawn incorrectly.
Here is the code itself (MQL5)
Hello all. People need your help. I combined two zigzags with different parameters into one indicator (no errors or warnings) The problem is that 2 zigzags are not drawn correctly.
Here is the code itself (MQL5)
It all works - just fix a few digits at the top
It's all working - just fix the numbers at the top.
Thanks for the help. One more thing, why is it that one zigzag is formed as usual (maximum, minimum) and the other is only formed at the maximum.