Download MetaTrader 5
To add comments, please log in or register
Write articles, help other developers and make money
mar
1143
mar 2016.01.27 17:28 

Hi forum,

for me it's inconvinient to disable autoscroll before I can scroll backwards. So I thought if it is possible to disable it automatically if WindowFirstVisibleBar() is above a certain number. I use chart scale 4 with a shift on the right side. So with enabled autoscroll the WindowFirstVisibleBar() function returns 76. That means if the first visible bar would be >76, I try to scroll backwards and I want autoscroll being disabled automatically.

I thought it might be a good idea to do it in a CHARTEVENT_MOUSE_MOVE:

if (id==CHARTEVENT_MOUSE_MOVE) {
   if (ChartGetInteger(0, CHART_SCALE, 0)==4) {
      if (WindowFirstVisibleBar()>76) ChartSetInteger(0, CHART_AUTOSCROLL, false);
      else ChartSetInteger(0, CHART_AUTOSCROLL, true);
   }
}

 Unfortunately, it only works this way: I scroll back with two fingers on my touchpad and when the next tick comes in, the chart jumps to the beginning without disabling autoscroll.

When I scroll back and quickly (before a tick comes in) touch the touchpad with only one finger (similar to a click), autoscroll is disabled. 

I also put the code above into the OnCalculate() to execute before the tick let's the chart jump to the beginning but that had no effect.

 

Does anyone have an idea how to solve this? Maybe with another event I am not thinking about right now? 

Ovo Cz
2953
Ovo Cz 2016.01.27 18:57  
mar:

Hi forum,

for me it's inconvinient to disable autoscroll before I can scroll backwards. So I thought if it is possible to disable it automatically if WindowFirstVisibleBar() is above a certain number. I use chart scale 4 with a shift on the right side. So with enabled autoscroll the WindowFirstVisibleBar() function returns 76. That means if the first visible bar would be >76, I try to scroll backwards and I want autoscroll being disabled automatically.

I thought it might be a good idea to do it in a CHARTEVENT_MOUSE_MOVE:

 Unfortunately, it only works this way: I scroll back with two fingers on my touchpad and when the next tick comes in, the chart jumps to the beginning without disabling autoscroll.

When I scroll back and quickly (before a tick comes in) touch the touchpad with only one finger (similar to a click), autoscroll is disabled. 

I also put the code above into the OnCalculate() to execute before the tick let's the chart jump to the beginning but that had no effect.

 

Does anyone have an idea how to solve this? Maybe with another event I am not thinking about right now? 

You may try to mine the idea from this indicator. I do not have energy to rewrite it just to answer a question.

Files:
syncscroll.ex4 121 kb
mar
1143
mar 2016.01.27 22:39  

Hi Ovo,

thanks for your code. To be honest, it is pretty hard to understand for me but I will try my best to find the autoscroll-logic you have used.

Unfortunately, I can't compile the code to see what it exactly does.

Ovo Cz
2953
Ovo Cz 2016.01.28 04:19  
mar:

Hi Ovo,

thanks for your code. To be honest, it is pretty hard to understand for me but I will try my best to find the autoscroll-logic you have used.

Unfortunately, I can't compile the code to see what it exactly does.

 

It is not for understanding the entire code, just the part where the CHART_AUTOSCROLL appears. And it cannot be compiled alone, but you have the compiled indicator to see if the code locks/unlocks the way you expect.
/
To add comments, please log in or register