Where exactly did you put this statement? If you put it in OnBarUpdate, it will only check once a tick is received.
You may want to consider working in OnPositionUpdate(), OnOrderUpdate(), OnExecution(), etc depending on what you are trying to accomplish:
I do not have any suggestions for you other than what is on our Performance Tips:

Comment