Indicator is on chart but is invisible

 

if I right click in that spot, where i know the indicator should be, it shows me that it is there....but i can only see colors in the strategy tester, and only after the beginning of the strategy tester(not on previous data)

I thought there was some problem with the code, but the indicator is actually there...


//+------------------------------------------------------------------+
//|                                          Head&ShouldersAlert.mq5 |
//|                        Copyright 2020, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "2009-2017, MetaQuotes Software Corp."
#property link      "http://www.mql5.com"
//---- indicator settings
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_plots   1

#property indicator_label1  "HeadnShoulders"
#property indicator_type1   DRAW_COLOR_SECTION
#property indicator_color1  clrRed,clrBlue,clrRed // (Up to 64 colors can be specified) 
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1

//---- indicator buffers
double ExtMixedBuffer[];
double         ColorLineColors[];
int necklines=0;

void OnInit()
  {
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtMixedBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,ColorLineColors,INDICATOR_COLOR_INDEX);

   IndicatorSetInteger(INDICATOR_DIGITS,_Digits);
   PlotIndexSetDouble(0,PLOT_EMPTY_VALUE,EMPTY_VALUE);
  }
//+------------------------------------------------------------------+
//| 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 i=0,limit;
//---
   if(rates_total<5)
      return(0);
//---
   if(prev_calculated<7)
     {
      limit=2;
      ArrayInitialize(ExtMixedBuffer,EMPTY_VALUE);
      ArrayInitialize(ColorLineColors,EMPTY_VALUE);
     }
   else
      limit=rates_total-6;




   for(i=limit; i<rates_total-3 && !IsStopped(); i++)
     {
      if(low[i]<low[i+1] && low[i]<low[i+2] && low[i]<=low[i-1] && low[i]<=low[i-2])
        {
         ExtMixedBuffer[i]=low[i];
        }
      else
         ExtMixedBuffer[i]=EMPTY_VALUE;


      if(high[i]>high[i+1] && high[i]>high[i+2] && high[i]>=high[i-1] && high[i]>=high[i-2])
        {
         if(ExtMixedBuffer[i]!=EMPTY_VALUE)
           {
            if(open[i]<close[i])
               ExtMixedBuffer[i]=high[i];
            else
               ExtMixedBuffer[i]=low[i];
           }
         else
            ExtMixedBuffer[i]=high[i];
        }
     }




//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
   if(rates_total>0)
      ColorLineColors[rates_total-1]=0;

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
   if(rates_total>3)
     {
      ExtMixedBuffer[rates_total-2]=EMPTY_VALUE;
      ExtMixedBuffer[rates_total-1]=close[rates_total-1];

     }
   return(rates_total);
  }
 

You have like this:

   if(prev_calculated< 7)
     {
      limit= 2 ;
      ArrayInitialize(ExtMixedBuffer,EMPTY_VALUE);
      ArrayInitialize(ColorLineColors,EMPTY_VALUE);
     }
   else
      limit=rates_total- 6 ;

do this:

   if(prev_calculated< 7)
     {
      limit= 2 ;
      ArrayInitialize(ExtMixedBuffer,EMPTY_VALUE);
      ArrayInitialize(ColorLineColors,0.0);
     }
   else
      limit=rates_total- 6 ;
 
Vladimir Karputov:

You have like this:

do this:

thank you 

Reason: