Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1034

 
The_Sheikh:

Hello, can someone explain in clear terms what are"Plots" in MQL5? They are not related to buffers, but the indicator_plots property creates a list of drawing object properties similar to buffers. When using MQL4 tools, it was clear that a reference was made to a specific drawing object, and now there is a new preprocessor propertyindicator_plots that defines the number of what is unclear.

In MQL4, the number of buffers to be displayed was specified using the

#property indicator_buffers 1

In the OnInit() function, you can add several buffers for calculations

IndicatorBuffers(3);

And in MQL5, the same thing is written in two directives

#property indicator_buffers 3
#property indicator_plots   1

It means that there are 3 buffers in total, while 1 buffer will be displayed on the chart. The other two will be used for calculations. And in MQL5, one of the additional ones can be used for colour displaying.

 
fxsaber:

It is probably clearer to understand if you run this indicator in MT4 and MT5. When converting to MT5 I had to use plots

Because only two buffers should be drawn.

Already closer to the truth. But in that case what if the second and the sixth buffers should be drawn? Is there no way?

Alexey Viktorov:

We could add several buffers for calculations inthe OnInit() function

By the way, is there an alternative to this function in MQL5?

 
The_Sheikh:

This is closer to the truth. But in that case, what if the second and sixth are to be drawn? Nothing?

I don't know.

 
The_Sheikh:

This is closer to the truth. But in that case, what if the second and sixth are to be drawn? No way?

1) "Second and sixth" - you decide the distribution of numbers ;)

2) INDICATOR_CALCULATIONS and DRAW_NONE vs INDICATOR_DATA and non-DRAW_NONE (any other) works for any sequence number.

 
The_Sheikh:

This is closer to the truth. But in that case, what if the second and sixth are to be drawn? No way?

You just set the buffer type, which one will be shown, which one will contain colour and which one will contain only auxiliary values.


INDICATOR_DATA

Drawing data

INDICATOR_COLOR_INDEX

Rendering colours

INDICATOR_CALCULATIONS

Additional buffers for intermediate calculations

 
The_Sheikh:

By the way, is there an alternative to this function in MQL5?

There is no need for such a function in mql5. I gave you an example of how to write it. The difference with mql4 is only in sequence and spelling.

 
Thank you all for responding!
 

Suppose the maximum number of bars on the chart is set at 10000. Then in the script and the indicator, the Bars() function returns the number specified in the settings + the number of new candlesticks appeared.

So, the number of candlesticks shown in the chart will not be limited to 10000?

How can I know in MQL exactly the number specified in the terminal settings?

If the number of bars reaches the maximum int type, what will happen to the number of candlesticks and positions of array elements?

 
The_Sheikh:

How do I know in MQL exactly how many bars are set in the terminal settings?

TerminalInfoInteger(TERMINAL_MAXBARS))
The_Sheikh:

If the number of bars reaches the maximum value of int type, then what will happen to the number of candlesticks

the number of bars will increase, i.e. it will exceed theTERMINAL_MAXBARS value

And then, by some unknown algorithms, the terminal "resets the extra bars" - when the actual number of bars in the chart will be in the const int rates_total, it will be in the iBars()https://www.mql5.com/ru/docs/series/ibars

i.e., as shown above - TERMINAL_MAXBARS is data from the terminal window, and iBars() is the actual value of bars on the chart


The_Sheikh:

and with positions of elements of arrays-timeseries?

if we are talking about indicator buffers, the terminal allocates memory for them and the size of the array, associated with the indicator buffer, is always equal to rates_total elements

indicator for testing:

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[])
  {
//---
   static datetime t=0;
   if(t!=time[rates_total-1])
     {
      Print("rates_total = ",rates_total, ", TERMINAL_MAXBARS = ",TerminalInfoInteger(TERMINAL_MAXBARS));
      t=time[rates_total-1];
     }
//--- return value of prev_calculated for next call
   return(rates_total);
  }

indicator log:

2019.04.30 19:10:12.247 rates (EURUSD,M1) rates_total = 50000, TERMINAL_MAXBARS = 50000

2019.04.30 19:10:29.699 rates (EURUSD,M1) rates_total = 50001, TERMINAL_MAXBARS = 50000

2019.04.30 19:11:29.392 rates (EURUSD,M1) rates_total = 50002, TERMINAL_MAXBARS = 50000

2019.04.30 19:12:30.125 rates (EURUSD,M1) rates_total = 50003, TERMINAL_MAXBARS = 50000


Документация по MQL5: Доступ к таймсериям и индикаторам / iBars
Документация по MQL5: Доступ к таймсериям и индикаторам / iBars
  • www.mql5.com
Количество баров в истории по соответствующему символу и периоду, но не более чем задано в настройках платформы параметром "Макс. баров в окне" ("Max bars in chart")
 

I want to get acquainted with developing interfaces in MQL5 on EasyAndFastGUI

There are 10 parts (or what?) of"Graphical Interfaces" articles from 2015

I have a question, are they all consistent, or is there no point in reading the older ones?

Reason: