Optimizing Code of Expert for Good Performance

 

I have coded a robot but my knowledge of coding is limited so, obviously, I have added the functions I need but I see these are not working right. I am constantly modifying the code LIVE adding /if and /while according to what I am seeing in the market. So, my question is, Is there a preestablished way of optimizing it or should I directly rely on a Freelance for it?

It is relying on 6 indicators, so now I am not sure if it might be the Indicators to blame. Once a trade is opened, I do not need the indicators to calculate again. Should I add a function to release data processing capacity?

My OnTick is stuck...

Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Expert tick function                                             | //| test1                                                            |...
 

It`s really hard to answer your question without any clue about your expert advisor and the code, unless it is a confidential project or something fresh on the market that nobody else is doing, I suggest you to paste your code in order to get help.


If you are not an expert in MQL5 or in programming, the best way is look for a freelancer. If you would like to try to discover what is happening with your code, you can run it in a demo account in debug mode or if it is not possible, simple add a lot of "Print" commands in order to identify where your code is stopped.


I hope that it makes sense.



Regards.

 

You do not run live until it is correct and optimized.

You do not optimize until it is correct.

You back test it with debugging prints or use the debugger until it is correct.

 
Here is one of them. I made this one for a request in Forex Factory but it basically is the same code as the one I am building. So far I have seen it is opening more than 1 trade per direction. That is not working right, although it is an error that gives profit so far, it may not be good in certain situations.
 
Fernando Souza:

It`s really hard to answer your question without any clue about your expert advisor and the code, unless it is a confidential project or something fresh on the market that nobody else is doing, I suggest you to paste your code in order to get help.


If you are not an expert in MQL5 or in programming, the best way is look for a freelancer. If you would like to try to discover what is happening with your code, you can run it in a demo account in debug mode or if it is not possible, simple add a lot of "Print" commands in order to identify where your code is stopped.


I hope that it makes sense.



Regards.

I attached a copy. The code is vey similar to the one I am coding. As I stated, I used that one for a request in Forex Factory while I was waiting for an Indicator Modification. I guess I will end up needing to look for a Freelancer to check the code. 

Thank you for answering Fernando.

Kind regards

Reason: