Complex Functions

 

To all experienced coders... do you break the steps of a complex function down to sub functions? For debugging would'nt this be easier to test each step for accuracy. Then once the final result is verfied the sub functions can be combined to a single function? Or is it best practice to keep each step seperated.

Opinions please...

 

I will put a piece of code into a separate function only if I am going to call it from several places... I think there's no need to create a function for each step of the code; you can do debugging on every step even if it is in your main program. ..and certainly there's no need to combine the functions later on, this would be too much overhead...

thank you

Automated

 
You can write a n Expert Adviser by some logic blocks, for example:
{trade signals check block }
{lot calculation block}
{open positions block}
{close position block}
{trailing stop loss block}
{statistics block}
{log blog} etc.

You can write each block as single subroutine.
Reason: