Problem with draw multi color lines

 

Hi, I'm trying to draw 8 color lines with 8 buffer colors in one day, base on time range, but almost of them are not showed on the chart, it only shows 4 buffers on data window. I spent all day without finding the cause. Where did I go wrong? My code file attached below

The order of these buffers

#property indicator_plots   8
#property indicator_buffers 16
#define indexAL1                0
#define indexALColor1           1
#define indexAL2                2
#define indexALColor2           3
#define indexAL3                4
#define indexALColor3           5
#define indexAL4                6
#define indexALColor4           7
#define indexAL5                8
#define indexALColor5           9
#define indexAL6                10
#define indexALColor6           11
#define indexAL7                12
#define indexALColor7           13
#define indexAL8                14
#define indexALColor8           15
Files:
AL_Pure.mq5  15 kb
 
Try to set:
#property indicator_plots   16
 
dcstoyanov #:
#property indicator_plots   16

It doesn't work...

According to the documentation I only need 8 plots for each drawn color line, the color buffer no needs to be counted as a plot but just the data buffer.

Anyway thanks for your answer.

 
Sorry, I got confused by the fact that you are applying PLOT_* properties also to the INDICATOR_DATA buffers in your void BasicInit().

As in the example reported in https://www.mql5.com/en/docs/customind/indicators_examples/draw_color_line PLOT_LABEL, PLOT_DRAW_TYPE, PLOT_LINE_STYLE, PLOT_LINE_WIDTH have to be applied to the INDICATOR_COLOR_INDEX buffers.
Documentation on MQL5: Custom Indicators / Indicator Styles in Examples / DRAW_COLOR_LINE
Documentation on MQL5: Custom Indicators / Indicator Styles in Examples / DRAW_COLOR_LINE
  • www.mql5.com
DRAW_COLOR_LINE - Indicator Styles in Examples - Custom Indicators - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
dcstoyanov #:
Sorry, I got confused by the fact that you are applying PLOT_* properties also to the INDICATOR_DATA buffers in your void BasicInit().

As in the example reported in https://www.mql5.com/en/docs/customind/indicators_examples/draw_color_line PLOT_LABEL, PLOT_DRAW_TYPE, PLOT_LINE_STYLE, PLOT_LINE_WIDTH have to be applied to the INDICATOR_COLOR_INDEX buffers.

Thank you but it doesn't solve my issue, I have to find another way.

 
The problem is still not resolved, does someone have the answer for this? Or is this a Mql5 bug?
 
Le Minh Duc #: The problem is still not resolved, does someone have the answer for this? Or is this a Mql5 bug?
  1. It is almost always your code.
          How To Ask Questions The Smart Way. (2004)
              Don't rush to claim that you have found a bug.
          Questions Not To Ask
              My program doesn't work. I think system facility X is broken.

  2. Where do you define your lines with #property? Where in OnInit do you connect the lines to buffers?

  3.   ReMainLoop(limit) {
    Do not post code that will not even compile.
 
William Roeder #:
  • Where do you define your lines with #property? Where in OnInit do you connect the lines to buffers?

  • Not sure if you have actually compiled and tested my code. In the picture I sent, I can still run it normally but it cannot display properly.

    2. It is not necessary to define indicator properties using #property. I have defined it all in BasicInit() and ColorBufferInit() functions

    3. I defined it on line 18, and the file I attached can still compile normally.

     
    Le Minh Duc #:

    Not sure if you have actually compiled and tested my code. In the picture I sent, I can still run it normally but it cannot display properly.

    2. It is not necessary to define indicator properties using #property. I have defined it all in BasicInit() and ColorBufferInit() functions

    3. I defined it on line 18, and the file I attached can still compile normally.

    Why are you defining your colours (and other display properties) at runtime and with hard coded values?

    Instead, use the "#property" to define the visual properties of the various plots.

    Not only will it simplify your code, but will also allow the user to change the colours and other visual aspects to suit their preferences.

    You are over-complicating things for yourself.

     
    Fernando Carreiro #:

    Why are you defining your colours (and other display properties) at runtime and with hard coded values?

    Instead, use the "#property" to define the visual properties of the various plots.

    Not only will it simplify your code, but will also allow the user to change the colours and other visual aspects to suit their preferences.

    You are over-complicating things for yourself.

    You're right, but this doesn't answer my question.

    The problem here is that it doesn't display properly, not that it makes the program inflexible.

    In fact, after loading the indicator into the chart, the user can still change the display properties.

     
    Le Minh Duc #: You're right, but this doesn't answer my question. The problem here is that it doesn't display properly, not that it makes the program inflexible. In fact, after loading the indicator into the chart, the user can still change the display properties.

    But that in itself is an issue, because your code is "stringy" and "over complicated", making it difficult for us to read it and identify the issue. We also don't have the disposition to debug it for you either.

    Reason: