Hull moving average (HMA) colors are separate buffers MQL5

barni2002
18
barni2002  
I want the colors to be separate buffers.

The attached image shows what I want. Can anyone help me with this?

Sorry for the stupid question. I just started learning mql5

Thanks in advance to everyone

Files:
Vladimir Karputov
Moderator
246799
Vladimir Karputov  

Declare TWO plots - a blank can be easily created using the 'MQL Wizard'

//+------------------------------------------------------------------+
//|                                                  Indicator 1.mq5 |
//|                                  Copyright 2021, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   2
//--- plot HMA_Fast
#property indicator_label1  "HMA_Fast"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrLime
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- plot HMA_Slow
#property indicator_label2  "HMA_Slow"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  1
//--- input parameters
input int      Input1=9;
//--- indicator buffers
double         HMA_FastBuffer[];
double         HMA_SlowBuffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,HMA_FastBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,HMA_SlowBuffer,INDICATOR_DATA);
   
//---
   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);
  }
//+------------------------------------------------------------------+
Files:
barni2002
18
barni2002  

For appearance I want what is shown in the attached image but it doesn't work now.

I want something in which the indicator works and is properly buffered.
The picture looks good only the indicator does not work


Files:
ham4.png  14 kb
Vladimir Karputov
Moderator
246799
Vladimir Karputov  
barni2002 :

For appearance I want what is shown in the attached image but it doesn't work now.

I want something in which the indicator works and is properly buffered.
The picture looks good only the indicator does not work


Perform calculations in 'OnCalculate' and fill two indicator buffers. As a result, you will receive two lines of the indicator.

Vladimir Karputov
Moderator
246799
Vladimir Karputov  
barni2002
18
barni2002  

Thank you so much for your help so far and I am very grateful for it.

I want to solve this: I have one piece of HMA and I want to create the two colors with separate buffers.

See the attacheb the picture

Thank you.

Mladen Rakic
215961
Mladen Rakic  
barni2002:

For appearance I want what is shown in the attached image but it doesn't work now.

I want something in which the indicator works and is properly buffered.
The picture looks good only the indicator does not work


Regardless if you are using mt4 or mt5, if you decide to draw color line the way you are trying to do, and you use only 2 buffers, it will repaint

Frankly, when all it takes is to read the state of the color buffer to see the state of some colored line (and I mean not just 2 colors and all that using just 2 buffers : one drawing buffer and one color index buffer) trying to do what you are trying to do (what we were forced to do in mt4) is a waste of time

barni2002
18
barni2002  
Sorry if the wording was not completely clear.

I want to be able to reference the buffers (colors) so that I know what color they are at the moment.

The HMA colors should be separate so I can examine them.


This would be perfect, for example, but written in mql4 and not in mql5.

IT IS FORBIDDEN TO DISCUSS MARKET PRODUCTS ON THE FORUM !!!