Why does this indicator not work?

 

All it does is paint white squares.

Files:
 
     if( MT(0,i)==MT(1,i) && 
         MT(0,i+1)==EMPTY_VALUE && MT(1,i-1)>0 )
It's a repainting indicator, useless for trading.
 
 //if( MT(0,i)==MT(1,i) &&  
 if ( MT( 0 ,shift)==MT( 1 ,shift) && 

Fixed " i " in parentheses of lines 95 - 96, 103 - 104, 112, 119 to " shift ".

The part of  " i - 1" pointed out by whroeder1 is probably "shift + 1".

 
int start()
  {
  int    counted_bars=IndicatorCounted(),i,shift;
   i=(Bars-counted_bars)-1;
   for(shift=i;shift>=0;shift--)
     {
     
     
     //-- SELL(NEW SIGNAL)
     if( MT(0,i)==MT(1,i) &&
         MT(0,i+1)==EMPTY_VALUE && MT(1,i+1)>0 )
      {
      Pair1Up[shift] = EMPTY_VALUE;  
      Pair1Down[shift] = 22;
      }
      
     //-- BUY(NEW SIGNAL)
     if( MT(0,i)==MT(1,i) &&
         MT(0,i+1)>0 && MT(1,i+1)==EMPTY_VALUE )
      {
      Pair1Up[shift] = 22;  
      Pair1Down[shift] = EMPTY_VALUE;
      }
     
     
     // SELL
     if( MT(0,i)==EMPTY_VALUE && MT(1,i)>0 )
      {
      Pair1Up[shift] = EMPTY_VALUE;  
      Pair1Down[shift] = 22;
      }
      
     // BUY
     if( MT(0,i)>0 && MT(1,i)==EMPTY_VALUE )
      {
      Pair1Up[shift] = 22;  
      Pair1Down[shift] = EMPTY_VALUE;
      }
     
     
     }
   return(0);
  }
Why doesn't this work?
 
 int start()
  {
   int     counted_bars= IndicatorCounted (),i,shift;
   i=( Bars -counted_bars)- 1 ;
   for (shift=i;shift>= 0 ;shift--)
     {
     
     
     //-- SELL(NEW SIGNAL) 
     //if( MT(0,i)==MT(1,i) && MT(0,i+1)==EMPTY_VALUE && MT(1,i+1)>0 ) 
     if ( MT( 0 ,shift)==MT( 1 ,shift) && MT( 0 ,i+ 1 )== EMPTY_VALUE && MT( 1 ,i+ 1 )> 0 )
      { 
      Pair1Up[shift] = EMPTY_VALUE ;  
      Pair1Down[shift] = 22 ; 
      }
      
     //-- BUY(NEW SIGNAL) 
     //if( MT(0,i)==MT(1,i) && MT(0,i+1)>0 && MT(1,i+1)==EMPTY_VALUE ) 
     if ( MT( 0 ,shift)==MT( 1 ,shift) && MT( 0 ,i+ 1 )> 0 && MT( 1 ,i+ 1 )== EMPTY_VALUE )
      { 
      Pair1Up[shift] = 22 ;  
      Pair1Down[shift] = EMPTY_VALUE ; 
      }
     
     
     // SELL 
     //if( MT(0,i)==EMPTY_VALUE && MT(1,i)>0 ) 
     if ( MT( 0 ,shift)== EMPTY_VALUE && MT( 1 ,shift)> 0 )
      { 
      Pair1Up[shift] = EMPTY_VALUE ;  
      Pair1Down[shift] = 22 ; 
      }
      
     // BUY 
     //if( MT(0,i)>0 && MT(1,i)==EMPTY_VALUE ) 
     if ( MT( 0 ,shift)> 0 && MT( 1 ,shift)== EMPTY_VALUE )
      { 
      Pair1Up[shift] = 22 ;  
      Pair1Down[shift] = EMPTY_VALUE ; 
      }
     
     
     }
   return ( 0 );
  }

You have to fix " i " to "shift", because the variable is "shift" in the "for loop" which you wrote.

Reason: