English

## highest(or lowest) value of a indicator

 4 atxjess 2014.06.24 22:46   How can I return the highest(or lowest) value of a indicator over a set period in a EA?So for instance If I want my EA to trade when indicator one reaches a high of 10 or more and within 5 bars from that indicator two also reaches a high of 10 or more. So it would trade when two indicators made new highs within 5 bars of each other.I've been stuck a few days so examples would be greatly appreciated.-Thank you
13123
WHRoeder 2014.06.25 00:55 #

 atxjess: How can I return the highest(or lowest) value of a indicator over a set period in a EA? Get each value, find the highest.```double highestInd(int iFrom, int iTo=0){    double hh = iCustom( ... iFrom); --iFrom;    while(iFrom >= iTo){      double val = iCustom( ... iFrom); --iFrom;      if(hh < val) hh = val;    }    return hh; }```Is that so hard?
4
atxjess 2014.06.25 06:14 #

WHRoeder:
 atxjess: How can I return the highest(or lowest) value of a indicator over a set period in a EA? Get each value, find the highest.Is that so hard?

I get this error when I try this code "'highestInd' - function can be declared only in the global scope". I need it to be local so say If both indicators high is greater than 10 within 5 bars of each other. It would buy.
 35 sokramm 2014.06.25 07:17 #   atxjess: I get this error when I try this code "'highestInd' - function can be declared only in the global scope". I think you need to review the beginning of https://book.mql4.com/basics/functions
 4 atxjess 2014.06.25 21:18 #   sokramm: I think you need to review the beginning of https://book.mql4.com/basics/functions I understand functions, this code can only be declared on a global scope meaning on initialization. So the values would set when I load the EA but never update. I need it to check if the parameters are met on every bar.
 4 atxjess 2014.06.26 04:48 #   I think I must be missing something. I'm still stuck.
 171 drazen64 2014.06.26 11:48 #   Show complete code.
13123
WHRoeder 2014.06.26 13:49 #

 atxjess: I think I must be missing something. I'm still stuck. Put the function definition (highestInd) outside of existing code and call it inside your function.Show your code, there are no mind readers here.