WindowPriceMax() & WindowPriceMin() don't change if MT4 is minimized

 

I had a problem with WindowPriceMax() & WindowPriceMin() not giving correct values but thought it was something I was doing wrong . . . . I never took the issue any further. Then yesterday I noticed an interesting phenomenon, I was grabbing charts from MT4 while it was minimized and some text that is positioned using WindowPriceMax() & WindowPriceMin() was in the wrong position on the chart grabs, so this got me thinking.

I wondered if WindowPriceMax() & WindowPriceMin() are not returning the correct values when MT4 in minimized . . . I created a little indicator to test the theory. It works best on an M1 chart as this is most likely to need a change on the Y axis scale . . . it Alerts when the values from WindowPriceMax() or WindowPriceMin() change.

If you want to try to see if you can replicate my issue, place the Indicator on an M1 chart, you should get an alert for the Min value and the Max value . . . then minimize MT4 and wait.

What I found is that I never got an Alert until I restored MT4 from being minimized, and then it was clear that the Y axis had actually changed while MT4 was minimized.

Files:
 

Get alert when attached, no alert after restore from minimized, get alert when price change.

Aren't you supposed to write it using not equal with ( " != " ) ?. When minimized the value of WindowPriceMax() & WindowPriceMin() were not changed and will never changed because Windows OS does/did the minimize not MT4. MT4 doesn't change those values.

Do this, rewrite it using " != ", then put your cursor on right side of the chart - that "price tag" (still in the chart window). left click and drag to resize the vertical value of the chart or click click on it. It changed :).

 
onewithzachy:

Aren't you supposed to write it using not equal with ( " != " ) ?. When minimized the value of WindowPriceMax() & WindowPriceMin() were not changed and will never changed because Windows OS does/did the minimize not MT4. MT4 doesn't change those values.

Do this, rewrite it using " != ", then put your cursor on right side of the chart - that "price tag" (still in the chart window). left click and drag to resize the vertical value of the chart or click click on it. It changed :).


If price falls below the WindowPriceMin() value (actually it doesn't have to go below just close to the min value) the chart will auto scale so that the new price is still visible on the chart. When that happens the value from WindowPriceMin() should change to reflect that the Y axis has been auto scaled to a new value.
 
RaptorUK:

If price falls below the WindowPriceMin() value (actually it doesn't have to go below just close to the min value) the chart will auto scale so that the new price is still visible on the chart. When that happens the value from WindowPriceMin() should change to reflect that the Y axis has been auto scaled to a new value.
My apology, I re-edit my comment and you miss it. Got alert when price moves down. And if anyone wants to try, zoom in the chart
 
   static double LastMax, LastMin = 100000;
   
   
   if(WindowPriceMin(0) < LastMin ) 
      {
      LastMin = WindowPriceMin(0);
      Alert("Window Min Price changed: ", DoubleToStr(WindowPriceMin(0), Digits));
      }

   if(WindowPriceMax(0) > LastMax ) 
      {
      LastMax = WindowPriceMax(0);
      Alert("Window Max Price changed: ", DoubleToStr(WindowPriceMax(0), Digits));
      }
   
   return(0);   
   } // end of start
   

What happens when you minimize your chart is that you get less bars on that chart with same timeframe

you get allert by the indicator only if(WindowPriceMin(0) < LastMin ) and if(WindowPriceMax(0) > LastMax )

for example you go from 40 to 20 bars

By minimize your chart this is not happen the last 20 are the same as last 20 of the 40 bars it can only happen

with minimizing (WindowPriceMax(0) < LastMax ) or (WindowPriceMin(0) > LastMin ) and the value is changed but you're not Allert

Going back to 40 Bars you then get allert because it then can possible happen the conditions of the indicator

 
Got several alerts. Is Price min on Zoom in M1 EURUSD MT build 409. I don't see a problem here or do I miss something ?
 
deVries:

What happens when you minimize your chart is that you get less bars on that chart with same timeframe

you get allert by the indicator only if(WindowPriceMin(0) < LastMin ) and if(WindowPriceMax(0) > LastMax )

for example you go from 40 to 20 bars

By minimize your chart this is not happen the last 20 are the same as last 20 of the 40 bars it can only happen

with minimizing (WindowPriceMax(0) < LastMax ) or (WindowPriceMin(0) > LastMin ) and the value is changed but you're not Allert

Going back to 40 Bars you then get allert because it then can possible happen the conditions of the indicator

It's nothing to do with the number of bars, it's to do with the range of price values on the chart . . . if I wait long enough price will move up or down and will go close to or beyond the last WindowPriceMax(0) & WindowPriceMin(0) values, at that time the Y axis will be re-scaled and there should be new WindowPriceMax(0) or WindowPriceMin(0) values returned.
 
onewithzachy:
Got several alerts. Is Price min on Zoom in M1 EURUSD MT build 409. I don't see a problem here or do I miss something ?

Did you have MT4 minimized ? I have my chart zoomed out one step. I'm on Build 409 too . . .

I get an alert when I restore MT4 from being minimized but nothing wile it is minimized.

 
//+------------------------------------------------------------------+
//|                                                                  |
//|                                               WindowMaxMin.mq4   |
//|                                                13th April 2012   |
//|                                                                  |
//|                                                  First version   |
//|                                                                  |
//| ---------------------------------------------------------------- |
//|                                                                  |
//|                                                                  |
//|                                                                  |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright        "Copyright © 2012, RaptorUK"
#property link             ""
#define VERSION            "1.0"
#define INDICATOR_NAME     "WindowMaxMin"


#property indicator_chart_window



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
   {
   
   IndicatorShortName(StringConcatenate(INDICATOR_NAME, " ", VERSION));   
   
   Print(StringConcatenate(INDICATOR_NAME, " ", VERSION), " launched.");   

   return(0);
   }
   
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
   {
   
   return(0);
   }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
   {
   static double LastMax, LastMin = 100000;
      
   if(WindowPriceMin(0) < LastMin ) 
      {
//      LastMin = WindowPriceMin(0);
      Alert("Window Min Price changed: ", DoubleToStr(WindowPriceMin(0), Digits));
      }

   if(WindowPriceMax(0) > LastMax ) 
      {
//      LastMax = WindowPriceMax(0);
      Alert("Window Max Price changed: ", DoubleToStr(WindowPriceMax(0), Digits));
      }
   if(WindowPriceMin(0) != LastMin ){LastMin = WindowPriceMin(0);}       
   if(WindowPriceMax(0) != LastMax ){LastMax = WindowPriceMax(0);}   
   Print("PriceMin  ", WindowPriceMin(0), "   PriceMax  ", WindowPriceMax(0));
   return(0);   
   } // end of start
   



  
A little change
 
RaptorUK:

I had a problem with WindowPriceMax() & WindowPriceMin() not giving correct values but thought it was something I was doing wrong . . . . I never took the issue any further. Then yesterday I noticed an interesting phenomenon, I was grabbing charts from MT4 while it was minimized and some text that is positioned using WindowPriceMax() & WindowPriceMin() was in the wrong position on the chart grabs, so this got me thinking.

I wondered if WindowPriceMax() & WindowPriceMin() are not returning the correct values when MT4 in minimized . . . I created a little indicator to test the theory. It works best on an M1 chart as this is most likely to need a change on the Y axis scale . . . it Alerts when the values from WindowPriceMax() or WindowPriceMin() change.

If you want to try to see if you can replicate my issue, place the Indicator on an M1 chart, you should get an alert for the Min value and the Max value . . . then minimize MT4 and wait.

What I found is that I never got an Alert until I restored MT4 from being minimized, and then it was clear that the Y axis had actually changed while MT4 was minimized.

I have 419 build, and your code gives no alert if the chart window or the whole MT is minimized. (Alert("New tick!"); is ok.)

Few days ago I have written a code for counting MA angle, and found that all Window functions should avoid for indicator counting. It is only for object placing issues, and therefore indifferent what is the values of them if there is no window to draw on. For indicator counting I used this:
extern int WindowSizeInBars = 80;
...
      winMax = High[ArrayMaximum(High, WindowSizeInBars, i)];
      winMin = Low[ArrayMinimum(Low, WindowSizeInBars, i)];
 
RaptorUK:

Did you have MT4 minimized ? I have my chart zoomed out one step. I'm on Build 409 too . . .

I get an alert when I restore MT4 from being minimized but nothing wile it is minimized.

You must be waiting long for this .... :)

Using WindowHandle () and Comment(), I rewrite the CI so I can attach it on 3 charts and can tell which one alerts me, one maximized two minimized which one of them will be restored.

Got several from the maximized, not from any the minimized, got only one from restored one.

Maybe, MT recognized it was minimized (here or here), and so doesn't give any damn about it. I't the size of the chart, - not something trading related - so MetaQoutes probably thinks that doesn't really matter.