Do you remember the Simple EA we created in the first part? The whole programming logic was handled within a single file. That is no problem for small expert advisors, but if you want to make it a real system with hundreds of lines of code, you will need a little bit more structure. Another advantage of modular programming is the fact that you can reuse one part of code over and over again in other expert advisors without the need to code everything again and again.


This part here is doing the trend calculation. We are going to cut it and create a new file. Click on Next and call it CheckTrend. It will create a template like the one you already know. We will remove everything except the header and paste our 3 lines of code here. And now, we will create a custom function. We call it CheckTrend. It will return a double value, so we’ll call it double CheckTrend.
And after the trend is calculated, we want to return it here. We will save the file and not compile it because it will be included like a text file with the include function in our main expert advisor.

Trading Tutorial Automation was found for: