# Find the highest / lowest of CLOSE price of some bars

47

Hi,

We can get highest / lowest value of last Depth bar using (similar to MT4 Zigzag indicator) :

```double theHighest = high[iHighest(NULL,0,MODE_HIGH,Depth,i)];
double theLowest  = low[iLowest(NULL,0,MODE_LOW,Depth,i)];```

But how can we get the highest/lowest of the CLOSE price of each bar in the last Depth bars ?  Which one from the code below is the right one ?

```double theHighest = close[iHighest(NULL,0,MODE_CLOSE,Depth,i)];
double theLowest  = close[iLowest(NULL,0,MODE_CLOSE,Depth,i)];

** OR **

double theHighest = high[iHighest(NULL,0,MODE_CLOSE,Depth,i)];
double theLowest  = low[iLowest(NULL,0,MODE_CLOSE,Depth,i)];
```

6989

the first two lines:

```double theHighest = close[iHighest(NULL,0,MODE_CLOSE,Depth,i)]; // <= close of the bar found
double theLowest  = close[iLowest(NULL,0,MODE_CLOSE,Depth,i)];
```

But instead of waiting for 2 hours or more why don't you write a simple script to check it out yourself?

That would take 5 min to get the result instead of 2 hours?

Moderator
10369

As Gooly says, but bear in mind that by using close, it is unclear from the documentation whether the default is set as series or not

So you should include

`ArraySetAsSeries(close,true);`

47

gooly:

the first two lines:

But instead of waiting for 2 hours or more why don't you write a simple script to check it out yourself?

That would take 5 min to get the result instead of 2 hours?

Thanks gooly. But it is not clear about "2 hours" , could you please explain more ?

Actually i am trying to create my own Zigzag indicator (modifying the default ZigZag indicator of MT4), which will get the CLOSE price of the bar (instead of High and Low of the bar).

Thanks

47

GumRai:

As Gooly says, but bear in mind that by using close, it is unclear from the documentation whether the default is set as series or not

So you should include

Thanks GumRai. Do you mean using : time,open,high,low,close,tick_volume,volume,spread  (found at OnCalculate function)  need to set them as Series first,

while using  "Close" or "iClose" , we do not need to set them as series?

Moderator
10369

pedma:

Thanks GumRai. Do you mean using : time,open,high,low,close,tick_volume,volume,spread  (found at OnCalculate function)  need to set them as Series first,

while using  "Close" or "iClose" , we do not need to set them as series?

Close (with the capital letter) etc are series arrays

but

from the documentation for OnCalculate

"To determine the indexing direction of time[], open[], high[], low[], close[], tick_volume[], volume[] and spread[], call ArrayGetAsSeries(). In order not to depend on default values, you should unconditionally call the ArraySetAsSeries() function for those arrays, which are expected to work with."

47

GumRai:

Close (with the capital letter) etc are series arrays

but

from the documentation for OnCalculate

"To determine the indexing direction of time[], open[],high[], low[], close[], tick_volume[], volume[] and spread[], call ArrayGetAsSeries(). In order notto depend on default values, you should unconditionally call the ArraySetAsSeries() function forthose arrays, which are expected to work with."

Thanks a lot GumRai ...
205

If I wish to spot some divergence with bollinger bands.. can it be done using this code?

```double theHighest = Close[iHighest(NULL,0,MODE_CLOSE,Depth,i)]; //count the close for the past Depth bars
double theHighestPast = Close[iHighest(NULL,0,MODE_CLOSE,Depth,i+Depth)]; //count the close for the past Depth bars before theHighest

double BB = iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_UPPER,"how to specify that this is to count the last 'Depth' bars");
double BBPast = iBands(NULL,0,20,2,0,PRICE_CLOSE,MODE_UPPER,"how to specify that this is to count the 'Depth' previous than the last Depth bars");

if(theHighestPast>BBpast /* if closed out of the bands at some point between this time*/ && theHighest<=BB && theHighest>theHighestPast /*the last highest was higher than the previous and didnt close out of the bollinger bands*/)

```

I've checked to use the iBarShift() function, but not shure how it would fit in this..

109

Hi.

Can please someone paste the entire code here?

Some traders like myself doesn't have any knowledge about coding and doesn't know where to paste that characters in MetaEditor.

Thanks for understanding.

15331

 erborja: Can please someone paste the entire code here? Some traders like myself doesn't have any knowledge about coding and doesn't know where to paste that characters in MetaEditor. You couldn't be bothered to learn mql4, therefor there is no common language for us to communicate. Even if you received code you couldn't integrate it into yours. You have only three choices: Search for it, learn to code it, or pay (Freelance) someone to code it. We're not going to code it for you. We are willing to help you when you post your attempt (using SRC) and the nature of your problem.