See https://www.mql5.com/en/code/34815
I wonder if this shows a bug, lack of understanding or MQ5 limitation,
I have a Color Line and a Color Histogram defined. They both work fine independently, but only one will display when they are both 'on'.
Here is the definition:
Hoping someone can say why this is not working...
When using color line or histogram, 1 plot is using 2 buffers.
Your indexing is wrong.
When using color line or histogram, 1 plot is using 2 buffers.
Your indexing is wrong.
I'm not understanding, "1 plot is using 2 buffers", seems like I'm doing that -
I have an INDICATOR_DATA and an INDICATOR_COLOR_INDEX for each (4 buffers for 2 plots). I'm also looking at the ColorLine.mq5 example (https://www.mql5.com/en/code/23), for the color line, it has 2 buffers, an INDICATOR_DATA and an INDICATOR_COLOR_INDEX buffer for its single plot.
Please elaborate.
I do think it's odd to have "#property indicator_plots 4" for only having 2 plotting types defined, but the environment clearly does not pick up the color line and the hystogram with 2 defined. Does seem to pick up with 3 defined, but then the 'Indicator Properties -> Colors' display is not as complete.
Played with the ColorLine example, this modification works:#property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 1 //--- Delete the remaining #property lines (or comment them out) -- // Replace the buffer definitions in OnInit with this: SetIndexBuffer(0,ExtColorLineBuffer,INDICATOR_DATA); ArraySetAsSeries(ExtColorLineBuffer,true); PlotIndexSetString(0,PLOT_LABEL,"Color_Line"); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetInteger(0, PLOT_DRAW_TYPE, DRAW_COLOR_LINE); PlotIndexSetInteger(0, PLOT_LINE_STYLE, STYLE_SOLID); PlotIndexSetInteger(0, PLOT_LINE_WIDTH, 3); PlotIndexSetInteger(0, PLOT_COLOR_INDEXES, 3); PlotIndexSetInteger(0, PLOT_LINE_COLOR, 0, clrRed); PlotIndexSetInteger(0, PLOT_LINE_COLOR, 1, clrGreen); PlotIndexSetInteger(0, PLOT_LINE_COLOR, 2, clrBlue); SetIndexBuffer(1,ExtColorsBuffer,INDICATOR_COLOR_INDEX); // "buffer is used for storing color indexes for the previous indicator buffer" ArraySetAsSeries(ExtColorsBuffer,true); PlotIndexSetString(1,PLOT_LABEL,"CLR_IDX"); PlotIndexSetInteger(1, PLOT_DRAW_TYPE, DRAW_NONE);
- www.mql5.com
I've convinced myself that this is a Bug or Lack of Support issue in MQ5.
Using #property to set the two plots up (DRAW_COLOR_LINE and DRAW_COLOR_HISTOGRAM) works as expected (attached File). Attempting to not use #property, but using "PlotIndexSet... " statements instead does not. Instead of using the setup as shown in post 1, the attached file uses this setup:
#property indicator_separate_window #property indicator_buffers 7 #property indicator_plots 2 #property indicator_label1 "WindLine" #property indicator_type1 DRAW_COLOR_LINE #property indicator_style1 STYLE_SOLID #property indicator_color1 clrLimeGreen,clrRed #property indicator_width1 2 #property indicator_label2 "HISTO_DECO" #property indicator_type2 DRAW_COLOR_HISTOGRAM #property indicator_style1 STYLE_SOLID #property indicator_color2 clrLimeGreen,clrRed #property indicator_width2 1 // Followed by this in OnInit ArraySetAsSeries(g_windLine,true); ArraySetAsSeries(g_windLineClrIdx,true); ArraySetAsSeries(g_histogram,true); ArraySetAsSeries(g_histogramClrIdx,true); ArraySetAsSeries(g_calcZero,true); ArraySetAsSeries(g_calcOne,true); ArraySetAsSeries(g_calcTwo,true); IndicatorSetInteger(INDICATOR_DIGITS,_Digits+1); SetIndexBuffer(0,g_windLine,INDICATOR_DATA); PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE); SetIndexBuffer(1,g_windLineClrIdx,INDICATOR_COLOR_INDEX); // "buffer is used for storing color indexes for the previous indicator buffer"" SetIndexBuffer(2,g_histogram,INDICATOR_DATA); PlotIndexSetDouble(2,PLOT_EMPTY_VALUE,EMPTY_VALUE); SetIndexBuffer(3,g_histogramClrIdx,INDICATOR_COLOR_INDEX); // "buffer is used for storing color indexes for the previous indicator buffer"" SetIndexBuffer(4,g_calcZero,INDICATOR_CALCULATIONS); PlotIndexSetDouble(4,PLOT_EMPTY_VALUE,EMPTY_VALUE); SetIndexBuffer(5,g_calcOne,INDICATOR_CALCULATIONS); PlotIndexSetDouble(5,PLOT_EMPTY_VALUE,EMPTY_VALUE); SetIndexBuffer(6,g_calcTwo,INDICATOR_CALCULATIONS); PlotIndexSetDouble(6,PLOT_EMPTY_VALUE,EMPTY_VALUE); //---- initialization done
I've convinced myself that this is a Bug or Lack of Support issue in MQ5.
Using #property to set the two plots up (DRAW_COLOR_LINE and DRAW_COLOR_HISTOGRAM) works as expected (attached File). Attempting to not use #property, but using "PlotIndexSet... " statements instead does not. Instead of using the setup as shown in post 1, the attached file uses this setup:
There is no bug, fix your code. I already said you your indexing is incorrect.
#property indicator_separate_window #property indicator_buffers 7 #property indicator_plots 2 ... PlotIndexSetDouble(5,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetDouble(6,PLOT_EMPTY_VALUE,EMPTY_VALUE);
You have 2 plots, they should be indexed 0 and 1. You are using 2, 4, 5 and 6 !
I confess that I too am at a loss to understand your explanation. I've never used two color plots at the same time, so I'm interested in the solution too.
However, I'm finding it difficult to understand you, so let me see if I can rephrase things in order to clarify them.
- From the OP's post, his buffers 4,5 & 6 are calculation buffers and not plots, so they are not relevant here I believe, and the OP has indeed put them at the end and used different values for the "indicator_buffers" and "indicator_plots".
- From the documentation about the colour buffers, they have to follow the primary buffer in index, because they are always in reference to the previous buffer and the iGator example in the documentation does that specifically:
... #property indicator_buffers 4 #property indicator_plots 2 ... SetIndexBuffer(0,GatorUpBuffer,INDICATOR_DATA); SetIndexBuffer(1,GatorUpColors,INDICATOR_COLOR_INDEX); SetIndexBuffer(2,GatorDownBuffer,INDICATOR_DATA); SetIndexBuffer(3,GatorDownColors,INDICATOR_COLOR_INDEX); ...
So, I am also unable to understand your explanation for the problem!
Please be so kind and to explain it in a little more detail please!
EDIT: The only possible wrong thing that I see in the OPs code is that he should be using "#property indicator_plots 2" instead of 4, but I don't see what is wrong with the indexing that you mention.
#property indicator_plots 2 // Instead of 4
I confess that I too am at a loss to understand your explanation. I've never used two color plots at the same time, so I'm interested in the solution too.
However, I'm finding it difficult to understand you, so let me see if I can rephrase things in order to clarify them.
- From the OP's post, his buffers 4,5 & 6 are calculation buffers and not plots, so they are not relevant here I believe, and the OP has indeed put them at the end and used different values for the "indicator_buffers" and "indicator_plots".
- From the documentation about the colour buffers, they have to follow the primary buffer in index, because they are always in reference to the previous buffer and the iGator example in the documentation does that specifically:
So, I am also unable to understand your explanation for the problem!
Please be so kind and to explain it in a little more detail please!
EDIT: The only possible wrong thing that I see in the OPs code is that he should be using "#property indicator_plots 2" instead of 4, but I don't see what is wrong with the indexing that you mention.
My previous post is clear and simple. I never talked about buffers but about plots.
2 plots are declared with #property plots 2. That means these plots will be indexed 0 and 1. In his code, the OP is using several indexes from 2 to 6 with PlotXXX functions. This is incorrect.
Beside that, to answer the OP question, using #property statement is mandatory for mql5 indicators. You can't just used dynamic statements.
There is no bug, fix your code. I already said you your indexing is incorrect.
You have 2 plots, they should be indexed 0 and 1. You are using 2, 4, 5 and 6 !
Are you telling me that the number 5 in these two statements do not refer to the same thing? If so, I have to re-think what the ColorLine example code is teaching me...
SetIndexBuffer(5,g_calcOne,INDICATOR_CALCULATIONS);
PlotIndexSetDouble(5,PLOT_EMPTY_VALUE,EMPTY_VALUE);
As near as I can tell, the code as shown that you quoted last works as expected. The indicator runs using it without any problems. I still see no way to make it work as desired - without using #property statements to define the two colored plots.
I have 2 lines to Plot, (which requires 4 buffers as they are both colored, buffers 0, 1, 2, 3). There are then 3 buffers for Indicator Calculations (which do not plot), buffers 4, 5 and 6.
My previous post is clear and simple. I never talked about buffers but about plots.
2 plots are declared with #property plots 2. That means these plots will be indexed 0 and 1. In his code, the OP is using several indexes from 2 to 6 with PlotXXX functions. This is incorrect.
Beside that, to answer the OP question, using #property statement is mandatory for mql5 indicators. You can't just used dynamic statements.
Your remarks are still confusing. Sorry!
In my case, I will try to figure it out on my own!
Thanks!
Are you telling me that the number 5 in these two statements do not refer to the same thing? If so, I have to re-think what the ColorLine example code is teaching me...
SetIndexBuffer(5,g_calcOne,INDICATOR_CALCULATIONS);
PlotIndexSetDouble(5,PLOT_EMPTY_VALUE,EMPTY_VALUE);
As near as I can tell, the code as shown that you quoted last works as expected. The indicator runs using it without any problems. I still see no way to make it work as desired - without using #property statements to define the two colored plots.
I have 2 lines to Plot, (which requires 4 buffers as they are both colored, buffers 0, 1, 2, 3). There are then 3 buffers for Indicator Calculations (which do not plot), buffers 4, 5 and 6.
Are you ever listening the answers ?
SetIndexBuffer(0,g_windLine,INDICATOR_DATA); SetIndexBuffer(1,g_windLineClrIdx,INDICATOR_COLOR_INDEX); // "buffer is used for storing color indexes for the previous indicator buffer"" PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetInteger(0,PLOT_LINE_COLOR,0,lngLineClr); PlotIndexSetInteger(0,PLOT_LINE_COLOR,1,shrtLineClr); SetIndexBuffer(2,g_histogram,INDICATOR_DATA); SetIndexBuffer(3,g_histogramClrIdx,INDICATOR_COLOR_INDEX); // "buffer is used for storing color indexes for the previous indicator buffer"" PlotIndexSetDouble(1,PLOT_EMPTY_VALUE,EMPTY_VALUE); PlotIndexSetInteger(1,PLOT_LINE_COLOR,0,lngHistClor); PlotIndexSetInteger(1,PLOT_LINE_COLOR,1,shrtHistClor); SetIndexBuffer(4,g_calcZero,INDICATOR_CALCULATIONS); SetIndexBuffer(5,g_calcOne,INDICATOR_CALCULATIONS); SetIndexBuffer(6,g_calcTwo,INDICATOR_CALCULATIONS);Plot indexed 2 to 6 DOESN'T EXIST.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
See https://www.mql5.com/en/code/34815
I wonder if this shows a bug, lack of understanding or MQ5 limitation,
I have a Color Line and a Color Histogram defined. They both work fine independently, but only one will display when they are both 'on'.
Here is the definition:
Hoping someone can say why this is not working...