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

To add comments, please log in or register
Samuel Olowoyo
2322
Samuel Olowoyo  
 guguqiaqia:

step 1: download your this sample code.

step 2: compile it in mql5 .

step 3:in mt5,open chart eurusd 1m, then ,click "auto trading"

step 4:set break symbol in code line 223,224 etc...

step 5:click start debugging button in mt5, then,show this error.

Hello,

Thanks for sharing your steps. If I can take you back to the code,

if(mresult.retcode==10009 || mresult.retcode==10008) //Request is completed or order placed
{
   Alert("A Buy order has been successfully placed with Ticket#:",mresult.order,"!!");
}
else
{
   Alert("The Buy order request could not be completed -error:",GetLastError());    // line 223
   ResetLastError();                                                                // line 224
   return;

As far as I know, the code did what its supposed to do. You got the error because the order you tried to place was NOT SUCCESSFUL and that is what the line 223 was supposed to do. Please read this  - https://www.mql5.com/en/docs/constants/errorswarnings/enum_trade_return_codes -  to know what the error means.  (Actually, 10030 means  Invalid order filling type ).

To understand what the order filling type -ORDER_FILLING_FOK  -

mrequest.type_filling = ORDER_FILLING_FOK; // Order execution type  ( line 213 )

  means, please read https://www.mql5.com/en/docs/constants/tradingconstants/orderproperties#enum_order_type_filling 

Hope this answered your question. 

rodrigo.ramos
7
rodrigo.ramos  

Hi Samuel,

I downloaded the code, installed it and ran it and I realized it's opening buy and sell orders mostly at every candle that meet the criteria (I'm using H1 as timeframe).

I did not debugging and realized some part of the codes are not triggered. Are you guys able to run the EA properly with the code available for download? 

Files:
screen.jpg 417 kb
jeanphi0034
9
jeanphi0034  

Hello Mr Olowoyo

 

 

 Thanks you very much for your extremelly interesting article about the way to build and EA.

It is simples for beginners and really helpful 

I am really new in the coding of EA but I realize it is extremelly necessary to test different strategies.

I have downloaded  you EA and try to compile it but I get immediately 50 errors ...

In the previous comments I did not see such problems reported by the users ...

Please find enclosed a extract of the error table.

I will appreciate very to receive some help 

 

Jean Philippe 

Files:
babigaf
15
babigaf  

Hi Samuel.

your guide was awesome and really cleared the air.

but I have some problems in calling other indicators in my EA.

can you tell me how add MACD and VIDyA signals in my EA? I need to calculate the Signal and Main amount of MACD for example but don't know how to call them in my EA. That would be a great help if you tell me how to do that :)

 you are awesome 

Baljit Oberoi
447
Baljit Oberoi  

I am trying to compile the code provided in this tutorial but getting the error

iADX: wrong parameter count

at the following line

adxHandle=iADX(NULL,0,ADX_Period);

The code seems fine to me. How do I fix the error?

Could anyone help?

Mohammad Hossein Najarzadeh
67
Mohammad Hossein Najarzadeh  
Dear Samuel
your article was magnificent.
i'm not sure if anyone could have wrote a better beginner guideline.
looking forward to your new articles.

Best Regards

vasagan1
28
vasagan1  

Hi,


I have a custom indicator, how to I create an EA, like in your example?

apirakkamjan
20
apirakkamjan  

Guys,

This is a simple quick modified code if you have an error with multiple orders opening at the same time.

Replace this code :  from line 167 -177

   if(PositionSelect(_Symbol)==true) // we have an opened position
     {
      if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY)
        {
         Buy_opened=true;  //It is a Buy
        }
      else if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL)
        {
         Sell_opened=true; // It is a Sell
        }
     }

with this:

   int total= PositionsTotal();
   for(int i=0;i<total;i++)
     {
      if(PositionGetSymbol(i)==_Symbol);
        {
         if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_BUY)
           {
            Buy_opened=true;  //It is a Buy
           }
         else if(PositionGetInteger(POSITION_TYPE)==POSITION_TYPE_SELL)
           {
            Sell_opened=true; // It is a Sell
           }
        }
      }

Thanks  @Samuel Olowoyo

To add comments, please log in or register