Disable chart scaling
- Hide an object when the scale of a chart changes
- Scale Fix One-to-One feature
- Change timeframe of the current chart with a script doesn't work
Since no one's responding, I did some research myself. So far the best solution is to handle this problem in the OnChartEvent function. This solution does not cause annoying chart "flickering" (at least in most cases).
#define ON_SCALE_CHANGE (97) void OnChartEvent(const int id,const long& lparam,const double& dparam,const string& sparam) { long scale; // Handle custom chart event ON_SCALE_CHANGE if(id==(ON_SCALE_CHANGE+CHARTEVENT_CUSTOM)) // if the scale hasn't changed yet if((scale=ChartGetInteger(ChartID(),CHART_SCALE))==lparam) EventChartCustom(ChartID(),ON_SCALE_CHANGE,scale,0.0,""); // reset the chart scale else ChartSetInteger(ChartID(),CHART_SCALE,lparam); // keydown "+" (on numeric keyboard) if(id==CHARTEVENT_KEYDOWN && lparam==107) EventChartCustom(ChartID(),ON_SCALE_CHANGE,ChartGetInteger(ChartID(),CHART_SCALE),0.0,""); // keydown "-" (on numeric keyboard) if(id==CHARTEVENT_KEYDOWN && lparam==109) EventChartCustom(ChartID(),ON_SCALE_CHANGE,ChartGetInteger(ChartID(),CHART_SCALE),0.0,""); } #undef ON_SCALE_CHANGE
If anyone has a more elegant solution, it would be great if you would share it.
Since no one's responding, I did some research myself. So far the best solution is to handle this problem in the OnChartEvent function. This solution does not cause annoying chart "flickering" (at least in most cases).
If anyone has a more elegant solution, it would be great if you would share it.