My arrows redraw every tick causing lag...

 

I'm new to MQL, but after going through much of the documentation and ripping apart several things to see how they work, I think I'm getting somewhere.

I now have arrows drawing correctly on a chart. I'm not sure why, but sometimes they don't show up correctly unless I change time frames, but whatever. My real problem is that arrows for the current tick are redrawing on top of each other. After a while, this causes a great deal of lag because as each tick comes in, the arrow gets redrawn. If I change time frames and then change back, it goes back to normal until we have another tick where an arrow pops up.

How do I go about correcting this? Thank you for any assistance you can provide. Below is an example of my code:

if ( ExtBuffer0[i] < 0
&& ExtBuffer3[i]-ExtBuffer4[i]<ExtBuffer3[i+1]-ExtBuffer4[i+1]
&& ExtBuffer3[i+1]-ExtBuffer4[i+1]<ExtBuffer3[i+2]-ExtBuffer4[i+2]
&& ExtBuffer3[i+2]-ExtBuffer4[i+2]>ExtBuffer3[i+3]-ExtBuffer4[i+3]
&& Volume[0]>1 && !UpTrend) DrawArrow(i,"up");

 
show the function DrawArrow(i,"up");
 
void DrawArrow(int i,string type)//Arrow_Size
{
maxArrows++;
ObjectCreate("AC_ArrowALERT"+maxArrows,OBJ_ARROW,0,Time[i],0);
if (type=="up")
{
ObjectSet("AC_ArrowALERT"+maxArrows,OBJPROP_PRICE1,High[i]+((4+Arrow_Shift)*Point));
ObjectSet("AC_ArrowALERT"+maxArrows,OBJPROP_ARROWCODE,ArrowDN);
ObjectSet("AC_ArrowALERT"+maxArrows,OBJPROP_WIDTH,Arrow_Size);
ObjectSet("AC_ArrowALERT"+maxArrows,OBJPROP_COLOR,Red);
}
else
{
ObjectSet("AC_ArrowALERT"+maxArrows,OBJPROP_PRICE1,Low[i]-((2+Arrow_Shift)*Point));
ObjectSet("AC_ArrowALERT"+maxArrows,OBJPROP_ARROWCODE,ArrowUP);
ObjectSet("AC_ArrowALERT"+maxArrows,OBJPROP_WIDTH,Arrow_Size);
ObjectSet("AC_ArrowALERT"+maxArrows,OBJPROP_COLOR,White);
}
}
 
Please use this to post code . . . it makes it easier to read.

 
Collusion:
void DrawArrow(int i,string type)//Arrow_Size
{
maxArrows++;

You should be drawing one arrow per bar ? not incrementing each time you call the function.
 
Collusion:

if ( ExtBuffer0[i] < 0
&& ExtBuffer3[i]-ExtBuffer4[i]<ExtBuffer3[i+1]-ExtBuffer4[i+1]
&& ExtBuffer3[i+1]-ExtBuffer4[i+1]<ExtBuffer3[i+2]-ExtBuffer4[i+2]
&& ExtBuffer3[i+2]-ExtBuffer4[i+2]>ExtBuffer3[i+3]-ExtBuffer4[i+3]
&& Volume[0]>1 && !UpTrend) DrawArrow(i,"up");

  1. Volume is unreliable (you can miss ticks), bars is unreliable (max bars on chart) always use time.
  2. If this is a indicator, you shouldn't be drawing ANY arrows. One/two of your buffers should be the arrow buffer(s). See fractal indicator for example.
Reason: