I have the following script for which I'm not sure how to create a simple alert whenever the line changes to green or red (not up or down). Any help is appreciated. Disclosure: this is not my original script, but do not know the creator.
Code:
declare lower;
def s2 = ExpAverage(ohlc4, 1) - ExpAverage(ohlc4, 2);
plot line = s2;
line.AssignValueColor (if s2 <= 0 then Color.RED else Color.GREEN);
line.SetPaintingStrategy (PaintingStrategy.LINE);
Alert(s2, “Change of Direction”, Alert.ONCE, Sound.Ding);