Highest and Lowest of an array

Created at 03 Apr 2015, 17:44
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
HQ

hq76

Joined 29.03.2015

Highest and Lowest of an array
03 Apr 2015, 17:44


Hello,

How can i retrieve the Highest High and the Lowest Low of an array, please ? Thnks.


@hq76
Replies

Manuel_Meza
03 Apr 2015, 22:43

Con un loop, que compare cada elemento del array con todos, si en la comparacion, el nuevo es el mas grande, toma ese valor... sino, el que tienes es el valor mas grande.


@Manuel_Meza

hq76
03 Apr 2015, 22:56

RE:

Manuel_Meza said:

Con un loop, que compare cada elemento del array con todos, si en la comparacion, el nuevo es el mas grande, toma ese valor... sino, el que tienes es el valor mas grande.

Gracias Manuel. Pienso tambien already. Thought it would have a cAlgo function... ?


@hq76

Spotware
06 Apr 2015, 12:49

No, there is no such cAlgo function.


@Spotware

hq76
07 Apr 2015, 17:43

Found this in the donchian channels indicators  /algos/indicators/show/133:

private double Highest(DataSeries arr,int range,int fromIndex)
        {
            double res;
            int i;
            res=arr[fromIndex];
            for(i=fromIndex;i>fromIndex-range && i>=0;i--)
            {
                if(res<arr[i]) res=arr[i];
            }
            return(res);
        }
 
        private double Lowest(DataSeries arr,int range,int fromIndex)
        {
            double res;
            int i;
            res=arr[fromIndex];
            for(i=fromIndex;i>fromIndex-range && i>=0;i--)
            {
                if(res>arr[i]) res=arr[i];
            }
            return(res);
        }

Fits my needs, no worries.


@hq76