Errors, bugs, questions - page 2976

 
Nikolai Semko:
Which drawback are you talking about?
About resource intensity?
That was a misleading statement.
Comment consumes just as many resources.
It takes 1-3 milliseconds to generate and display a canvas with text for the whole window.
In MT5, the output of comment takes slightly longer. If you are going to update text information 30 times per second, you won't see any lags.

I haven't investigated in detail why Kanvas might be slow, but I think it's for the same reason... The pixels in the array can't be selectively changed and given a redraw command. You make changes to the array first, and then you have to ResourceCreate. Which copies the pixels one by one and then, similarly, charts them out one by one and then updates the chart (ChartRedraw) some more. How many unnecessary operations... This will in any case kill the CPU load, when it's busy with useful data processing. While labels at least take less pixels (and hence output faster). And then, their output mechanism is completely inside the chart (no need to pass an array). Although I'm notentirely sure of their algorithm, I think they're faster. I used to make a text output panel based on a canvas. When visually testing the Expert Advisor with such a panel in the tester, I was not much impressed with the result. In addition to the EA's own load, the panel's redrawing was rather annoying. The panel is constantly being updated(ResourceCreate -ChartRedraw) on every tick. While I didn't notice such slowdowns with labels.

 

Either I'm a fool or the skis aren't moving? mt4 build 1320

double LotStep = SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP);
double Lot=0.7;
PrintFormat("LotStep %f, lot %f, %f, %f %f",LotStep,Lot,Lot/LotStep,MathFloor(Lot/LotStep),(int)double(Lot/LotStep));
//Print
//2021.03.07 23:42:46.507	2021.02.25 07:36:40  EA_CCIcross_v1.0 AUDJPY,M5: LotStep 0.010000, lot 0.070000, 7.000000, 6.000000 6.000000

p/s/ I understand that 7 is 6.9999 but why then 0.7 divided by 0.1 Print outputs as 7.000 not 6.9999, misleading.
 
Mihail Matkovskij:

I haven't worked out in detail why Kanvas might be slow, but I think it's for the same reason... The pixels in the array cannot be selectively changed and given a redraw command. You make changes to the array first, and then you have to ResourceCreate. Which copies the pixels one by one and then, similarly, charts them out one by one and then updates the chart (ChartRedraw) some more. How many unnecessary operations... This will in any case kill the processor load when it's busy with useful data processing. While labels at least take less pixels (and hence output faster). And then, their output mechanism is entirely within the chart (no need to pass an array). Although I'm notentirely sure of their algorithm, I think they're faster. I used to make a text output panel based on a canvas. While visually testing the Expert Advisor with such a panel in the tester, I was not much impressed by the result. In addition to the EA's own load, the panel's redrawing was rather annoying. The panel is constantly being updated(ResourceCreate -ChartRedraw) on every tick. At the same time I've never noticed such slowdowns with labels.

It's only your imagination.
Of course nothing is free, but kanvas is the fastest way to display text in MT5, because kanvas is a base and comments and labels are secondary to kanvas.
Use the unprinters if you are so greedy for your CPU resources...
 
Mihail Matkovskij :

I haven't worked out in detail why Kanvas might be slow, but I think it's for the same reason... The pixels in the array cannot be selectively changed and given a redraw command. You make changes to the array first, and then you have to ResourceCreate. Which copies the pixels one by one and then, similarly, charts them out one by one and then updates the chart (ChartRedraw) some more. How many unnecessary operations... This will in any case kill the processor load when it's busy with useful data processing. While labels at least take less pixels (and hence output faster). And then, their output mechanism is completely inside the chart (no need to pass an array ). Although I'm not entirely sure of their algorithm, I think they're faster. I used to make a text output panel based on a canvas. When visually testing the EA with such a panel in the tester, I was not much impressed with the result. In addition to the EA's own load, the panel's redrawing was rather annoying. There is a constant Update ( ResourceCreate - ChartRedraw ) on every tick. I didn't notice such slowdowns with labels.

Please don't talk about what you don't know. @Nikolai Semko is absolutely right, and Canvas works fast and without any problems or flaws.
 

@Ilyas

Compiler bug ? Build 2817.

   const ushort AN_USHORT_CONSTANT = 1;
//---
   ushort avariable = 1;

   switch(avariable)
     {
      case AN_USHORT_CONSTANT :
         Print("Compiler bug ?");
         break;
     }


 
Nikolai Semko:
It only seems to you.
Obviously, nothing is free, but kanvas is the fastest way to display text in MT5, since kanvas is the base, and comments and labels are secondary to kanvas.
Use primer if you are so greedy for your CPU resources...

How did you know that labels are based on canva, if canva itself is add-on of OBJ_BITMAP_LABEL and label is OBJ_LABEL?

While I've been chatting here on the forum, I've already sketched out the output panel on labels, with any given number of rows and columns. And for the canvas I have other tasks, in my other applications. And it works very well there too.

Alain Verleyen:
Please don't talk about what you don't know. @Nikolai Semko is absolutely right, and Canvas works quickly and without any problems or flaws.

So you probably know everything? Then maybe share your knowledge or links where you can read about charting in MetaTrader so I know what you know too? :)

 
Alain Verleyen:

@Ilyas

Compiler bug ? Build 2817.

In MQL, const is not const at all. In fact, constcan only bewritten through a macro

//const ushort AN_USHORT_CONSTANT      = 1; //(*)
#define         AN_USHORT_CONSTANT ushort(1) //(**)
void main()
{
        int i[AN_USHORT_CONSTANT];      //(1) нормально
        ushort avariable = 1;
        switch(avariable) {
        case AN_USHORT_CONSTANT:        //(2) нормально
                break;
        }
}
void f( int = AN_USHORT_CONSTANT ) {}   //(3) нормально
enum { e = AN_USHORT_CONSTANT };        //(4) нормально    
 
A100 :

In MQL, const is not const at all. In fact const can only be written through a macro

That's a mistake :-D
 
Alain Verleyen:
Yes so it is an error :-D

Note that this is not in one case, but in all (1) (2) (3) (4) it is designed this way: with (*) there will be an error, but with (**) it is OK. I.e. constants are missing as an entity

 
A100 :

Note that this is not in one case, but in all (1) (2) (3) (4) it is designed this way: with (*) there will be an error, but with (**) it is OK. I.e. constants are missing as an entity

I know. That's why I'm asking the developers to fix it.
Reason: