Delete Arrow in Indicator Buffer

 
I have a question about deleting or repainting an arrow object in an indicator buffer.

Here's the scenario. I have an indicator that gives me an up arrow when the fast ma is above the slow ma and a down arrow when the fast ma is below the slow ma. I use an indicator buffer and draw the indicator in a separate window (using DRAW_ARROW as the IndexStyle). So, at the bottom of my window, I have a line of either up or down arrows, depending on the MA's.

On the current bar, the ma's might start out such that I have a down arrow. But, in the course of the bar, the ma's reverse, causing an up arrow to be drawn. What happens, though, is that the new arrow gets drawn on top of the old one, rather than the old one being replaced by the new one.

I want the new arrow to replace the old one. In other words, I want the the arrow to be more dynamic and be finally set at the close of the bar. Any ideas?

Thanks.

stockwet
 
Use a temp variables, for example:

double val1,val2;
for (i=limit;i>=0;i--)
{
val1=0;
val2=0;
// some calculations
if (buySignal) val1=Bid;
if (sellSignal) val2=Bid;
ExtBuffer1[i]=val1;
ExtBuffer2[i]=val2;
}
It's safely style of coding.
 
OK. But, I have that in my code. That doesn't do the trick. The issue is that the tmp value could change from one tick to another. But, the arrow does not get repainted. The arrows are in a separate indicator window, all on one line, so they are drawing on top of each other if within one bar the signal reverses.
 
If you have that in own code it must works properly.
 
What Rosh means that you should redraw your entire buffer every tick, that way you clear out all old objects.
 
Thomas/Rosh, I'm having this same problem as well. I do redraw the entire buffer every time. I even do this:

            if (conditionToDrawLongArrow)
            {
               double tmp=Low[barNum]-(sep*Point);
               currentPosition = LONG_POSITION;
               previousPosition = NO_POSITION;
               lastTradedBar = barNum;
               longArrows[barNum]=tmp;
               alertGiven = false;
            }
            else
            {
               longArrows[barNum]=0;
               WindowRedraw();
            }
What's missing?
 
Stockwet & Josh,

Put a value in the buffer for the type of arrow(up/down) that you want to appear. ...use EMPTY_VALUE for the one that you don't want to show.
Something like this:

      if(LongCondition)
         {
         UpArrowBuffer[i]  =PotentialLongEntryPrice;
         DownArrowBuffer[i]=EMPTY_VALUE;
         }
      else if(ShortCondition)
         {
         UpArrowBuffer[i]  =EMPTY_VALUE; 
         DownArrowBuffer[i]=PotentialShortEntryPrice;
         }
 
raider:
Stockwet & Josh,

Put a value in the buffer for the type of arrow(up/down) that you want to appear. ...use EMPTY_VALUE for the one that you don't want to show.
Something like this:

Perfect..Worked like a charm!


Thanks a Bunch

Reason: