Problem creating a function returning a SuperTrend indicator, in an EA

 

Hello!  

Here is a newbie in MQL. I'm coding a strategy for MT4 using a SuperTrend indicator. The MQ4 indicator was downloaded and works fine painting the result, but I need help migrating or embedding it into my EA.

I need clarification on why the values of 'TrendUp' and 'TrendDown' variables are not correctly updated in the EA (and that the function returns only the current result of the SuperTrend line itself). I attach the indicator file and the EA that for now is just call to the 'SuperTrend' function plus a few logs to try to locate the problem. Please, I prefer to do not use 'iCall' function and use the entire code in a single file.

Could you help me on this, please? For me seems to be something related to an invalid usage of the loop or maybe related to the 'shift' of values. 


Thanks!

Files:
 
"I prefer to do not use iCall and use entire code in a single file"

This is a common non-sense theory.

Use #resource for embedding an indicator inside an EA but leave code separated.
 
Fabio Cavalloni #:
"I prefer to do not use iCall and use entire code in a single file"

This is a common non-sense theory.

Use #resource for embedding an indicator inside an EA but leave code separated.

Thanks.  Even in this case I don't know how to get the SuperTrend result (the resulting price) and the flags or 'trend' variable to launch the position in the EA.

 
Search documentation for iCustom command.

In MT4 it will return the value of the buffer you try to access, so you can clearly catch the signal and make EA opening trades!