Thanks, the script is perfect! I tried to reverse engineer it to turn it into a scan but I believe it is too advanced for my skill level. Any chance you could give it a shot?The zigzag is a little tricky as it is most often a 'nan'. So it helps to create code like the zzave below to have a value for it a every bar. The upstep and downstep were revised to produce a barnumber which was used in the addlabel to capture the 3 bars, including the signal bar that you wanted for the label to be colored.
The picture below is a daily chart of AAPL and it shows the signal arrow and the label within 3 bars still showing the red downstep color. In testing the next days bar turned the label black.
See if this helps.