Condition met but Alert not generated

Trying to code the below strategy but alert happened only once for the script even though condition met multiple times.

I wanted to generate a buy alert signal whenever the last traded price equaled the High price of the day or exceeded it. Also, wanted a sell Alert signal whenever the last traded price equaled the low price of the day or went less than that.

My Buy Script: REF(LAST,0) = REF(HIGH,0) OR REF(LAST,0) > REF(HIGH,0)

My Sell Script: REF(LAST,0) = REF(LOW,0) OR REF(LAST,0) < REF(HIGH,0)

The problem is that the buy alert was generated only once when the LTP equaled High price. After that, whenever the LTP became equal to the High price, no buy alert was generated. Why the Alert signal generated only once when the condition was met for the first time and after that? The buy alert should have triggered every time this condition is met but it did not. Will the second buy alert be generated only after the first buy alert is squared off? Is it because of this that subsequent buy alert signals were not generated?

I’d appreciate it if someone helped me with this. Thank you.

PS: I was using the day chart with 1 day interval. So the codition would check only the most recent candle which happens to be the intraday/current bar.

As per the above condition 

Buy Script


Sell Script


you should use day candles for the above code (you can create as EA and can apply it to day chart)

When the last breaches high or low, the value of high or low will also change. So can Last be ever greater or lower than high or low. Also. In an intraday timeframe the last traded price might cross the high or low several times in a day. Will a trigger be generated every time this happens?