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

 

New article Step-by-Step Guide to Writing an Expert Advisor in MQL5 for Beginners is published:

The Expert Advisors programming in MQL5 is simple, and you can learn it easy. In this step by step guide, you will see the basic steps required in writing a simple Expert Advisor based on a developed trading strategy. The structure of an Expert Advisor, the use of built-in technical indicators and trading functions, the details of the Debug mode and use of the Strategy Tester are presented.

Figure 15. Debugger stops at the first breakpoint

Author: olowsam

 

really nice article, you should write the book your explaination are well structured!

by the way there seems to be a little ommission in the code of the file, the bool Buy_opened and the bool Sell_opened are not reset to false each time so in the tester it will only make 1 sell and one buy... you only have to replace  this

 bool Buy_opened,Sell_opened;

 by this 

 bool Buy_opened=false;
   bool Sell_opened=false;

and it works fine

please continu your good work writing interresting article like this !

 

 
Gachette:

really nice article, you should write the book your explaination are well structured!

by the way there seems to be a little ommission in the code of the file, the bool Buy_opened and the bool Sell_opened are not reset to false each time so in the tester it will only make 1 sell and one buy... you only have to replace  this

 bool Buy_opened,Sell_opened;

 by this 

 bool Buy_opened=false;
   bool Sell_opened=false;

and it works fine

please continu your good work writing interresting article like this !

 

Hi Gachette, 

Thanks so much for your observation and commendation. I do appreciate it.

Your suggestion is actually a better way. It will be modified.

Thanks 

 

Thanks but didn't talk about how to Close positions.

 
song_song:

Thanks but didn't talk about how to Close positions.

Yes, it's true that the article does not dicsuss how to close positions in details, however, if you open a Sell position, once you open a Buy, the sell position is automatically closed.

Therefore, to close a Buy position, open a Sell; and to close a Sell position, open a Buy.

Thank you. 

 

Greal article! Clearly structured and easily understood. 

 I doubt the return expression in the first "if" condition of the "OnInit()". Perhaps the parameter should be -1, whatever but not 0, or the if condition is redundant.

 

Thank you for you article !

 
I am very thankful for this article it has helped a great deal. After writing my codes for my EA I pressed the debugging button and i was told that I have 10 errors, in your article their isn't any information for correcting these errors. So how do I solve this problem, please write back as soon as possible ?
 
Stacy:
I am very thankful for this article it has helped a great deal. After writing my codes for my EA I pressed the debugging button and i was told that I have 10 errors, in your article their isn't any information for correcting these errors. So how do I solve this problem, please write back as soon as possible ?

Hi Stacy,

Thanks for your compliments, like you said, correcting some of the code errors were not discussed in the article, however, another article will soon be published that explained how to resolve code errors in detail.

Just wait for it.

 Thank you

Samuel. 

 

hi everyone!

i am a beginer and i am trying to write an E.A follow the guide but it did not make sell or buy order.

my algorithm is use 2 ma( 6 and 12) and 1 rsi(14), like that:


bool Buy_Condition_1 =  (maVal_fast[0]<maVal_slow[0]) && (maVal_fast[1] > maVal_slow[1]);

bool Buy_Condition_2 = (rsiVal[0] < Pereprod);

if(Buy_Condition_1 && Buy_Condition_2)

{

            // blah...blah...

              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.volume = Lot;                                                 // number of lots to trade

              mrequest.type = ORDER_TYPE_BUY;

             // .............


}

but it dont jump into  segment code above. so it cannot automated trading. = =!.

i need help :(.

i use PRICE_MEDIAN instead of PRICE_CLOSE ( i dont know differences between them ).

thank you.

Documentation on MQL5: Standard Constants, Enumerations and Structures / Trade Constants / Order Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Trade Constants / Order Properties - Documentation on MQL5
 

hi everyone!

i am a beginer and i am trying to write an E.A follow the guide but it did not make sell or buy order.

 

Hi,

Can you please make available your code so we can see where the problem is?