BUG : DRAW_FILLING and DRAW_HISTOGRAM2 can't have 2 instances in 1 indicator??

 

I want to have 2 fillings in 1 indicator, so I use DRAW_FILLING twice to get what i want (or DRAW_HISTOGRAM2  if I can't use DRAW_FILLING). For the base example, i use the official DRAW_FILLING.mq5 from

https://www.mql5.com/en/docs/customind/indicators_examples/draw_filling

The only change I did to the code was adding a 2 other buffers with the suffix ''_test'' in order to have 2 fillings. But the print in MT5 is just 1 filling. Notice how in the ''data window of MT5'', there are only 3 buffers instead of 4.


//+------------------------------------------------------------------+ 
//|                                                 DRAW_FILLING.mq5 | 
//|                        Copyright 2011, MetaQuotes Software Corp. | 
//|                                              https://www.mql5.com | 
//+------------------------------------------------------------------+ 
#property copyright "Copyright 2011, MetaQuotes Software Corp." 
#property link      "https://www.mql5.com" 
#property version   "1.00" 
  
#property description "L'indicateur pour la démonstration DRAW_FILLING" 
#property description "Dessine dans la fenêtre séparée le canal entre deux moyens" 
#property description "La couleur du remplissage du canal se change par hasard" 
#property description "dans chaques N ticks" 
  
#property indicator_separate_window 
#property indicator_buffers 2 *2
#property indicator_plots   1 *2
//--- plot Intersection 
//#property indicator_label1  "Intersection" 
//#property indicator_type1   DRAW_FILLING 
//#property indicator_color1  clrRed,clrBlue 
//#property indicator_width1  1
//--- les paramètres input 
input int      Fast=13;          // la période de la glissante moyenne rapide 
input int      Slow=21;          // la période de la glissante moyenne lente 
input int      shift=1;          // le décalage des moyennes au futur (positif) 
input int      N=5;              // le nombre de ticks pour le changement  
//--- les paramètres input 
input int      Fast_test=3;          // la période de la glissante moyenne rapide 
input int      Slow_test=9;          // la période de la glissante moyenne lente 
input int      shift_test=6;          // le décalage des moyennes au futur (positif) 
input int      N_test=5;              // le nombre de ticks pour le changement  
//--- les tampons d'indicateur 
double         IntersectionBuffer1[]; 
double         IntersectionBuffer2[]; 
int fast_handle; 
int slow_handle; 
double         IntersectionBuffer1_test[]; 
double         IntersectionBuffer2_test[]; 
int fast_handle_test; 
int slow_handle_test; 
//--- le tableau pour le stockage des couleurs 
color colors[]={clrRed,clrBlue,clrGreen,clrAquamarine,clrBlanchedAlmond,clrBrown,clrCoral,clrDarkSlateGray}; 
color colors_test[]={clrRed,clrBlue,clrGreen,clrAquamarine,clrBlanchedAlmond,clrBrown,clrCoral,clrDarkSlateGray}; 
//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
int OnInit() 
  { 
//--- indicator buffers mapping 
   SetIndexBuffer(0,IntersectionBuffer1,INDICATOR_DATA); 
   SetIndexBuffer(1,IntersectionBuffer2,INDICATOR_DATA); 
   SetIndexBuffer(2,IntersectionBuffer1_test,INDICATOR_DATA); 
   SetIndexBuffer(3,IntersectionBuffer2_test,INDICATOR_DATA); 
//--- 
   PlotIndexSetInteger(0,PLOT_DRAW_TYPE,DRAW_FILLING);
   PlotIndexSetInteger(2,PLOT_DRAW_TYPE,DRAW_FILLING);
//--- 
   PlotIndexSetString(0,PLOT_LABEL,"IntersectionBuffer1");
   PlotIndexSetString(1,PLOT_LABEL,"IntersectionBuffer2");
   PlotIndexSetString(2,PLOT_LABEL,"IntersectionBuffer1_test");
   PlotIndexSetString(3,PLOT_LABEL,"IntersectionBuffer2_test");
//--- 
   PlotIndexSetInteger(0,PLOT_SHIFT,shift);
   PlotIndexSetInteger(2,PLOT_SHIFT,shift_test); 
//--- 
   fast_handle=iMA(_Symbol,_Period,Fast,0,MODE_SMA,PRICE_CLOSE); 
   slow_handle=iMA(_Symbol,_Period,Slow,0,MODE_SMA,PRICE_CLOSE);
//--- 
   fast_handle_test=iMA(_Symbol,_Period,Fast_test,0,MODE_EMA,PRICE_CLOSE); 
   slow_handle_test=iMA(_Symbol,_Period,Slow_test,0,MODE_EMA,PRICE_CLOSE); 
//--- 
   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[]) 
  { 
   static int ticks=0; 
//--- calculons les ticks pour le changement du style, de la couleur et de l'épaisseur de la ligne 
   ticks++; 
//---si s'est accumulé le nombre suffisant des ticks 
   if(ticks>=N) 
     { 
      //--- changeons les propriétés de la ligne 
      ChangeLineAppearance(); 
      //---oblitérons le compteur des ticks au zéro 
      ticks=0; 
     } 
  
//---faisons le premier calcul de l'indicateur ou les données sont changées et on demande la recalculation complète 
   if(prev_calculated==0) 
     { 
      //--- copions toutes les valeurs des indicateurs dans les tampons correspondants 
      int copied1=CopyBuffer(fast_handle,0,0,rates_total,IntersectionBuffer1); 
      int copied2=CopyBuffer(slow_handle,0,0,rates_total,IntersectionBuffer2); 
      
      int copied1_test=CopyBuffer(fast_handle_test,0,0,rates_total,IntersectionBuffer1_test); 
      int copied2_test=CopyBuffer(slow_handle_test,0,0,rates_total,IntersectionBuffer2_test); 
     } 
   else // remplissons économiquement seulement les données, qui sont mises à jour 
     { 
      //--- recevrons la différence dans les barres entre le lancement actuel et précédente OnCalculate() 
      int to_copy=rates_total-prev_calculated; 
      //--- s'il n'y a pas de différence, en tout cas copions une seule valeur - sur la barre nulle 
      if(to_copy==0) to_copy=1; 
      //--- copions to_copy des valeurs à la fin de tampons d'indicateur 
      int copied1=CopyBuffer(fast_handle,0,0,to_copy,IntersectionBuffer1); 
      int copied2=CopyBuffer(slow_handle,0,0,to_copy,IntersectionBuffer2); 
      
      int copied1_test=CopyBuffer(fast_handle_test,0,0,to_copy,IntersectionBuffer1_test); 
      int copied2_test=CopyBuffer(slow_handle_test,0,0,to_copy,IntersectionBuffer2_test); 
     } 
//--- return value of prev_calculated for next call 
   return(rates_total); 
  } 
//+------------------------------------------------------------------+ 
//| change les couleurs du remplissage du canal                                   | 
//+------------------------------------------------------------------+ 
void ChangeLineAppearance() 
  { 
//--- la ligne pour la formation de l'information sur les propriétés de la ligne 
   string comm=""; 
   string comm_test=""; 
//--- le bloc du changement de la couleur de la ligne 
   int number=MathRand(); // recevrons le nombre accidentel 
   int number_test=MathRand(); // recevrons le nombre accidentel 
//--- le diviseur du nombre est égal au montant du tableau colors[] 
   int size=ArraySize(colors); 
   int size_test=ArraySize(colors_test); 
  
//--- recevrons l'index pour le choix de la nouvelle couleur comme le reste de la division entière 
   int color_index1=number%size; 
   
   int color_index1_test=number_test%size_test; 
//--- définissons la première couleur comme la propriété PLOT_LINE_COLOR 
   PlotIndexSetInteger(0,PLOT_LINE_COLOR,0,colors[color_index1]); 
   
   PlotIndexSetInteger(2,PLOT_LINE_COLOR,0,colors_test[color_index1_test]); 
//--- inscrirons la première couleur 
   comm=comm+"\r\nColor1 "+(string)colors[color_index1]; 
   comm_test=comm_test+"\r\nColor1 "+(string)colors_test[color_index1_test]; 
  
//--- recevrons l'index pour le choix de la nouvelle couleur comme le reste de la division entière 
   number=MathRand(); // recevrons le nombre accidentel 
   int color_index2=number%size; 
   
   number_test=MathRand(); // recevrons le nombre accidentel 
   int color_index2_test=number_test%size_test; 
//--- définissons la deuxième couleur comme la propriété PLOT_LINE_COLOR 
   PlotIndexSetInteger(0,PLOT_LINE_COLOR,1,colors[color_index2]); 
   PlotIndexSetInteger(2,PLOT_LINE_COLOR,1,colors_test[color_index2_test]); 
//--- inscrirons la deuxième couleur 
   comm=comm+"\r\nColor2 "+(string)colors[color_index2]; 
   comm_test=comm_test+"\r\nColor2 "+(string)colors_test[color_index2_test]; 
//--- déduisons l'information sur le graphique par le commentaire 
   Comment(comm+"\r\n"+comm_test); 
  }
Documentation on MQL5: Custom Indicators / Indicator Styles in Examples / DRAW_FILLING
Documentation on MQL5: Custom Indicators / Indicator Styles in Examples / DRAW_FILLING
  • www.mql5.com
DRAW_FILLING - Indicator Styles in Examples - Custom Indicators - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
bump. how to get 2 DRAW_FILLING in 1 indicator?
 
Enaud #:
bump. how to get 2 DRAW_FILLING in 1 indicator?
Look at here
Two Stochastic Custom Filling
Two Stochastic Custom Filling
  • www.mql5.com
Две линии 'Main' от двух индикаторов iStochastic (Stochastic Oscillator, STO) с заливкой областей между линиями
 

yes but this is to have 2 colors. I really want to have 2 independent ribbons, and each ribbon will be filled independently from the other. it's really cramming 2 different indicators into one.
 
Enaud #:

yes but this is to have 2 colors. I really want to have 2 independent ribbons, and each ribbon will be filled independently from the other. it's really cramming 2 different indicators into one.
//--- plot Filling
#property indicator_label3  "Filling"
#property indicator_type3   DRAW_FILLING
#property indicator_color3  C'236,236,255',C'255,236,236'
#property indicator_style3  STYLE_SOLID
#property indicator_width3  1
 
Tretyakov Rostyslav #:

I doubled the buffers to have 4 stochastics in total and 2 PAIRS of DRAW_FILLING. it turns out my added stochastics are not drawn look at the picture

Where are  StochFastMainBuffer2, StochSlowMainBuffer2, FillingBuffer12 , FillingBuffer22 ??


MESSAGE By MQL5 FORUM : Message may not exceed 64000 characters


so I posted the code here

https://pastebin.com/TnScEzjH
 

please help.

how to have 2 DRAW_FILLING in 1 indicator ?

 
bump