WindowPriceMax() & WindowPriceMin()

 
If I run the following code I get various results. These functions return the y co-ordinates of the main chart with no sub indicator windows, so if there is one or more indicator window(s) open then these functions return erroneous results. Also with version 199 & 200 if the period is changed the results are the same as that of the preceding period chosen! Thanking you in advance.

// debug
int iWin=WindowHandle(Symbol(), Period());
Print("iWin=",iWin," WindowPriceMax()=",WindowPriceMax(iWin)," WindowPriceMin()=",WindowPriceMin(iWin));
// end debug
 
Not window handle! Subwindow number of the current chart
 
Thank you Slawa for the WindowPriceMin() & WindowPriceMax() parameter.
BUT when I start off with PERIOD_M1 the results are correct, but if the period is changed to PERIOD_M5 the same values are returned yet the chart visually displays different y values!, BUT if I delete my indicator and run it again the WindowPriceMin() & WindowPriceMax() return the correct values. Thanking you in advance.
 
There is a nuance concerning indicators.

Indicators are first calculated one by one, then drawn.
Minimum price and maximum price are calculated during drawing, i.e., when the timeframe is changed, your indicator gets the previous value of the minimum and the maximum. You should wait until the next tick comes, everything will be ok.

The above does not relate to Expert Advisors and scripts.
 
Slawa I wait for many ticks but it is not OK, but Friday afternoon is not a good day to test due to the low volume. I will test again on Monday. Thanks, have a nice week end.
 
I've specially checked it. It works as described above
 
1) It works as described above sometimes, and I do not understand why the user must wait for a tick to arrive sometime in the future before the functions return the correct results! Could this please be looked into again.