ChartNavigate problem

 

Hi,

 

first I apologize if this is in the wrong part of the forum, I saw no technical problems or developer section.

I have a problem with ChartNavigate() function in MQL5. I'm working on a couple of projects, some indicators and EAs; and it has come to my attention that ChartNavigate will jump the chart from your desired position to the END position, if used too frequently.

Simple test for example is a script that you can drop on any chart: 

//+------------------------------------------------------------------+
//|                                           test_ChartNavigate.mq5 |
//|                                                        Me, me ME |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Me, me ME."
#property link      "https://www.mql5.com"
#property version   "1.00"
//+------------------------------------------------------------------+
//| Script program start function                                    |
//+------------------------------------------------------------------+
void OnStart()
{
   for(int i=0;i<10000;i++)
     {
      ChartNavigate(0,CHART_END,-50);
     }
   
}

 If you run this script, the chart should stay on the same spot all the time (make sure that chart autoscroll per tick is disabled).

However, it does not.

 

Why is this and what are possible solutions?

Thank you and BR,

AT 

Automated Trading and Strategy Testing
Automated Trading and Strategy Testing
  • www.mql5.com
MQL5: language of trade strategies built-in the MetaTrader 5 Trading Platform, allows writing your own trading robots, technical indicators, scripts and libraries of functions
 
it does not it only shifts once.
 

No, "it" does not only shift once. It should shift 10000 times. To the same place. It does not. 

 

when you run the script it will shift once and the script ends.

scripts are designed like that.

if you want repeated action use indicator or expert.

 

What build are you using?

Nevermind. I just realized you do not know what a simple for loop is.

 

sure it will shift 10000 times, then script ends.

this happens in milliseconds seemingly make it look like once.

 

Really. This script should take 5 to 10 seconds on a new computer (>4ghz) with a completely empty chart. By all means, increase the number to 50000, and if that finishes in milliseconds for you, please let me know what supercomputer you're using.  

When you run the script, observe the chart carefully. It will not be hard to notice the jumping of the chart. 

Btw, thanks for trollifting my post. You may stop.

 

whatever you say buddy.

you will get a lot of help with that attitude.

 
If your help is indication of what goes around, I don't need it :)
 

For anyone looking, I solved this with a workaround; this means that the problem still persists, however I managed to bypass it mostly. 

I optimized my code to call ChartNavigate far less often than it did. This basically means that flickering has died to the point that I can try to ignore it.  However this is not a permanent solution as it does not solve the original post.

 
aries:

For anyone looking, I solved this with a workaround; this means that the problem still persists, however I managed to bypass it mostly. 

I optimized my code to call ChartNavigate far less often than it did. This basically means that flickering has died to the point that I can try to ignore it.  However this is not a permanent solution as it does not solve the original post.

This script doesn't make sense, what are you trying to achieve ?
Reason: