Disable autoscroll by scrolling manually backwards?

Back to topics list To post a new topic, please log in or register
avatar
371
mar 2016.01.27 18: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? 

avatar
1109
Ovo 2016.01.27 19: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.

 

Attached files:
  syncscroll.mq4  (9.59 KB)
  syncscroll.ex4  (120.24 KB)
avatar
371
mar 2016.01.27 23: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.

 

avatar
1109
Ovo 2016.01.28 05: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.
Back to topics list  

To add comments, please log in or register