In general terms, there are no "best practices". The vast majority of coders here are not software developers and are usually self taught, so apply their own style and "practices". Also given that is trading, most tend to keep things to themselves.
Given that MQL is very similar to C and C++, you can however look into the "best practices" of coding C and C++ in general and apply it to MQL.
As for the specifics for Indicators and EAs, there are no "best practices". You will simply devise your own as you progress and gain experience while programming them.
As a side note, the following article aimed at Market products is also a good set of practices that should be applied to your own EAs as well ...
The checks a trading robot must pass before publication in the Market
MetaQuotes, 2016.08.01 09:30
Before any product is published in the Market, it must undergo compulsory preliminary checks in order to ensure a uniform quality standard. This article considers the most frequent errors made by developers in their technical indicators and trading robots. An also shows how to self-test a product before sending it to the Market.
Thanks for this.
Your questions are too general. The answers are scattered in the forum. Unfortunately there is no easy way to find the good and useful topics which are drowned among thousands of repetitive, trivial or useless posts.
Thanks for this.
As per my experience, the best practices of mql codes are pulbished in this user's publication
I used to write an incdicator in 2000 lines of codes but after exploring these codes I have been able to use best practice and covert my old codes of 2000 lines into 50 lines of code.
I think the best practice is to check for Errors, If something wrong happens then you would never know whats going wrong in indicator but if you write your code in a style which checks everything or inform errors then it is one of the example of writing code with best practice, example here is how noob coder writes code
ObjectCreate(chart_ID,name,OBJ_TEXT,sub_window,time,price);
Its valid but with good practice its written like this
ResetLastError(); //--- create Text object if(!ObjectCreate(chart_ID,name,OBJ_TEXT,sub_window,time,price)) { Print(__FUNCTION__, ": failed to create \"Text\" object! Error code = ",GetLastError()); return(false); }

As per my experience, the best practices of mql codes are pulbished in this user's publication
I used to write an incdicator in 2000 lines of codes but after exploring these codes I have been able to use best practice and covert my old codes of 2000 lines into 50 lines of code.
I think the best practice is to check for Errors, If something wrong happens then you would never know whats going wrong in indicator but if you write your code in a style which checks everything or inform errors then it is one of the example of writing code with best practice, example here is how noob coder writes code
Its valid but with good practice its written like this

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I just wanted to know if any experienced developer has made post / topic about best practices and patterns about creating Indicators.
Since information about EA/MQL5/Indicator is spread out across forum posts/articles/MQL5 documentation, I thought someone may already have created post about best practices that would enlighten about
- modularise code and how to manage variables which may be reused across different modules/classes
- facilitate easier testing within code
- improve performance of code in EA
- "watch out for this condition" and other warnings
- prevent edge conditions from breaking Indicators while functioning
- Unique aspects one has to take care of when dealing with different instruments - eg forex pairs to indices to commodities
- unique aspects one may have to account for , for different brokers
- other aspects that one learns only through hit and trial/ live running of EAs
- limitations
If not perhaps experienced developers here can share their experience here.
Thanks in advance!