Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1274

 
alex_xss:

1) Personally, I agree, and if it were up to me, I would simply turn it off and forbid it to be included in the code. But you can't)

2) Thanks, but I haven't found any solution there (it's solved everywhere via OBJ_VLINE object, it doesn't suit me), I'm digging my own way

You can make a grid on some Canvas that some people like. Put the canvas as a background (or front) of the chart, draw over it and follow the geometry/price/time relationship.

It's a pain, but with some taste and time, it can be beautiful.

 
Maxim Kuznetsov:

you can make a grid on some Canvas favourite. Lay out the canvas as the background (or front) of the chart, draw over it and follow the geometry/price/time relationships.

It's painful, but with some taste and time it may be beautiful.

Can you write a simple example on kanvas? please

I don't know a damn thing about it, I just need a rectangle the size of a chart and a vertical line on it

 
alex_xss:

Can you write a simple example on kanvas? please

I don't know a damn thing about it, I just need a rectangle the size of a chart and a vertical line on it.

Should call @Nikolai Semko he's much better with kanvas. And while he's on the road - look at his profile there are many things on the canvas

 
alex_xss:

Can you write a simple example on kanvas? please

I don't know a damn thing about it, I just need a rectangle the size of a chart and a vertical line on it

Funny. Such a glitch only in MT4 and only with vertical lines.

Only mystery is why it interferes. I wouldn't have noticed it in my life.

Can you formulate the problem in more detail to understand the best way to solve it. The interaction of graphical objects with the canvas has nuances.
By the way, one of the possible ways of solving it is to change the manager. ))
If he/she believes that colour changing is a crutch, the more so that kanvas will be a crutch for him/her.
Although I admit that your manager is a fictional character or an allegory. ))

 

alex_xss
:

Can you write a simple example on kanvas? please

I don't know a damn thing about it, I'd just like a rectangle the size of a chart and a vertical line on it.


Not optimal in terms of performance (re-drawing happens more often than it should - just lazy to complicate the code), but it works.

You can implement a canvas for the size of the screen (not the window, for example 1920x1080) and not redraw it at all. It will just take 8 Mbytes of memory.
By the way, changing the grid colour won't help.

#include <Canvas\iCanvas.mqh> //https://www.mql5.com/en/code/23840

int OnInit()
  {
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
   if(id==CHARTEVENT_CHART_CHANGE) DrawGrid();
  }
//+------------------------------------------------------------------+
void DrawGrid() {
  Canvas.Erase(0);
  if (ChartGetInteger(0,CHART_SHOW_GRID)) {
      Canvas.SetBack(false);
      ChartSetInteger(0,CHART_FOREGROUND,0,true);
      uint clr = ColorToARGB((color)ChartGetInteger(0,CHART_COLOR_GRID),255);
      for (int y=0;y<W.Height;y++)
      if (y%6<2 || y%6>4) {
         for (int x=32;x<W.Width;x+=32)
         Canvas.m_pixels[y*W.Width+x]=clr;
      } 
  }
  Canvas.Update();
}
Files:
 
Does anyone have a function for sorting an array (string) alphabetically?
 
Aleksey Vyazmikin:
Maybe someone has a function for sorting an array (string) alphabetically?

I have one of these, once upon a time sabre wrote

//===============================================================================================
//--------------------------------- Сортирует строковой массив ---------------------------------+
//===============================================================================================
void ArraySortStr(string &Str[]) {
 string Min;
 int jMin, Size = ArraySize(Str);
  for(int i=0; i<Size-1;i++) {
   Min = Str[i];
   jMin = i;
    for(int j=i+1; j<Size; j++)
     if(Str[j] < Min) {
       Min = Str[j];
       jMin = j;
      }
     if(jMin > i) {
       Str[jMin] = Str[i];
       Str[i] = Min;
     }
   }
 }
 
Vitaly Muzichenko:

I have one of these, once upon a time a saber wrote

Thank you.

 
Maxim Kuznetsov:

We should call vertical lines.

It is a mystery why it prevents me from using it. I would never have noticed it.

Can you formulate the problem in more detail to understand the best way to solve it. The interaction of graphical objects with the canvas has nuances.
By the way, one of the possible ways of solving it is to change the manager. ))
If he/she believes that colour changing is a crutch, the more so that kanvas will be a crutch for him/her.
Although I admit that your manager is a fictional character or an allegory. ))

Yep, a cool gimmick I've spent almost a week on) My ass is on fire)

Well why would it be an obstacle. There's an indicator that uses triangles to draw. It all turns out beautifully, the colours have been picked up, and now you've noticed such a bug.
The indicator is not for personal use and it is nonsense to release it with this bug. I have to either change the entire drawing, which is quite a pain in the ass because I'm a beginner, or fix the bug.

Change the colour grid does not help, as you have noticed, I have come to this myself) Initially, some colour combinations seemed to help

Changing the grid colour (if it would help) is an unacceptable crutch, since the user may have an influence on it, in case they want to change the colour.
The option to block this function for the user is also not suitable, I think it's clear why)))

The task: to make a user see the grid, if it is enabled, with the same colour always on the screen. Taking into account bugs of MT4 with vertical grid + filled object. I don't know what else to add)

Basically the varic you wrote above is fine. I can polish it. You are a golden man!!! There are simply no words to express my gratitude. I'll give you five bucks for your help.

Just a couple of little questions:
How much lag will I get on weak PCs? I know it's an abstract question, but I'd be happy to hear from you.
"It'll just eat up 8 MB of memory" - I guess you're not talking about RAM?)) If so, 8MB is nothing like
iCanvas is a must, a regular one won't do? It's just another user saying "this file here, this file there". They're so dumb, they won't know where to put it.)

 
Good day

Please advise - answer the question

There is a Bulls.mq4 indicator in Metatrader.
Why does it need an additional buffer, and why can't you just use an intermediate variable
dd = iMA(NULL,0,InpBullsPeriod,0,MODE_EMA,PRICE_CLOSE,i);
ExtBullsBuffer[i]=dd;

The question is that ExtBullsBuffer[i] is used only to store the calculated value of iMA function result and in the next line this value is assigned to indicator buffer element. The ExtBullsBuffer is not used anywhere else. Why this intermediate buffer ExtBullsBuffer is needed here and not just a variable, as it is marked in green in the figure
***