color change is bar a behind, why?

 
   for(N=3000-144-1;N>=0;N--){
      A[N]=iCustom(NULL,0,"zCog",17,11,13,0,N);
      B[N]=iCustom(NULL,0,"zma",3,0,N);
      }
   
   
   
   int M;
   for(N=3000-144-1;N>=0;N--){
      if(A[N+1]<A[N]&&B[N+1]<B[N]){M=A[N];GG[N]=A[N];G[N]=EMPTY_VALUE;R[N]=EMPTY_VALUE;Z[N]=0;}else 
      if(A[N+1]>A[N]&&B[N+1]>B[N]){M=A[N];RR[N]=A[N];G[N]=EMPTY_VALUE;R[N]=EMPTY_VALUE;Z[N]=1;}else 
      if(A[N+1]<A[N]&&B[N+1]>B[N]){M--;G[N]=M;GG[N]=A[N];R[N]=EMPTY_VALUE;Z[N]=2;}else 
      if(A[N+1]>A[N]&&B[N+1]<B[N]){M++;R[N]=M;RR[N]=A[N];G[N]=EMPTY_VALUE;Z[N]=3;}
      }

I have a small problem with all the indicators i design with color... the color changes one bar after it should even if i refer to just one buffer

if(G[N+1]>G[N]){R[N]=EMPTY_VALUE;}else{R[N]=G[N];}

I can't figure it out and it seems like such a obscure problem that when I search for it all I get is noobs asking how to add colour!

 
G[N]=EMPTY_VALUE;R[N]=EMPTY_VALUE;Z[N]=1;

Green is no longer valid, so you don't display it. fine. But that means Red is valid, why are you not displaying it?

Try rewiting the code in this format

if(A[N+1]<A[N]){
  if (B[N+1]<B[N]){ ... 
  }
  else{ ...
  }
}
else{
  if (B[N+1]<B[N]){ ... 
  }
  else{ ...
  }
}
 

#WHRoeder 'Green is no longer valid, so you don't display it. fine. But that means Read is valid, why are you not displaying it?'

Because I want to only show white (not Green nor Red)

i will try your idea thanks for the suggestion... speak soon!

Reason: