I would like to , anchor chart view on th left side, so that when new price data is updated the left side stays at the same date/time position. currently if i want to view the whole chart from point a to point b
while market is live , i would need to scroll back to when market is open. hence my wish to anchor the chart on the left side.
if anyone don't mind pointing the concepts or guide for me to get started coding by myself.
apologize if my question comes off as parasitic , no effort chump.
Use once F12 to mark the start bar of the day, then, each time that you want to see all the bars accumulated during the live trading period, select the last visible bar (most recently added to the chart) and use SHIFT-F12 to mark the new end of the range.
As the article suggests, create a shortcut to Zoom to Range to make the Zoom operation more accessible.
i apologize for not explaining my question thoroughly let me clarify.
current setup:
1-minute time frame
start of day the right most edge of
chart pane with price plot updates every
minute
at every update , the chart moves to the left as
new price is plotted.
what i aim to do programatically, i.e. with out constantly pressing a chart button zoom out
re adjust chart postion, is to have the left side anchored , and whilst new data is being plotted
to keep the chart stationary and not moving.
Yes, I understand. You want to see the whole session all the time (no matter if there are 100, 200 or 500 bars - so you would like to automatically "squeeze" the chart (not scroll) as new bars appear during the session... Yes it can be done. As I wrote above - I will post example code tomorrow.
@fxshrat - thanks for the interesting code. Yes, exactly - I was thinking about a similar solution making use of ZoomToRange() each time a new bar appears or on demand. I will post my version tomorrow.
Would it be possible to use SetChartOptions to adjust the number of blankbars as the session progresses?
The number of remaining bars can be calculated using the session close time, last bar time and bar interval. The session would start with a full session’s worth of blank bars and the number of blank bars would decrease as each new bar arrives.
I just tried my approach of adjusting blank bars using SetChartOptions.
It appears that we can not reduce the number of blank bars. The first bar of the day sets a day’s worth of blank bars. Once that is set, subsequent calls to request fewer bars do not work. Changing to another symbol and back sets the expected number of blank bars. I can always increase the number, but not reduce it.
@fxshrat i am just amazed at the code right now, and have to say bit speechless, I am also studying the code to understand what you did . but you have my utmost gratitude.
Initially I was going to try another (less strict) approach comparing to @fxshrat 's solution, but after giving it some additional thoughts, I came to the conclusion, that his already presented version is better. Because my code became so similar to the above one, posting it makes no sense.
@bigalgator when using Fxshrat's code, you can change the number of blank bars in the right margin replacing 1 with 5, 10, 20 or other number in the below line.
You might also need to increase the number of blank bars (either by pressing End key or changing the default number of Blank bars in the right margin via Parameters --> Charting
Frankly, I don't like this idea, because I wouldn't like to see mostly empty chart during the session
@beppe While in general I agree with this statement, in my opinion it is not the case here because:
In those examples you won't find a code meeting the criteria of OP request.
Tomasz always warns users against using OLE from AFL, because when used improperly (especially by inexperienced people), they might impose serious problems. Because I remember some of Fourier's past codes ( an example ) I can savely assume, that he is not an experienced AFL coder. For this reason I thought it would be better if some more experienced user shows him how it should be done properly and safely.
@fxshrat 's code can be treated as addition to those mentioned examples - also because he wrapped the whole code in a function (procedure to be exact) in a similar way.
I also wrote that I was going to post an example code, because in this way, I could not only help Fourier, but also practice my coding skills and possibly learn something new. For example I like the way Fxshrat used Interval() in conjunction with SetBarsrequired() and DateTimeAdd() to show n blank bars. Personally I find replying to such posts much more interesting than explaining someone for the n'th time what every user can easily find in AB documentation or what has been already written on this forum.
For the reasons above (especially point 1 and 2) and taking into accout that the proposed code solves Fourier's request (he is very satisfied with it) and preparing the code took some time and effort, in my opinion (you know @beppe that I like you very much ) the Solution this time should go to Fxshrat.
It is not a matter of liking OLE approach or not. I might not like OLE (because of it's disadvantages mentioned many times by Tomasz in his posts and AB documentation) but there is no other option if we want to achieve this effect.