Discussion of article "Step-by-Step Guide to Writing an Expert Advisor in MQL5 for Beginners" - page 28

 
MrBrooklin #:

Hello, Rustam! I attach a working version of this EA at the bottom of the message. The changes have been made to this code section:

What is highlighted in yellow colour has been added:

and also removed the condition related to Buy_opened and Sell_opened:

Regards, Vladimir

MrBrooklin #:

Hello, Rustam! I attach a working version of this EA at the bottom of the message. The changes have been made to this code section:

What is highlighted in yellow colour has been added:

and also removed the condition related to Buy_opened and Sell_opened:

Regards, Vladimir.

Hello Vladimir ! The attached file does not work for some reason, I will try to insert your codes into the Expert Advisor, we'll see.

Regards, Rustam.

It worked in the tester, just something must have updated again with the operating system and inserted just classically, without its local peculiarities) Look.
 
Rustam Ayupov #:

Hello Vladimir ! The attached file does not work for some reason, I will try to insert your codes into the EA, we'll see.

Regards, Rustam.

Hello, Rustam! I checked the EA file on two different terminals. Everything works. You can see it on the bottom picture. Try to run visual testing and go to the Journal tab. If there will be messages with red circles, copy them and post them here on the forum.

Regards, Vladimir.



 
MrBrooklin #:

Hello, Rustam! I checked the EA file on two different terminals. Everything works. You can see it on the bottom picture. Try to run visual testing and go to the Journal tab. If there will be messages with red circles, copy them and post them here on the forum.

Regards, Vladimir.



Hello Vladimir ! Your file worked, in the tester, just something to see something updated again with my operating system and inserted just classically, without its local peculiarities) Look.

And in the demo worked) Now optimising, very extreme).

Regards, Rustam.

 
Rustam Ayupov #:

Hello Vladimir ! Your file worked, in the tester, just something to see something updated again with my operating system and inserted just classically, without its local peculiarities) Look.

Regards, Rustam.

Based on my personal experience, I can highlight the main thing in self-learning MQL5 language:

  1. Until you start writing codes on your own, even short and simple scripts, you will never get anywhere.
  2. Be sure to leave comments to the lines of code you will write. This will make it easier to understand the code you will write right now.
  3. You need to understand what functions are used for and learn how to write them.
  4. Be sure to study and use the MQL5 Reference Manual
Regards, Vladimir.
 
MrBrooklin #:

Based on my personal experience, I can highlight the main thing in self-study of MQL5 language:

  1. Until you start writing codes on your own, even short and simple scripts, you will never get anywhere.
  2. Be sure to leave comments to the lines of code you will write. This will make it easier to understand the code you will write right now.
  3. You need to understand what functions are used for and learn how to write them.
  4. Be sure to study and use the MQL5 Reference Manual
Regards, Vladimir.

I understand everything, I agree with you 100%, I read all your materials that I have found and along with references to the MQL5 Reference Manual, I look at the published C++ courses. The authors of MQL5 have spoken about using another language Python in their MT5 terminal programme, apparently for the sake of its (very slow) "crazy", recently "crazy" speeds, fantastic, but not soon. After realising that FXopen broker lagged behind MT5 news and therefore created errors, did not execute the MQL5 class line, I removed it from the set of my brokers, I am still watching the others, there are similar debates of forum members on the forum and more brokers. But it became clear that it's high time to update everything left from the past skills and add a lot of news, as I realised, both with the terminal and with the editor. I have saved an online C++ compiler for the future, and we will test the MT5 terminal editor with it. First of all, I want to understand the safety net of huge take profit of the optimised Expert Advisor, trailing or according to the author's declaration to close positions after price reversal. I build all my programming from the necessary now, if the Expert Advisor will work, and it will, I have not yet met the best strategy algorithm, and on the market since the time of MT3) but then all the comprehension of the huge MQL5, the whole, which is from C++, apparently pointless ? The F1 guide works quite well. Sorry for the long speech)

I found a manual trailing, right on the chart, to see if it will follow the price ? It's not a stoploss.

THANK YOU !

Regards, Rustam.

 

Hi Samuel. Very good article. At the end you mentioned there are many aspects to consider in order to improve results that were not included. Could you mention those aspects or technics that are missing, just a guide for studying.

Many thanks. 

 
My greetings to you. Your article is very interesting, thank you very much, I am a beginner and I learned a lot from your article.

However, I have a problem with my code. I tried a little to modify the code at my level according to the MQL5 reference. 

I receive alerts notifying me of errors :

(control on lines 138, 169 in my code )  : My_First_EA (EURUSD DFX 10 Index,M1) OrderSend error 4752

(control on line 142 in my code )  : My_First_EA (EURUSD DFX 10 Index,M1) Alert: The Buy order request could not be completed - error:4752
(control on line 173 in my code )  : My_First_EA (EURUSD DFX 10 Index,M1) Alert: The Sell order request could not be completed - error:4752


I tried to know about this type of error but I do not find how to correct it. Thank you for kindly helping me.

Files:
My_First_EA.mq5  12 kb
 

Try to understand the new code. The code works for now.
Unfortunately, the EA opens more positions when some are already open.
Where is the error?

Thank you for your help

 
Mario31415927 #:

Try to understand the new code. The code works for now.
Unfortunately, the EA opens more positions if there are already some open.
What is the error?

Thank you for your help

I don't know now - but try to find out for yourself:

  1. Place break points (F9 or DebugBreak()) when the EA would open the new position.
  2. Then you can check the variables in the debug window and see why, despite the position, another ...
 
Mario31415927 #:

Try to understand the new code. The code works for now.
Unfortunately, the EA opens more positions if there are already some open.
What is the error?

Thank you for your help

Probably because you are not asking whether a position is already open or not. If you don't do this, it opens as long as the condition is met