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

 
Excellent work my guy ... I learnt something today
 

please what should i tick on those checkbox in the dialog box

Files:
 

Hi everybody begginings:

All I have needed to do to fix error 4756 (for both buy and sell codes change the next 3 lines):

// any opened Sell position?

         if(Sell_opened || Buy_opened) // Include both orders in this conditional with an OR operator
           {
            Alert("We already have a Sell position!!!");
            return;    // Don't open a new Sell Position
           }
         ZeroMemory(mrequest);                                                 // Include this line in this position
         mrequest.action=TRADE_ACTION_DEAL;                                // immediate order execution
         mrequest.price = NormalizeDouble(latest_price.bid,_Digits);           // latest Bid price
         mrequest.sl = NormalizeDouble(latest_price.bid + STP*_Point,_Digits); // Stop Loss
         mrequest.tp = NormalizeDouble(latest_price.bid - TKP*_Point,_Digits); // Take Profit
         mrequest.symbol = _Symbol;                                          // currency pair
         mrequest.volume = Lot;                                              // number of lots to trade
         mrequest.magic = EA_Magic;                                          // Order Magic Number
         mrequest.type= ORDER_TYPE_SELL;                                     // Sell Order
         mrequest.type_filling = ORDER_FILLING_IOC;      // Change the "FOK" by "IOC"
         mrequest.deviation=100;                                             // Deviation from current price

 

Although in some indicators the size of MQL5 is smaller than MQL4,

the impression is that MQL5 has become more complicated and polluted than MQL4.

 
Nice article, save my days, thanks bro..
 
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

It seems the file with the code (*.mq5) should be placed somewhere in MQL5 installation directory (for example, in the `Shared Projects`)
 
surfdoode2 #:


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.

Make sure you have allowed Algo Trading.
 
Does anybody know why did he check for the number of bars (<60) the second time in the article? His explanation of this action is not an explanation at all.
 
Samuel Olowoyo #:

Hello,

First from your explanation, when you removed those lines of code, you get an error and when you did not multiply the stoploss/takeprofit values by 10, you get an error? This I believe has explained that those lines of code are very important.

Back to the article, it explained those lines of code are necessary if you are using a chart with 5 decimal digits (0.XXXXX) or 3 decimal digits (0.XXX) currency pairs.

See examples below: 

 

 5 - Decimal Digits price

 

3 - Decimal Digits price 

I hope this has answered your question.

Hmm.. no it doesn't at all.
Samuel Olowoyo #:

Hello,

First from your explanation, when you removed those lines of code, you get an error and when you did not multiply the stoploss/takeprofit values by 10, you get an error? This I believe has explained that those lines of code are very important.

Back to the article, it explained those lines of code are necessary if you are using a chart with 5 decimal digits (0.XXXXX) or 3 decimal digits (0.XXX) currency pairs.

See examples below: 

 

 5 - Decimal Digits price

 

3 - Decimal Digits price 

I hope this has answered your question.

No it doesn't at all. You just repeat what you said in the article.
 

Hi samuel. I am also new to algorithmic trading. I constantly get the error 4756 that in the manual indicates that it is account type and that it is shown in the commercial request submission failed. Based on your experience, what do you think I am doing wrong, or what should I take into account knowing that I opened my account with the XM broker. Greetings...