I want to stop the y axis scale to automatically shrink or stretch when the chart is moved from left to right, because it compress or stretch the candle stick, which is not desirable.
Per unit height of y axis must be fixed with fixed number of PIPs or currency value so that even when the chart is moved left or right the candle heights are intact and are not distorted when the chart is moved. And then the chart must be able to be moved up and down by moving the cursor on the y axis.
Is there any setting or afl code for this ?
This might be what you need…
Right Click on your price chart, Select Parameters from the list, then Click on Axes & Grid.
In the Axes Section change the Scaling Parameter from Automatic to Custom.
Hope this helps.
Thankyou for your reply. But my expectation is something more. I have tried your method and this can also be done by using “SetChartOptions” function.
This method will lock the chart and you will not be able to move the chart up or down by moving the cursor on y axis. Y axis scale has to fixed per unit value of PIP or currency and I must also be able to move the chart up and down by moving the cursor over y axis without shrinking or stretching the candles. That is the technique / code I want.
Have you tried “clicking and holding” in the y-axis.
You should get a double headed arrow and you can drag the scale.
This is the manual method.
Warning, as you scroll left/right, you could lose sight of the candles in your chart and assume that there is an issue, when in fact, it is user issue.
Hope this helps…
As requested above by Manoj earlier, is there a way where Y axis scale has to be fixed per unit value of PIP or currency and one should be able to move the chart up and down by moving the cursor over y axis without shrinking or stretching the candles. Please, let me know your comments.
This is possible, but you have to do a bit of coding to make it work. The trick is to manipulate the 'ymin' and 'ymax' values of the 'SetChartOptions' function.
Also @trader123 I don't know if this will be helpful, but you are not limited to only using the price scale to drag to move the chart up and down - I have mine setup so that when I drag on empty areas of the chart, it will move the chart vertically.
How do you keep the vertical scale constant in an indicator panel so that it does not use min/max visible values to set the scale? So that the scale is fixed or is a set range?
You could add some code to the indicator to plot some "fake" Min and Max values to keep the scale to what you want.
- There is zero code required to get fix y-min and y-max
All you have to do is opening Parameter window
And go to tab Axes&Grid there, set Scaling to Custom and set fix minimum and maximum values.
- If (alternatively) using code level then all you have to do is modifying SetChartOptions() function's y-min, y-max arguments e.g.,
min_y = 30;
max_y = 70;
SetChartOptions(1, chartShowDates | chartShowArrows, chartgridMiddle, min_y, max_y);
Plot( RSI(), "", colorRed, styleLine);
I tried to manipulate ymin & ymax. It is only accepting string/constants. It is not accepting variables. So coding with upper limit and lower limit is very much restricted with "SetChartOptions". And I do not find any suitable afl function for this coding.
@manoj - it does work, I use it on many of my charts where I want to keep a constant height/width ratio of the chart. Can you post the code of what you are trying so we can take a look?