Indicator arrow displacement

 

Hi all,

I encountered a problem that my indicator arrow didn't show properly.

When I first added indicator to chart, it showed correctly. But if I scroll to the earlier date , the position of arrow was totally a mess.

Please check chart below which is normal

Please check the chart below which is not correct when I scrolled to earlier date

Any guru can fix this problem? 

I will be appreciate it very much.

You can give me your paypal account. 

 
   int bars = rates_total - 1;
   if(prev_calculated > 0)
      bars = rates_total - prev_calculated;

   for(int i = bars-1; i >= 0; i--) …
   return(rates_total);
First run prev_calculated is zero, so you process [rates_total-1-1 … 0]. Subsequent runs (previous_calculated is rates_total) you process [rates_total - rates_total -1 … 0] which does nothing. See How to do your lookbacks correctly #9#14 & #19.
 

Hello

I have the same problem... but I dont know how to fix it...I'm glad if you can help me.

 
sajad vatan #:

Hello

I have the same problem... but I dont know how to fix it...I'm glad if you can help me.

Some of the junk values are still there. Make sure to  choose EMPTY_VALUE for those arrows.

Check the modification here:

     UpArrowBuffer[i+1]=EMPTY_VALUE;
      if(Close[i+1]>UpperBuffer[i+1])
        {
         UpArrowBuffer[i+1] = Low[i+1] - 1 * Point;
         if(i==0) Alert("Channel BreakUp: ",Symbol() + " " + TimeToStr(Time[i+1]+21600),Symbol()); // 這裡將i設定為0,可以用來避免指標剛載入的時候,過去的行情不斷跳出Alert
        }

     DownArrowBuffer[i+1]=EMPTY_VALUE;
      if(close[i+1]<LowerBuffer[i+1])
        {
         DownArrowBuffer[i+1] = High[i+1] + 1 * Point;
         if(i==0) Alert("Channel BreakDown: " ,Symbol() + " " + TimeToStr(Time[i+1]+21600)); // 這裡將i設定為0,可以用來避免指標剛載入的時候,過去的行情不斷跳出Alert
        }
Files:
test.mq4  9 kb
 
Yashar Seyyedin #:

Some of the junk values are still there. Make sure to  choose EMPTY_VALUE for those arrows.

Check the modification here:

Amazing!!!!!!!!

That's it....

Dozen's of thanks...

Reason: