How to set the vertical window range (shown) of a current chart window? [solved]
- EAs have no eyes, they don't need to scale the chart.
- The default is to scale to highest high/lowest low. There is no need "to set it."
- If you want to free it, add my indicator and press its button and drag the price scale.
Files:
scalefix.mq4
4 kb
Found this a while back.
I used it and changed it around to fit what i need but never really worked out.
Hope you or someone else can do better than I did.
Files:
Auto_Scale.mq4
5 kb
I solved it by following this solution:
... extern bool autoChartScaling = true; // Enable Automatic chart scaling ... void AdjustChartPrice() { ... ChartSetInteger(cid,CHART_SCALEFIX, 0, true); // Set the MODE for using a fixed chart scale ([x] Fixed MT4 option) ChartSetDouble(cid,CHART_FIXED_MAX, ymax); // Maximum chart price (height) in [points] ChartSetDouble(cid,CHART_FIXED_MIN, ymin); // Minimum chart price (height) in [points] } ... int OnInit() { ... OnChartEvent(); } void OnChartEvent(const int id, const long& lparam, const double& dparam, const string& sparam) { // Adjust the chart price Max/Min if chart window changed if (autoChartScaling && id == CHARTEVENT_CHART_CHANGE) AdjustChartPrice(); }
No indicators or scripts needed.
I'm trying to automatically scale the price range for an opened chart, in such a way that the price shown are withing a certain range.
But the documentation is so limited that the only thing I can find is about how to get the Max/Min prices, but not how to set it.
So I don't even have a good starting point to try with.
How can I automatically resale the price axis when starting an EA?