# How to get the position of highest or lowest point of Indicator?

Have you developed a trading robot? Publish it in the Market and make profit!
130
2010.08.30 23:48

I am looking for a method to get the position of highest or lowest point of Indicator(MACD,etc) from a period(for example from 0 to 30 bars), when i found out the point of a indicator from them,i also want to know the number of the bar it corresponded. it's so kind of you telling me how to find it out, I'm a new one, at present, I only know how to found out a highest or lowest bar from a period, and the indicator point they corresponded,but it seems not what I am looking for.

2650
2010.08.31 04:15

look at the indicator data for each bar, see if it is higher than any other data you've seen, if it is, remember the bar number.

```int theBar;
double theHighest;

for(int i = 0; i <= 30; i++){

if( theIndicatorData[i] > theHighest ) {

theHighest = theData;
theBar = i;
}
}
```
130
2010.08.31 06:16

Thank you very much for fast reply, I'm a beginner, let me study it first, and i will be back later .

130
2010.08.31 09:45
phy:

look at the indicator data for each bar, see if it is higher than any other data you've seen, if it is, remember the bar number.

Dear Sir:

I nearly understand your mean, I'm a beginner and cannot write it the code out by myself at present, will you please give me a complete code? sorry for demanding that, i want to serch the highest point of RSI indicator from nearest 30 bars, will you help me to do that?

14230
2010.08.31 16:04
```int theBar;
double theHighest;
for(int i = 0; i <= 30; i++){
double rsi = iRSI(NULL,0,14,PRICE_CLOSE, i);
if( rsi > theHighest ) {
theHighest = rsi;
theBar = i;
}
}
```
130
2010.08.31 21:24
WHRoeder:

thank you very much, they work very on Rsi, but they seems won't work on the indicators which have 2 buffers, such as Macd and Stochastic, will you please write a code about them for me?
130
2010.08.31 21:29

thank you very much, It work very well on Rsi, but they seems won't work on the indicators which have 2 buffers, such as Macd and Stochastic, will you please write a code about them for me?

```int theBar;
double theHighest;
for(int i = 0; i <= 30; i++)
{
double mac;
//stoch=iStochastic(NULL,0,5,3,3,MODE_SMA,1,MODE_MAIN,i);
mac=iMACD(NULL,0,12,26,9,PRICE_CLOSE,MODE_MAIN,i);
//rsi = iRSI(NULL,0,14,PRICE_CLOSE, i);
if( mac > theHighest )
{
theHighest = mac;
theBar = i;
}

```
130
2010.09.01 03:02

Thank you very much for you all, it has worked,it's nice of both of you to help me about that.

130
2010.09.01 23:56

When I looking for the highest, it work well, when i looking for the lowest, it won't work, will you teach me how to repair it ?

```int theBar;
double thelowest;
for(int i = 0; i <= 30; i++)
{
double rsi; rsi = iRSI(NULL,0,14,PRICE_CLOSE, i);
if( rsi < thelowest )//I just changed the ">" code there.
{
thelowest = rsi;
theBar = i;
}
}```
2650
2010.09.02 07:11

You need to initialize theLowest to a value above the highest expected value of rsi, so you can later find an rsi value that is lower.

double theLowest = 99999999;

130
2010.09.02 08:27

Thank you very much phy, it has worked.

/ /12