Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1131

 
Alexey Viktorov:

Artyom, you didn't notice that the type is DRAW_COLOR_HISTOGRAM2 and it has two data buffers and a third colour buffer.

Yes, that's right. Didn't pay attention.

 
Artyom Trishkin:

Yes, that's right.

In general, yes. The first buffer is used for calculations, DRAW_COLOR_HISTOGRAM2 is drawn using two coordinates/buffers + need another one for colour.


Alexey Viktorov:

Why is this line commented out

It should include other colours, though. Or at least one, but the declaration should be.

I use either

#property indicator_color2 GreenC,RedC

or

PlotIndexSetInteger(1,PLOT_LINE_COLOR,0,GreenC);
PlotIndexSetInteger(1,PLOT_LINE_COLOR,1,RedC);

I.e., it's one thing, and I assumed that they are interchangeable as in MQL4, i.e. the absence of preprocessor directive for colour setting is replaced with PlotIndexSetInteger(). Is that not the case in MQL5?

 
The_Sheikh:

In general, yes. The first buffer is used for calculations, DRAW_COLOR_HISTOGRAM2 is drawn using two coordinates/buffers + need another one for colour.


I use either

#property indicator_color2 GreenC,RedC

or

PlotIndexSetInteger(1,PLOT_LINE_COLOR,0,GreenC);
PlotIndexSetInteger(1,PLOT_LINE_COLOR,1,RedC);

i.e., it's one thing, and I assumed that they are interchangeable as in MQL4, i.e. the absence of preprocessor directive for colour setting is replaced with PlotIndexSetInteger(). Is that not the case in MQL5?

Well you're giving snippets of documentation. Why don't you study them thoroughly? Because in the example, the directive is present regardless of PlotIndexSetInteger.

 
Alexey Viktorov:

Well, you give extracts from the documentation. Why don't you study it thoroughly? The directive is present in the example regardless of PlotIndexSetInteger.

Yes, I studied the documentation and the directive is present in the example, but I'm sorry, I didn't see any paragraph in it saying that the directive must be present, so I habitually exclude the directive as in MQL4.

The documentation also says that up to 64 colours can be used for plotting. But I didn't find there a way to assign the number of such palette without monotonous listing of each colour after the directive.

Nevertheless, the question is settled.

 
The_Sheikh:

Yes, I studied the documentation, the directive is present in the example, but I'm sorry, I didn't see the paragraph, which says that the directive must be present, so out of habit I exclude the directive as in MQL4.

The documentation also says that up to 64 colours can be used for plotting. But I haven't found there a way to set the number of such palette without monotonous enumeration of each colour after the directive.

Nevertheless, I am done with the question.

And this

#define  GreenC 0x00FF00
#define  RedC 0x0000FF

can't be changed in the loop? I am not familiar with it at all and therefore do not know.

After all, a colour array can also be filled in the loop from another array. In the example, there is an array color colors = {}; where colours are listed. And then that "service" array is filled with PlotIndexSetInteger(1,PLOT_LINE_COLOR, index_in_array, colour);

 

I download quotes from different places and often see gaps of 1-2 bars, the data is just not there

How can they be filled with minimal loss of information? Are there any algorithms?

I'm sure Metatrader does it

 
Roman Sharanov:

I download quotes from different places and often see gaps of 1-2 bars, the data is just not there

How can they be filled with minimal loss of information? Are there any algorithms?

I am sure Metatrader does it.

MetaTrader does not fill the holes - if there is a bar, it will be drawn, if there is no bar, it will be skipped.

 
Vladimir Karputov:

Here's the test examiner - it all works correctly:

and the result:

Thanks for the detailed answer. It turned out that the error is observed only when testing the Expert Advisor on history, if I connect it to real data- everything is OK.

If run your expert under debugging on historical data it calculates incorrectly:

2019.10.08 02:10:14.425 2019.01.01 00:00:00 Volume 1.0, profit -> -50.00

2019.10.08 02:10:16.226 2019.01.01 00:00:00 Volume 0.5, profit -> -50.00


 
aveshoff:

Thanks for the detailed reply. It turned out that the error is observed only when testing the Expert Advisor on history, if it is connected to real data - everything is OK.

If run your expert under debugging on historical data it calculates incorrectly:

2019.10.08 02:10:14.425 2019.01.01 00:00:00 Volume 1.0, profit -> -50.00

2019.10.08 02:10:16.226 2019.01.01 00:00:00 Volume 0.5, profit -> -50.00


Please give full information: full code, symbol, timeframe, how many positions and on which symbols are open - in general to be able to reproduce the situation.

 

Good afternoon!

Can you tell me how to find out which expert it is by ID

ID 11032019, can't figure out where to find it?

Reason: