ball float switch

hy guys i recently bought this http://www.ebay.com/itm/251176582485?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649

sensor and when i plug it in it works good when it is in on state but in off state it gives out some false positive information have any of you encountered with this and is there any way to get 100% accurate information?

How do you have it connected to the arduino? Is the device analogue or digital? If it's digital then do you have pullup/pulldown resistor to stop arduino pin from floating?

I recommend using the internal resistors: pinMode(pin, INPUT_PULLUP).