Maintaining constant chart appearance on multiple time frames by code?

 

I could not think of a more descriptive title.


What I would like to do is have one chart window on which are drawn all my objects.

I use 3 different time frames and when I click the button to change between these time frames I would like the chart to present itself in the same way every time so that I get a constant visual effect for each time frame.


For example

On 30m chart I would like candles for the past 2 weeks and I am happy to allow the automatic re scaling of chart height to take place so price fits from top to bottom

On 5m chart I would like candles from the past 9 hours or so and I would like the vertical scale to be 70 pips even if price within those 9 hours fall outside that 70 pip range. I would like the chart to initially appear with the current price half way up the screen

On 1m chart I would like the vertical scale to be 40 pips but with candles only going back 90 minutes (say). Once again the current price should be in the middle of this range


So using ONE chart only, I want the parameters above to be implemented if I change the time frame.


Is this possible?


Thanks a lot


Trevor

 
On Mt4 or Mt5 ?
 

Sorry should have said MT4


Thanks

 

So essentially , a list of the 9 timeframes followed by a lock/unlock viewport mechanism for that chart .

 

OK, I think I have discovered a little more.


I had switched off scale fix 1:1 and just set the fixed max and fixed minimum to give the number of pips from top to bottom but that of course will change the appearance as I move between TF


So now I have tried using scale fix 1:1 and I see that the platform decides what number of pips are on the y axis based on how far zoomed in I am 

e.g. when I only have 50 candles on the chart on a 1m TF which is spanning a 50cm wide chart window then a 4.5 pip bar is 4.5cm high. and the height of the y axis is 31 pips versus my 31cm high chart window

When I zoom in to 100 candles the range doubles and the size of bar heights halve


I have read somewhere that using 1:1 is better for line studies so if I kept that then the appearance would be decided by how many bars were on the chart.

On the 1m chart if I zoom in as much as possible using the + key I get 50 candles and about a 31 pip y axis and TBH that is probably OK

On the 5m  if I get 100 candles and and 100*5 = 500 mins time and that is OK as well on that second level of zoom. I also get height of about 62 pips

To get the 30m chart I just need to zoom a for more times


So it looks as if I use fix 1:1 then when changing TF I just need to a) set a different number of bars (zoom?) b) centre price in vertical plane.


Does this sound about right? Can that be done automatically?


Cheers


Trevor

 
  1. Trevor Duddle: Sorry should have said MT4

    Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
              General rules and best pratices of the Forum. - General - MQL5 programming forum?
    Next time post in the correct place. The moderators will likely move this thread there soon.


  2. Trevor Duddle:

    I had switched off scale fix 1:1 and just set the fixed max and fixed minimum to give the number of pips from top to bottom but that of course will change the appearance as I move between TF

    Can that be done automatically?

    Code an indicator to do that.

    You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

    Or pay someone. Top of every page is the link Freelance.
              Hiring to write script - General - MQL5 programming forum 2018.05.12

 

Sorry William  - new here.


Thanks for your advice


Cheers


Trevor

Reason: