Indikator zeichnet Dinge, die eigentlich nicht sichtbar sein sollten

 

Hallo, ich habe einen MA Ribbon Indikator:

#property indicator_chart_window

#property indicator_buffers   5
#property indicator_plots     3

#property indicator_type1     DRAW_FILLING
#property indicator_label1    "Channel FastMA; Channel SlowMA"
#property indicator_color1    clrYellow,clrFireBrick

#property indicator_type2     DRAW_LINE
#property indicator_label2    "SlowMA"
#property indicator_color2    clrGray
#property indicator_style2    STYLE_SOLID
#property indicator_width2    2

#property indicator_type3     DRAW_LINE
#property indicator_label3    "FastMA"
#property indicator_color3    clrBlue
#property indicator_style3    STYLE_SOLID
#property indicator_width3    2

input ENUM_APPLIED_PRICE   InpAppliedPrice         = PRICE_CLOSE; // type of price

input int                  InpSlowMAPeriod         =        34; // Slow EMA Period
input ENUM_MA_METHOD       InpSlowMAMode           =  MODE_EMA; // Slow EMA Mode

input int                  InpFastMAPeriod         =        13; // Fast EMA Period
input ENUM_MA_METHOD       InpFastMAMode           =  MODE_EMA; // Fast EMA Mode

input int                  InpSignalMAPeriod       =         5; // Signal Period
input ENUM_MA_METHOD       InpSignalMAMode         =  MODE_EMA; // Signal Mode
//+------------------------------------------------------------------+
double BufferFastChannel[], BufferSlowChannel[];
double BufferFast[], BufferSlow[], BufferSignal[];

int MaxPeriod;

int FastHandle, SlowHandle, SignalHandle;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit() {
   
   SetIndexBuffer(0,BufferFastChannel,INDICATOR_DATA);
   SetIndexBuffer(1,BufferSlowChannel,INDICATOR_DATA);
   SetIndexBuffer(2,BufferSlow,INDICATOR_DATA);
   SetIndexBuffer(3,BufferFast,INDICATOR_DATA);
   SetIndexBuffer(4,BufferSignal,INDICATOR_DATA);
   
   MaxPeriod = (int)MathMax(MathMax(InpSignalMAPeriod,InpFastMAPeriod),InpSlowMAPeriod);
   
   SlowHandle = iMA(_Symbol,_Period,InpSlowMAPeriod,0,InpSlowMAMode,InpAppliedPrice);
   FastHandle = iMA(_Symbol,_Period,InpFastMAPeriod,0,InpFastMAMode,InpAppliedPrice);
   SignalHandle = iMA(_Symbol,_Period,InpSignalMAPeriod,0,InpSignalMAMode,InpAppliedPrice);
   
   PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,MaxPeriod);
   PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,MaxPeriod);
   PlotIndexSetInteger(2,PLOT_DRAW_BEGIN,MaxPeriod);
   
   
   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[])
{
   
   if(IsStopped()) return 0; // Überprüfe, ob mql5 zwangsbeendet 
   
   if(rates_total < MaxPeriod) return 0;  // Überprüfe, dass genug Kerzen zum berechnen verfügbar sind
   
   //Überprüfe, dass alle MAs berechnet wurden
   if(BarsCalculated(SlowHandle) < rates_total)    return 0;
   if(BarsCalculated(FastHandle) < rates_total)    return 0;
   if(BarsCalculated(SignalHandle) < rates_total)  return 0;
   
   int copyBars = 0;
   int startBar = 0;
   
   if(prev_calculated > rates_total || prev_calculated <= 0) {
      copyBars = rates_total;
      startBar = MaxPeriod;
   } else {
      copyBars = rates_total - prev_calculated;
      if(prev_calculated > 0) copyBars++;
      startBar = prev_calculated - 1;
   }
   
   if(IsStopped()) return 0;        // Überprüfe, ob mql5 zwangsbeendet 
   if(CopyBuffer(SlowHandle,0,0,copyBars,BufferSlowChannel) <= 0) return 0;
   if(CopyBuffer(FastHandle,0,0,copyBars,BufferFastChannel) <= 0) return 0;
   if(CopyBuffer(SlowHandle,0,0,copyBars,BufferSlow) <= 0) return 0;
   if(CopyBuffer(FastHandle,0,0,copyBars,BufferFast) <= 0) return 0;
   if(CopyBuffer(SignalHandle,0,0,copyBars,BufferSignal) <= 0) return 0;
   
   if(IsStopped()) return 0;        // Überprüfe, ob mql5 zwangsbeendet 
   for(int i = startBar; i < rates_total && !IsStopped(); i++) {
      if(   (BufferFast[i] >= BufferSlow[i] && BufferSignal[i] < BufferFast[i]) ||
            (BufferFast[i] < BufferSlow[i] && BufferSignal[i] > BufferFast[i])   ) {
         BufferFast[i] = EMPTY_VALUE;
         BufferSlow[i] = EMPTY_VALUE; 
         BufferFastChannel[i] = EMPTY_VALUE;
         BufferSlowChannel[i] = EMPTY_VALUE;     
      }
   }
   
   return(rates_total); //rates_total wird zu prev_calculated im nächsten Durchlauf
}
//+------------------------------------------------------------------+

void onDeinit(const int reason) {
   if(SlowHandle != INVALID_HANDLE) IndicatorRelease(SlowHandle);
   if(FastHandle != INVALID_HANDLE) IndicatorRelease(FastHandle);
   if(SignalHandle != INVALID_HANDLE) IndicatorRelease(SignalHandle);
}

Wenn jetzt ein Umkehrpunkt erreicht wird, werden alle Daten auf "EMPTY_VALUE" gesetzt, dass nichts mehr gezeichnet wird. Im Anhang ist ein Bild in dem man sieht, dass die EMAs nicht gezeichnet werden, die Füllung aber schon. Wie kann das sein? Es müsste doch entweder beides oder nicht sichtbar sein?

Dateien:
Unbenannt.PNG  14 kb
 

Ich glaube Du hast vergessen mit PlotIndexSetDouble(.., PLOT_EMPTY_VALUE, EMPTY_VALUE) Deinen EMPTY_VALUE bekannt zu geben.