Price scale changing

 
Can we detect that the scale of the price axis has changed when the price rises/falls outside the original interval on the price axis?
I thought this should be handled by a function OnChartEvent with id CHARTEVENT_CHART_CHANGE, but unfortunately not.
 
Petr Nosek:
Can we detect that the scale of the price axis has changed when the price rises/falls outside the original interval on the price axis?
I thought this should be handled by a function OnChartEvent with id CHARTEVENT_CHART_CHANGE, but unfortunately not.

As in when the chart does that on its own  ?

Since it can change on tick (only) i'd assume a copy of the price max and price min can be kept and checked against .

Will test that 

ChartGetDouble(ChartID(),CHART_PRICE_MIN,0);
ChartGetDouble(ChartID(),CHART_PRICE_MAX,0;

if that's what you meant :

#property strict
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
double scaleMax=0.0,scaleMin=0.0;
int OnInit()
  {

  scale_changed(scaleMax,scaleMin,0);
  return(INIT_SUCCEEDED);
  }

void OnTick()
  {
//---
  if(scale_changed(scaleMax,scaleMin,0)){
    Comment("Scale changed to "+DoubleToString(scaleMin,_Digits)+"-"+DoubleToString(scaleMax,_Digits));
    }
  }

bool scale_changed(double &max,double &min,int subwindow){
bool change=false;
double _max=ChartGetDouble(ChartID(),CHART_PRICE_MAX,subwindow);
double _min=ChartGetDouble(ChartID(),CHART_PRICE_MIN,subwindow);
if(_max!=max||_min!=min){
change=true;
}
max=_max;
min=_min;
return(change);
}
 
Lorentzos Roussos #:

As in when the chart does that on its own  ?

Since it can change on tick (only) i'd assume a copy of the price max and price min can be kept and checked against .

Yes that's exactly what I mean (when the chart does it on its own). I was hoping that this could be handled somehow with OnChartEvent, but if that's not possible, I'll have to use some solution similar to what you suggested. Thanks.

 
Petr Nosek #:

Yes that's exactly what I mean (when the chart does it on its own). I was hoping that this could be handled somehow with OnChartEvent, but if that's not possible, I'll have to use some solution similar to what you suggested. Thanks.

Yeah , i don't think there is unless a more experienced coder has found one .