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

 

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:

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 

 
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?
 
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.

 
Tchuso:

Hi, I'm getting an error:

return value of 'OrderSend'should be checked lines 213 and 259.


have you solved it?

Good morning Tchuso,

The same thing happened to me. I fixed it by replacing those lines in both operations with this.

if(!OrderSend(mrequest,mresult))
PrintFormat("OrderSend error %d",GetLastError());

Tell me if you need help, I'm new too.

Best regards!

 

I like the example code quite a lot, I'm new to this too, I fixed the code as it appears in the comments and it doesn't give errors anymore.

The problem is that the robot does not open trades, it does not even open a trade.

Has anyone been able to solve this problem?


I'm using the "Unico" option of the strategy tester: is it my mistake?


Thanks for your time and support
 


I noticed that the Robot tries to open the orders but always gives an error:


Exit:

2020.05.06 20:35:16.141 Core 1 2020.04.20 20:25:00 failed market sell 0.10 EURUSD sl: 1.08965 tp: 1.07665 [Invalid request].


I have changed several things in the code but it doesn't work, I add the code I have:


Original: mrequest.type_filling = "I have put it in the 3 ways that are in the documentation".

 mrequest.action = TRADE_ACTION_DEAL;                                  // immediate order execution
         mrequest.price = NormalizeDouble(latest_price.ask,_Digits);           // latest ask price
         mrequest.sl = NormalizeDouble(latest_price.ask - STP*_Point,_Digits); // Stop Loss
         mrequest.tp = NormalizeDouble(latest_price.ask + 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_BUY;                                        // Buy Order
         mrequest.type_filling = ORDER_FILLING_RETURN;                             // Order execution type
         mrequest.deviation=100;                      
        



Tambien he probado este codigo:

 //--- declaration and initialisation of the request and result
               MqlTradeRequest request={0};
               MqlTradeResult  result={0};
            //--- application parameters
               request.action   =TRADE_ACTION_DEAL;                     // type of business operation
               request.symbol   =Symbol();                              // symbol
               request.volume   =0.1;                                   // volume of 0.1 lot
               request.type     =ORDER_TYPE_BUY;                        // order type
               request.price    =SymbolInfoDouble(Symbol(),SYMBOL_ASK); // opening price
               request.deviation=5;                                     // permissible price deviation
               request.magic    =EA_Magic;                          // Magical number of the order

               //--- sending the application
               if(!OrderSend(request,result))
               PrintFormat("OrderSend error %d",GetLastError());     // if the request could not be sent, enter the error code
               //--- information on the operation
               PrintFormat("retcode=%u  deal=%I64u  order=%I64u",result.retcode,result.deal,result.order);
 
Libni Colina:


I noticed that the Robot tries to open the orders but always gives an error:


Exit:

2020.05.06 20:35:16.141 Core 1 2020.04.20 20:25:00 failed market sell 0.10 EURUSD sl: 1.08965 tp: 1.07665 [Invalid request].


I have changed several things in the code but it doesn't work, I add the code I have:


Original: mrequest.type_filling = "I have put it in the 3 ways that are in the documentation".


Add this at the top of the code:

#include <Trade\Trade.mqh>

And then to open an operation just type this:

double volumen= 0.01; // Or whatever volume you want

CTrade m_trade;

m_trade.Buy(volumen); // Purchase

m_trade.Sell(volumen); // Sells
 
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.
 

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