Disable autoscroll by scrolling manually backwards?

 

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? 

 
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.mq4  10 kb
syncscroll.ex4  121 kb
 

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.

 
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.
 
Ex Ovo Omnia:
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.

Hey Ovo,

I try this issue too. and I just success to be disable AutoScroll triggered by chart moving.

But, I only use below for catching infomation if MT4 scrolling.

if( id == CHARTEVENT_MOUSE_MOVE ) {}

So, it works between only mouse moving.

Your SyncScroll.ex4 can do this with click & drag, scroll (without mousemoving) and keydown. I can't understand your codes.

What should I use for getting scroll chart? Any advice for me plz?

thx.

 
Ex Ovo Omnia:

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

Very interesting, but I found that to complete compilation the source code need header file "Ovo/MT4IndicatorManager.class.mqh". Could you please again post the source code of this header file?
 

This one works well for me.

if( id == CHARTEVENT_MOUSE_MOVE && ChartGetInteger( 0 , CHART_AUTOSCROLL , 0) == true ) ChartSetInteger( 0 , CHART_AUTOSCROLL, false );
Reason: