HH and LL backtesting

I would like to backtest a simple system. My idea is to buy when market makes higher high(HH) and sell when market makes lower low(LL).

Below is the script i wrote in Pi.

Buy script: HIGH > REF(HIGH, 1) AND LOW>REF(LOW,1)

Sell script:LOW < REF(LOW, 1) AND HIGH<REF(HIGH,1)​

Exit long script: LOW < REF(LOW, 1)

Exit Short script: HIGH > REF(HIGH, 1)

I tried testing the code with 3 month nifty spot data but the script does not captures all HH/LL.

For example:

Data set: Nifty spot data from 06/22/2015 to /09/18/2015

On 06/30 nifty broke 06/29 high of 8329.35. So i expected system to enter into long but the system didn't enter into any trade.

Similarly, on 07/06 nifty broke 07/03 low of 8424.5 so i expect system to enter into short position but, it didn't.

How can i change the code so that it picks every HH and LL?

you can use Highest high value   

HIGH = HHV(14)

and Lowest Low value

LOW = LLV(14)