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

chucks4sure
31
chucks4sure  

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

           }

Keith Watford
Moderator
26567
Keith Watford  
chucks4sure:

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

Boob Wood
175
Boob Wood  
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. 

louisd
6
louisd  

Hi All,

Brand new to MQL5 (and FOREX for that matter) but, long time programmer. I opened the My_First_EA.mq5 file and compiled but, I'm not getting the Debug functions. If I open any of the example script files I do get the Debug option. Also received a warning return value of 'OrderSend' should be checked. What do I have to do to get Debug functionality?

Louis

louisd
6
louisd  
louisd:

Hi All,

Brand new to MQL5 (and FOREX for that matter) but, long time programmer. I opened the My_First_EA.mq5 file and compiled but, I'm not getting the Debug functions. If I open any of the example script files I do get the Debug option. Also received a warning return value of 'OrderSend' should be checked. What do I have to do to get Debug functionality?

Louis

Hi All,

Figured out my own issue. I created a new Project with the Expert Advisor Wizard and then just copied in the My_First_EA.mq5 file and I get debug functionality.

Louis 

surfdoode2
6
surfdoode2  
louisd:

Hi All,

Figured out my own issue. I created a new Project with the Expert Advisor Wizard and then just copied in the My_First_EA.mq5 file and I get debug functionality.

Louis 

But have you fixed the 'OrderSend should be checked' warning?
surfdoode2
6
surfdoode2  
Boobwood:

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. 


I also still have this error having made both suggested corrections:

ZeroMemory(mrequest);

and also

if(Buy_opened || Sell_opened)

Please can someone help with the error 4756? It just seems unable to place a Buy Order.

Bryan Djoufack Nguessong
201
Bryan Djoufack Nguessong  
Hello, Thank you for the tutorial, it was very helpful. But i have a misunderstanding, the New_Time variables declared and initialized with the CopyTimes function but Old_Time was declared but not initialized at first and then it was compared to the New_Time variable to verify is there a new bar. Old_Time is supposed to be empty. I don't know i described it well but thanks for reading.
advisory100
143
advisory100  

Hi,


Similarly, I have the error code 4756 when running testing and said " Sell order request could not be completed ".

Please inform how to solve this.


Thank 

zrwhiteley
8
zrwhiteley  
Many thanks for the excellent article. Where and how would one implement the Intraday Time Filter module into your code?