The best way to freeze a signal so the signal doesn't repaint

 
I have a signal indicator that should make an arrow on the LL or HH for any timeframe, but it repaints frantically like a rabid racoon on crack cocaine. One idea to stop something repainting is to take the initial signal it found and force it to remain with some boolean logic, another idea would be to use time or start a timer check if the signal flickered or vanished after a certain time, and if so, avoid said signal because it wasn't strong enough. Lastly, an idea would be to compare consecutive bars to validate the signal, or use a secondary indicator to validate the signal.  I'm not sure for now hat is best, or how to achieve best results.
 
If a signal repaints, it is useless. Drop it.
 
Good morning
no idea and it seems that trying to filter a signal that repaints is not a good idea

You picture
“I had a signal, so I came home, but now I don’t see it anymore and I wonder why I came home?”

And it's even worse, if it's an EA
“Why did he get into position?”
 
Repaint is at design level, not implementation level. If something is designed as repaint there is nothing useful you can do about it.
 
Yashar Seyyedin #:
Repaint is at design level, not implementation level. If something is designed as repaint there is nothing useful you can do about it.
Yeah makes sense, I'll go back to the design of the code. I just thought would be interesting if there is a hack (and worthwhile) approach to give the indicator "surgery".  The thing is that if we want to find an LL or HH, it's not always as easy as comparing the price shift on one bar. Because next bars could change the LL or HH especially on the minute timeframes

 

I just recently re-coded this indicator I made and I have no more repainting :)  

I thought I would discuss it. First of all, I had to go back to the original logic so that all signals would be as reliable as possible - nothing signaling too late and no False signals (very very few if any).

This was achieved, but now there was the other kind of repainting problem - a signal came, it's a good signal, but it disappeared for a few seconds and came back. This isn't that bad, but imagine how it spikes confidence when trading live. I needed more code to make the signal arrows persist. 


This is how I stop signal arrows flashing if anyone is interested:

static bool freeze_long_condition, freeze_short_condition;
static int lastUpArrowBar = -1;    // Bar index where the last up arrow was drawn
static int lastDownArrowBar = -1;  // Bar index where the last down arrow was drawn

int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
{
    int lastBar = rates_total - 1;
    
    for (int i = lastBar; i > rates_total - bars; i--){
 
           //indicator calculations
    }
    
    for (int i = lastBar-2; i > rates_total - bars; i--){
    
        arr_buf_up[i] = 0;
        arr_buf_down[i] = 0;        
        
        if (Conditions_for_buy){ 
         
            lastUpArrowBar = i; // Record the bar index for the last "buy" arrow
            freeze_long_condition = true; // Set the freeze condition
        }       
        
        if (Conditions_for_sell){
        
            lastDownArrowBar = i; // Record the bar index for the last "sell" arrow
            freeze_short_condition = true; // Set the freeze condition
        }
        

        if(freeze_long_condition){
            arr_buf_up[lastUpArrowBar] = low[lastUpArrowBar]; // Set the up arrow buffer value
        }
        
        if(freeze_short_condition ){
            arr_buf_down[lastDownArrowBar] = high[lastDownArrowBar]; // Set the down arrow buffer value
        }
    }          
     // Reset the freeze conditions
     freeze_long_condition = false; 
     freeze_short_condition = false;   


    return rates_total;
}


Reason: