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.
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=false; bool Sell_opened=false;
and it works fine
please continu your good work writing interresting article like this !
Thanks so much for your observation and commendation. I do appreciate it.
Your suggestion is actually a better way. It will be modified.
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.
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 !
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.
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<maVal_slow) && (maVal_fast > maVal_slow);
bool Buy_Condition_2 = (rsiVal < Pereprod);
if(Buy_Condition_1 && Buy_Condition_2)
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 ).
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.
Can you please make available your code so we can see where the problem is?
Please enable the necessary setting in your browser, otherwise you will not be able to log in.