Inserting values into an array

 
Hello, i want to insert the highest value of a candle into an array whose highest value is greater than its two successive predecessor and successor respectively. The code is actually inserting the value but it copies the same value on each tick until the condition matches for second time. As in the figure below. The array is filled with same value for more than 100 times and finally new value is copied when the condition meets. I want to copy only one value (Highest value of candle) when it satisfies the condition each time. please help me. 
Files:
code1.png  42 kb