how to introduce the (general) function to the code of the enclosed indicator

to switch between all the arrows and the selected arrows visible (as in the screen)?

The function should draw only the first arrow in the sequence of the arrows with the same color.

I mean the general function - which can be used in each indicator of that kind.

I'm trying to do this using the following code:

Code: Select all

```
if(ArrUp[i] != EMPTY_VALUE){
for(k = 1; k <= Bars-1; k++){
if(ArrUp[i+k] != EMPTY_VALUE)
{ArrUpSel[i] = EMPTY_VALUE; break;}
if(ArrDn[i+k] != EMPTY_VALUE)
{ArrUpSel[i] = High[i] + ... ; break;}
}
}
if(ArrDn[i] != EMPTY_VALUE){
for(k = 1; k <= Bars-1; k++){
if(ArrDn[i+k] != EMPTY_VALUE)
{ArrDnSel[i] = EMPTY_VALUE; break;}
if(ArrUp[i+k] != EMPTY_VALUE)
{ArrDnSel[i] = Low[i] - ... ; break;}
}
}
```