The best way to freeze a signal so the signal doesn't repaint
- Coding help
- Indicator Based Systems with good profit
- Cycle indicators
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.
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; }