English

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

 6 pedma 2015.02.05 07:06   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)]; ```Thank you in advance.
 2017 gooly 2015.02.05 09:03 #   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?
 Moderator3425 GumRai 2015.02.05 12:04 #   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 notSo you should include`ArraySetAsSeries(close,true);` Before your code. Otherwise just use Open instead of open
 6 pedma 2015.02.05 15:52 #   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
 6 pedma 2015.02.05 15:59 #   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 notSo you should include Before your code. Otherwise just use Open instead of openThanks 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?
 Moderator3425 GumRai 2015.02.05 21:05 #   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 arraysbut 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."
 6 pedma 2015.02.06 00:23 #   GumRai: Close (with the capital letter) etc are series arraysbut 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 ...
 16 gviali 2015.02.06 04:38 #   Taking advantage of this topic, I had a doubt earlier..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..