Incomplete depiction of indicator system while grabbing some color buffer?!

 
Hello people,
while working with some indicator system I experienced a misrepresentation of the values.

More exactly: the custom indicator consists of 7 buffers being used for 4 plots.

First I have a fast ma and a slow ma, which are being drawed normally as lines 

Secondly their data is copied to a second pair of buffers which are drawed as a filling.

Third I have a logic that draws wicks on every candle but changes the color depending on the first two.

Now when I call the indicator with iCustom and Copy only the color buffer in an EA the filling which is not needed in the calculation is going from the one ma all the way to the bottom. 

Am I right thinking that the compiler doesn't need the filling for the calculation of the color value (because it is calculated from the first two buffers) and therefore it sets up the calculation in a way that the filling is not depicted right?

Thanks for looking into it.
 
Tobias Johannes Zimmer:
Hello people,
while working with some indicator system I experienced a misrepresentation of the values.

More exactly: the custom indicator consists of 7 buffers being used for 4 plots.

First I have a fast ma and a slow ma, which are being drawed normally as lines 

Secondly their data is copied to a second pair of buffers which are drawed as a filling.

Third I have a logic that draws wicks on every candle but changes the color depending on the first two.

Now when I call the indicator with iCustom and Copy only the color buffer in an EA the filling which is not needed in the calculation is going from the one ma all the way to the bottom. 

Am I right thinking that the compiler doesn't need the filling for the calculation of the color value (because it is calculated from the first two buffers) and therefore it sets up the calculation in a way that the filling is not depicted right?

Thanks for looking into it.
Hard to say what's happening from what you have described. Code would help.

Did you know, you can bind the same array multiple times to different buffers? You do not need to copy the data over.
 
Dominik Egert #:
Hard to say what's happening from what you have described. Code would help.

Did you know, you can bind the same array multiple times to different buffers? You do not need to copy the data over.

Hello Dominik, thanks for your response. Can you point me to any source? Because the implementation doesn't seem so obvious.

Again the representation makes me doubt:

#property indicator_chart_window
#property indicator_buffers 4
#property indicator_plots   3

#property indicator_label1  "MAFast"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrTomato
#property indicator_style1  STYLE_SOLID
#property indicator_width1  3

#property indicator_label2  "MASlow"
#property indicator_type2   DRAW_LINE
#property indicator_color2  clrDodgerBlue
#property indicator_style2  STYLE_SOLID
#property indicator_width2  5

#property indicator_label3  "Filling"
#property indicator_type3   DRAW_FILLING
#property indicator_color3  clrYellow; clrIndianRed



//double RibFast[], RibSlow[];



input int MASlowper                     = 40;
input int  MASlowshft                   =  0;
input ENUM_MA_METHOD MASlowmode         = MODE_SMA;
input ENUM_APPLIED_PRICE MASlowtype     = PRICE_CLOSE;
double MASlow[];


input int MAFastper                     = 10;
input int  MAFastshft                   =  0;
input ENUM_MA_METHOD  MAFastmode        = MODE_SMA;
input ENUM_APPLIED_PRICE  MAFasttype    = PRICE_CLOSE;

double MAFast[];



int handle_signal, handle_trend;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0, MAFast, INDICATOR_DATA);
   SetIndexBuffer(1, MASlow, INDICATOR_DATA);
   SetIndexBuffer(2, MAFast, INDICATOR_DATA);
   SetIndexBuffer(3, MASlow, INDICATOR_DATA);
   
   ArraySetAsSeries(MAFast, true);
   ArraySetAsSeries(MASlow, true);
   //ArraySetAsSeries(RibFast, true);
   //ArraySetAsSeries(RibSlow, true);
   
   ArrayInitialize(MAFast, EMPTY_VALUE);
   ArrayInitialize(MASlow, EMPTY_VALUE);
   //ArrayInitialize(RibFast, EMPTY_VALUE);
   //ArrayInitialize(RibSlow, EMPTY_VALUE);

   PlotIndexSetDouble(0, PLOT_EMPTY_VALUE, EMPTY_VALUE);
   PlotIndexSetDouble(1, PLOT_EMPTY_VALUE, EMPTY_VALUE);
   PlotIndexSetDouble(2, PLOT_EMPTY_VALUE, EMPTY_VALUE);
   PlotIndexSetDouble(3, PLOT_EMPTY_VALUE, EMPTY_VALUE);
   
   
   
   handle_signal = iMA(_Symbol, _Period, MAFastper, MAFastshft, MAFastmode, MAFasttype);
   handle_trend = iMA(_Symbol, _Period, MASlowper, MASlowshft, MASlowmode, MASlowtype);





//---
   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[])
  {
//---

   int hhb1 = 0, llb1 = 0, hhb2 = 0, llb2 = 0, count = 0, start = 0;
   int limit = (prev_calculated == rates_total) ? (prev_calculated - 1) : (prev_calculated - rates_total);
   int to_copy = (prev_calculated == rates_total) ? 1 : (rates_total);

   ArraySetAsSeries(high, true);
   ArraySetAsSeries(low, true);

   CopyBuffer(handle_signal, 0, 0, to_copy, MAFast);
   CopyBuffer(handle_trend, 0, 0, to_copy, MASlow);

/*
   for(int i=0;i<to_copy;i++)
     {
      RibFast[i]=MAFast[i];
      RibSlow[i]=MASlow[i];
     }
*/

//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

Chart looks okay at first:

First

But then in Debugger only the filling showed and not the 2 lines:

Debug

And after that the drawing had changed:

line?

It shows only one line now. I am wondering if it is not plotting right because the rest looks okay. But this is not the problem that I opened this thread for.

Edit: It went back to normal later.

 
Tobias Johannes Zimmer #:

Hello Dominik, thanks for your response. Can you point me to any source? Because the implementation doesn't seem so obvious.

Again the representation makes me doubt:

Chart looks okay at first:

But then in Debugger only the filling showed and not the 2 lines:

And after that the drawing had changed:

It shows only one line now. I am wondering if it is not plotting right because the rest looks okay. But this is not the problem that I opened this thread for.

Edit: It went back to normal later.

I am not quite sure what the issue is, but I suspect your problem is coming from CopyBuffer function.

Maybe you can check what the results are...



Since you are not handling any errors, you will return rates_total in any case, thus on next run, you will only be copying one value with CopyyBuffer...

EDIT:
I suggest, if CopyBuffer!=to_copy, you should return 0.
 
Dominik Egert #:
I am not quite sure what the issue is, but I suspect your problem is coming from CopyBuffer function.

Maybe you can check what the results are...



Since you are not handling any errors, you will return rates_total in any case, thus on next run, you will only be copying one value with CopyyBuffer...

EDIT:
I suggest, if CopyBuffer!=to_copy, you should return 0.

Okay thanks.