Errors, bugs, questions - page 310

 

How is it different ?

CHART_WIDTH_IN_BARS Ширина графика в барах
от
CHART_VISIBLE_BARS Количество баров на графике, доступных для отображения
 
Urain:

How is it different ?

There may be an empty field on the right, if an indentation is set. In this case CHART_VISIBLE_BARS will show a smaller value than CHART_WIDTH_IN_BARS
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы графиков / Свойства графиков
Документация по MQL5: Стандартные константы, перечисления и структуры / Константы графиков / Свойства графиков
  • www.mql5.com
Стандартные константы, перечисления и структуры / Константы графиков / Свойства графиков - Документация по MQL5
 
Urain:

How is it different ?

Literally different.


 
Rosh:
What is the question?

1. take the script twisted to the post and execute on the chart. The script should copy a certain number of bars and perform unwinding of the 20 oldest ones.

This way is used (I understand there are no checks and all sorts of traps for errors, but still)

int  CopyRates(
   string           symbol_name,       // имя символа
   ENUM_TIMEFRAMES  timeframe,         // период
   int              start_pos,         // откуда начнем 
   int              count,             // сколько копируем
   MqlRates         rates_array[]      // массив, куда будут скопированы данные
   ); 

So with those parameters that I specified (number of bars and M1) the script runs but sometimes it refuses to work NORMALLY. It happens at a certain number of bars (I got more than 368700).

At 368800 it returns much less bars (but always a different number - 368732 / 368735 / 368736 or something in this vicinity).

But it doesn't always work correctly even at 360000, there were cases when it just copied 10000 bars.

2. The variant where two dates are specified really shocked me. Not only it wouldn't accept 0 as the first date (which makes sense in my opinion) but it also copies up to 10000.

Although with 0 as int as start_time it's understandable (I have experience), it's all about functions overloading and compiler "not understanding" certain things. But that's why 10000 bars is a separate question which is called "in a million".

The 10,000 minute bars as we understand it will not go beyond 2011, if I understand correctly, they will not go beyond February (and as it becomes clear from all of the above at least 360000 is loaded for sure).

int  CopyRates(
   string           symbol_name,       // имя символа
   ENUM_TIMEFRAMES  timeframe,         // период
   datetime         start_time,        // с какой даты
   datetime         stop_time,         // по какую дату
   MqlRates         rates_array[]      // массив, куда будут скопированы данные
   ); 

PS

At the same time, the speed of normal and "buggy" (when the script copies only 10000 bars) differs many times over.

PPS

Please make sure you bring certain sections of help (or rather their examples) to their logical conclusion, to avoid ambiguity and other "silly" situations.

Checks should be placed additionally, etc. Also, in this case there are no cross references in parameter descriptions (at least in timeframe) and it is not clear what type start_time and start_pos have.I guess that datetime (otherwise why would the compiler swear by 0 as start_time).

//Код по третьему варианту, может я что-то упустил?
//Так ругается - 'CopyRates' - ambiguous call to overloaded function
Copied = CopyRates(Symbol(),PERIOD_M1,0,TimeCurrent(),Rates);
//Так нет, но копирует только 10000 баров
Copied = CopyRates(Symbol(),PERIOD_M1,(datetime)0,TimeCurrent(),Rates);
 

Is this a bug or my lack of skill?

void OnStart()
  {
//---
   long chart_id=ChartID();
   ChartSetInteger(chart_id,CHART_AUTOSCROLL,false);   // отключаем автоскролл
   while(!IsStopped())
     {
      //------------------      
      ChartNavigate(chart_id,CHART_END,-2410); // делаем навигацию, поставим константу
      //------------------
      Sleep(500);
      ChartSetString(chart_id,CHART_COMMENT,ChartGetInteger(chart_id,CHART_FIRST_VISIBLE_BAR));
      ChartRedraw(chart_id);// отображаем первый бар чарта после навигации
      Sleep(500);
     }        
  }


The chart jerks when navigating from zero bar. I purposely inserted slips between navigation and update to highlight the problem. But the bug exists even without slips. It turns out that ChartNavigate() first moves the chart to zero and then moves it back. In addition, it does not do this every time.

At least, the fact that the bug does not exist every time you call ChartNavigate(), it appears when you run it without slips.

Документация по MQL5: Операции с графиками / ChartNavigate
Документация по MQL5: Операции с графиками / ChartNavigate
  • www.mql5.com
Операции с графиками / ChartNavigate - Документация по MQL5
 
Urain:

Is this a bug or my lack of skill?


The chart jerks when navigating from zero bar. I purposely inserted slips between navigation and update to highlight the problem. But the bug exists even without slips. It turns out that ChartNavigate() first moves the chart to zero and then moves it back. In addition, it does not do this every time.

At least, the fact that the bug does not exist every time you call ChartNavigate(), it appears when you run it without slips.


Try the example from ChartNavigate function doesn't work, Please help
 
Rosh:
Try the example from the branch ChartNavigate function doesn't work, Please help

So, what is there in this example that is so fundamentally different from my code?

It's just that in your code navigation is called once, whereas I need to hold the chart on the desired bar all the time (regardless of user actions).

I tried your example and ran my code without chart update (although it's important to me because the program uses a lot of graphical transformations), but it didn't work either. The jerk remains. I still navigate to the same point, and then navigate to the zero bar.

I also find using navigation from the current bar unacceptable, because the user can inadvertently move the chart while the program is running.

 
If it is not immediately clear, let me explain: the above code is an attempt to emulate an autoscroll on a given bar.
 
Interesting:
Is the story all tucked away?
of course there is a story, but not all worms have a history of spreading!
 
Urain:

So, what is there in this example that is so fundamentally different from my code?

It's just that in your code navigation is called once, while I need to keep the chart on the desired bar all the time (regardless of user's actions).

After reviewing your example, ran my code without chart refresh (although it's important to me since the program also uses a bunch of graphic conversions), but it didn't help either. The jerk remains. I still navigate to the same point, and then navigate to the zero bar.

I also find using navigation from the current bar unacceptable, because the user can inadvertently move the chart while the program is running.

I have the same problem with my indicator, only it is redrawn as soon as the tick comes and it is not clear how to fix it?
Reason: