This code displays a spike and paints a bar whenever the current price crosses the 10-period High or Low. I want it to only show a spike and paint on reversals. Any ideas?
LookCross_10_2_lower
LookCross_10_2_lower
Code:
declare lower;
def crossHI = high crosses above highest (high [1], 10);
def UPcross = CrossHI AND sum(CrossHI[1],2)==0;
Alert(UPcross, "Look10 BUY", Alert.BAR, Sound.ring);
def crossLO = low crosses below lowest (low [1],10);
def DNcross = CrossLO AND sum(CrossLO[1],2)==0;
Alert(UPcross, "Look10 SELL", Alert.BAR, Sound.ring);
plot UPspike = if upcross then +1 else 0;
plot DNspike = if dncross then -1 else 0;
AssignPriceColor(if UPcross then Color.green else if DNcross then Color.red else Color.gray);