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

 
Ms fox pro, ma those were the days
 

So, I have now rebuilt the EA.

Of course it's notprofitable, but at least it's readable (for me).

Good luck with continuing with it.

Files:
 
Otto Pauser:

So, I have now rebuilt the EA.

Of course it's not profitable, but at least it's readable (for me).

Good luck with continuing with it.

THANK YOU VERY MUCH FOR THAT!

Say goodbye to my notebook-free holiday for now

 
vmajor:

Hi, I'm new, great guide, thank you!


I have a problem though. I compiled the provided example, ran through the debugger, the break points worked, resumed the debugging and I get 4756 errors on both buy and sell orders, like this:



What may be happening and what should I look into to correct this behaviour?


V.


It's a bug in the EA. Take a look at page 2 where the solution is.

Better approach: use https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade class.

Documentation on MQL5: Standard Library / Trade Classes / CTrade
Documentation on MQL5: Standard Library / Trade Classes / CTrade
  • www.mql5.com
Standard Library / Trade Classes / CTrade - Reference on algorithmic/automated trading language for MetaTrader 5
 

The EA is opening many positions both buy and sell.

best way to correct it is This: 

if(Buy_Condition_1 && Buy_Condition_2)

     {

      if(Buy_Condition_3 && Buy_Condition_4)

        {

         // any opened Buy position?

         if(Buy_opened || Sell_opened)         

           {

            Alert("We already have a open Position!!!");

            return;    // Don't open a new Buy Position

           }

---------------The same is applicable to the sell  position-----------------------


The original code under opens multiple positions:

if(Buy_Condition_1 && Buy_Condition_2)

     {

      if(Buy_Condition_3 && Buy_Condition_4)

        {

         // any opened Buy position?

         if(Buy_opened )    //Error,  should be:    if(Buy_opened || Sell_opened)   

            Alert("We already have a open Position!!!");

            return;    // Don't open a new Buy Position

           }

 
chucks4sure:

Please edit your post and use the code button (Alt + S) when posting code.

 
Could someone help me with the optimisation of the EA?
What start, end and step values do I use?
Can I use genetic optimisation?
 
Since more people are coming here, good article, good work))))) Question, is it correct in the article to calculate the order opening price, stoploss and take profit for buy from ask price, for sell from bid price? It seems to be correct for buy order opening price - ask, but stoploss and takeprofit are calculated from bid price? After all, the buy order closes at the bid price. I apologise for my Russian in terms.
 
VikMorroHun:


It's a bug in the EA. Take a look at page 2 where the solution is.

Better approach: use https://www.mql5.com/en/docs/standardlibrary/tradeclasses/ctrade class.



I'v got 4756 error, I saw the solution in page 2, and I checked orginal code, there was ZeroMemory(mrequest); in line 218 itself. but I have still the error 4756. 

 
wefgoncalves:
Could someone help me with optimising the EA?
What start, end and step values do I use?
Can I use genetic optimisation?

Hello my friend, I'm a beginner too but there's a YouTube channel that has helped me a lot with optimisation, the Vilela channel!

I've found a lot of useful stuff there with excellent teaching. Can I chat to you so we can exchange experiences?
good studies!!!