No update on live candles

 

Hi there is my indicator that it does what it need to be doing but doesnt update on new candles - on history of candles works fine but cant get my head around it why it doesnt work for new ones:

Are you able to help - or explain to me why is it happening? Its basically crossover for darma indicator when buy becomes sell signal and other way around.

#property copyright "Copyright 2018"
#property link      "http://www.LOL.SS"
#property version   "1.00"
#property strict
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_minimum -2
#property indicator_maximum 2

//---- input parameters
extern int Miodzio = 110;
extern int ShowDarmaIndicator = 0;

double BlueDot[];
double RedDot[];
double BlueDot2[];
double RedDot2[];
//---SEFC
extern int period = 12;
double g_ibuf_80[];
double g_ibuf_84[];
double g_ibuf_88[];
//----SEFC END



//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexStyle(0,DRAW_ARROW,STYLE_DOT,2,Blue);//BUY
   SetIndexBuffer(0,BlueDot);//buff3
   SetIndexLabel(0,"Blue Dot");
   SetIndexEmptyValue(0,-100);
   //SetLevelValue(0,2);
   SetIndexArrow(0,233);
   SetIndexStyle(1,DRAW_ARROW,STYLE_DOT,2,Red);

   SetIndexBuffer(1,RedDot);//buff4
   SetIndexLabel(1,"Red Dot");   
   SetIndexEmptyValue(1,-100);
   //SetLevelValue(1,1);
   SetIndexArrow(1,234);
   
   //---------
   
   SetIndexStyle(2,DRAW_ARROW,STYLE_DOT,2,Blue);//BUY
   SetIndexBuffer(2,BlueDot2);//buff3
   SetIndexLabel(2,"Blue Dot");
   SetLevelValue(2,2);
   SetIndexArrow(2,233);
   SetIndexEmptyValue(2,-100);
   SetIndexStyle(3,DRAW_ARROW,STYLE_DOT,2,Red);
   SetIndexBuffer(3,RedDot2);//buff4
   SetIndexLabel(3,"Red Dot");   
   SetLevelValue(3,1);
   SetIndexArrow(3,234);
   SetIndexEmptyValue(3,-100);

   
   //-----------
   

   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    counted_bars=IndicatorCounted();
//---- TODO: add your code here
      int adjustment=0; //change this value to make the indicator behave slightly differently. valid values are 0-4. 
      int periods=10;
      int extremes=0;
      int limit;
      
      limit=rates_total-prev_calculated;
      if(prev_calculated>0)
         limit++;
     
      for(int i=0;i<Bars;i++){
        // for(int i=limit-1;i>=0;i--){
         //double sig=iSAR(NULL,0,0.5,1,i);
   
         //if(sig<Low[i]) BlueDot[i]=1;//sell sig
         //if(sig>High[i]) RedDot[i]=-1;//buy sig
      
         //----------------------------- DARMA -----------------------------------------------------------------
         bool b1,s1,b2,s2;
         
         //current darma
         double sig=iSAR(NULL,0,0.5,1,i);
         if(sig<Low[i]) s1=true;
         if(sig>Low[i]) s1=false;
         if(sig>High[i]) b1=true;
         if(sig<High[i]) b1=false;
         //prev darma
         //double sigp=iSAR(NULL,0,0.5,1,i+1);
         //if(sigp<Low[i+1]) BlueDot[i]=1;
         //if((sigp>High[i+1])) RedDot[i]=-1;
         
         int adjsig2=1;
         double sig2=iSAR(NULL,0,0.5,1,i+adjsig2);
         if(sig2<Low[i+adjsig2]) s2=true;
         if(sig2>Low[i+adjsig2]) s2=false;
         if(sig2>High[i+adjsig2]) b2=true;
         if(sig2<High[i+adjsig2]) b2=false;
         
         if(ShowDarmaIndicator == 1){
         if((s1 == true) && (b1==false))
            {
               RedDot2[i]=0.5;
            }
            if((s1 == false) && (b1==true))
            {
               BlueDot2[i]=-0.5;
            }
         }
         else{
         
         RedDot2[i]=-100;
         BlueDot2[i]=-100;
         
         }
         if((s1 == true) && (s2 == false) && (b1 == false) && (b2 == true))
         {
            BlueDot[i]=-1;
         }else{
         BlueDot[i]=-100;
         }
         
         if((s1 == false) && (s2 == true) && (b1 == true) && (b2 == false))
         {
            RedDot[i]=1;
         }else{
         RedDot[i]=-100;
         }
         //----------------------------- DARMA --------------------------------------END OF------------------------
         
         
         
         
         
         }//end for
//----   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
 
//for(int i=0;i<Bars;i++){
for(int i=0;i<Bars-1;i++){

 
Naguisa Unada:

NOO WAY I SPENT good few hours and i have missed that - thank you so much!!!!! Naguisa Unada - THANKS!

Reason: