ChartNavigate during initialisation - page 4

 
Ihor Herasko:

P./S.: Just in case, I would like to clarify that I did not start to see what happens if the terminal is loaded after a long time (i.e. when many new bars are supposed to appear after the terminal has been unloaded).

 
Alexey Viktorov:

Dina, is it working for you? I've been struggling for 2-3 hours (just today, not counting yesterday's tests) trying to get a non-working version of OnInit, but to no avail. Everything always works as it should. If I put the indicator on two charts and restart the terminal, it works only on the chart which was active at the time of closing and opening the terminal. On the second, not active chart does not work. But this, in my opinion, is understandable, there is no chart rendering and no chart itself, despite the fact that the data is received.

Yes, Alexei, it works. I wrote about it here. Apparently it got visually lost in my citations of other posts.

 
Dina Paches:

Please tell me, before unloading the terminal, do you reset the chart to the most recent prices?

No, I do not. Because that is the point. Let me tell you in details why all this is necessary. A trader uses the chart as if it were a tester. The indicator hides a part of the real chart to the right of the supposedly current time (in fact, this time is somewhere in the history). Pressing F12 displays the next candle in the online chart, etc. So, it is when restarting the terminal with the indicator attached that it does not return the chart position to the place where the trader finished his studies. As a result he/she receives an empty chart because the terminal resets the chart to the last real candle. And this despite the fact that the terminal was unloaded in a completely different place.

Why do I ask:

I used your code to see how it would work in my situation. At first I thought that I was reproducing the problem you describe. Later I understood that it doesn't. If the chart is restored to the latest prices before being unloaded, it works according to the code when the terminal is loaded. If I do not return to the latest prices before unloading, the chart will remain where it was before unloading.

Interesting observation. I checked it on my own and alas, nothing has changed. I still get the freshest prices on reloading.

I suggest you "synchronise your watch". I'm testing all this on build 1861. What is your build?

 
Alexey Viktorov:

Dina, does it work for you? I've been struggling for 2-3 hours (just today, not counting yesterday's tests) trying to get a non-working version of OnInit, but all to no avail. Everything always works as it should. If I put the indicator on two charts and restart the terminal, it works only on the chart which was active at the time of closing and opening the terminal. On the second, not active chart does not work. But this, in my opinion, is understandable, there is no chart rendering and no chart itself, despite the fact that the data is received.

Put it on two charts. Unfortunately, both work in the same way - the most recent prices are displayed on reload.

What build do you have?

 
It turned out to be even more fun than I thought. Moved the code to OnCalculate (made a single triggering, not to call it on every tick ), but the picture hasn't changed. That is, even in OnCalculate when starting the terminal ChartNavigate doesn't work...
 
Alexey Viktorov:

... Only one peculiarity has been noticed: If I place the indicator on two charts and restart the terminal, it will work only on the chart that was active at the time I closed and opened the terminal. On the second, not active chart does not work. But this, in my opinion, is understandable, there is no chart rendering and no chart itself, despite the fact that the data is received.

I didn't think of trying it out that way myself. Now did such experiments (also with the help of Igor's code).

In doing so I managed to end up with... that I reproduced the problem he described.

 
Ihor Herasko:

...

I suggest we "synchronise our watches". I'm testing all this on build 1861. What's yours?

I have 1861 too. But thanks to Alexey Viktorov I managed to reproduce the problem described by you when installing via OnInit(). /* before that, it turns out, as I've seen your posts.

Order of actions: As you have describedhere.

I. But before unloading the terminal I shifted charts to the freshest prices.

And I set the indicator on two charts of one pair, different timeframes (GBPUSD M5 and GBPUSD H1).

My results are the results of these experiments:

1. I first set the indicator on GBPUSD M5 chart, then - on GBPUSD H1. After that, having shifted charts to fresh bars, I closed the terminal when GBPUSD H1 chart is active (i.e. higher timeframe is active). Under such conditions, if I open the terminal again, the chart is shifted when I open it , on the bars specified by your code.

However, if we close the terminal with active chart of GBPUSD M5 (i.e., lower timeframe is active) and then reopen the terminal, then after terminal loading, no shifts occur on either of the two charts. The charts open on fresh bars. At the same time, for one of them I get success, for the other - an error:

test 2018 06 26 (GBPUSD,M5)     Alert: Успешно
test 2018 06 26 (GBPUSD,H1)     Alert: Ошибка №4111

When performing experiments on items 1 and 2, after restarting the terminal and seeing the results, I deleted this indicator from the charts and then installed it again.


3. when I made the same experiments, but without reinstalling the indicator each time, after restarting the terminal, there is no shift of the chart after the restart of the terminal. Regardless of whether it is active with a higher or lower timeframe. The charts open on fresh bars. Messages are the same as in point 2(successful and error 4111)

II. In addition I have experimented with simultaneous installation of the indicator on the same two charts but without returning these charts before unloading the terminal to fresh bars.

The results I have: if you close/open on a higher timeframe, the chart of the higher timeframe is where it was before closing. The lower one (not active) is on the freshest.

If you open/close on a lower timeframe, the lower one will be opened on the freshest bars. Messages are the same as in 2(success and error 4111).


III. The problem has appeared now with the following:

  • I forgot to disable auto-scrolling of the chart before installing the indicator;
  • When I realized it, I deleted the indicator and installed it again.

After such resetting of the indicator the shift did not occur, but the alert was successful:

test 2018 06 26 (GBPUSD,M5)     Alert: Успешно

However, if before such re-installation of the indicator the auto-scrolling was disabled not just now, but some time later, then the problem was not detected.


Somehow.

Sounds like you should write to Service Desk.

 
Dina Paches:

It gives a success for one and an error for the other:

Now that's a surprise! I haven't yet managed to get an error from ChartNavigate. But that's something.

At the heart of the problem, apparently, I'm beginning to understand what's going on.

When the ChartNavigate() is called for the first time in OnInit() or OnCalculate(), it is highly probable that not all of the chart data has had time to be loaded yet. However, the ChartNavigate() has already worked and worked successfully (at that moment). The data are then loaded and displayed on the chart, which leads to a complete redraw and shift of the chart to its beginning. As a result, we see the chart as if it was not shifted by ChartNavigate() at all.

Therefore, in order to successfully shift the chart, we need to somehow determine that the chart data will no longer be displayed (due to history paging). Only after establishing this fact can ChartNavigate() be called.

 
Ihor Herasko:

...

Therefore, in order to successfully shift the chart, it must somehow be determined that the chart data is no longer expected to be displayed (due to history paging). Only after establishing this fact can ChartNavigate() be called.

You are right, probably. When restarting the terminal, it may become relevant. Also, while experimenting, I was interested in enabling/disabling autoscrolling in combination with (or without) resetting the ndicator. A consequence of what I described in block III, at the end of this post. But I'm not looking into this in more detail yet. I have to solve my own pressing issues. Therefore I will pass on for the time being.

 
Ihor Herasko:

Put it on two charts. Unfortunately, both work in the same way - the most recent prices are displayed on reload.

What build do you have?

Forum on trading, automated trading systems and strategy testing

ChartNavigate on initialization

Alexey Viktorov, 2018.06.25 15:10

I have 1861 as well. Only managed to reproduce it once. All other attempts worked fine.


Reason: