erroneous arrows being plotted - Help!!!

 

Hi guys,

I'm trying to plot arrows where the TDI crosses the RSI line but I get extra arrows, anyone got any ideas - it's been driving me crazy. It plots OK if I compile when MT4 is running, but changing time frames or restarting messes things up. Cheers.

int start(){

if(Bars <= 10) return(0);
counted_bars = IndicatorCounted();
if(counted_bars < 0) return(-1);       //---- check for possible errors
if(counted_bars > 0) counted_bars--;   //---- last counted bar will be recounted
int i=Bars-counted_bars-1;
int j=Bars-counted_bars-1;

while(i>=0)
{
   RSIBuf[i] = iRSI(NULL,0,RSI_Period,RSI_Price,i); 
   i--;
}

while(j>=0)
{
   MaBuf[j] = iMAOnArray(RSIBuf,   0, RSI_Price_Line,   0, RSI_Price_Type,   j);
   MbBuf[j] = iMAOnArray(RSIBuf,   0, Trade_Signal_Line,0, Trade_Signal_Type,j);

   chkXover = CrossOver(MaBuf[j], MaBuf[j+1], MbBuf[j], MbBuf[j+1]);

   if (chkXover==1)
   {
      infotext=StringConcatenate("infotext3",j);
      ObjectCreate(infotext, OBJ_ARROW, 2, Time[j],MbBuf[j]+8);
      ObjectSet(infotext, OBJPROP_ARROWCODE, 198);
      ObjectSet(infotext, OBJPROP_COLOR, Blue);
   }
   if (chkXover==(-1))
   {
      infotext=StringConcatenate("infotext4",j);
      ObjectCreate(infotext, OBJ_ARROW, 2, Time[j], MbBuf[j]-4);
      ObjectSet(infotext, OBJPROP_ARROWCODE, 196);
      ObjectSet(infotext, OBJPROP_COLOR, Red);
   }
   j--;
}

return (0);}
//+------------------------------------------------------------------+
int CrossOver(double mabuf1, double mabuf2, double mbbuf1, double mbbuf2)
{
   if (mabuf2 > mbbuf2 && mabuf1 < mbbuf1) return (-1);
   if (mabuf2 < mbbuf2 && mabuf1 > mbbuf1) return (1);
   return (0);
}
 
bump - anyone please???
 
Paul_B:
bump - anyone please???
If you want me to see what is going on I need code that will compile and run . . in other words the whole code.
 
Paul_B:
bump - anyone please???
It looks like you are using bar 0 ? so your result will "repaint" . . . . perhaps that explains the weird arrows ?
Reason: