A custom-shaped wireless fence system is provided that contains one or more dogs in a user-defined containment area without the need for a physical fence or underground wire. The system, which is easy to set up and use, includes at least three base units and at least one collar and, preferably, a remote controller. A virtual fence is defined around the containment area, as well as around optional exclusion zones within the containment area, during system set up through communication between the base units and a trackable device as the user walks around the desired border. Visualization software enables the user to verify that the location of the fence is as desired and that the system is operating properly using a computing device having a display screen. In use, the system employs improved filtering of consecutive distance measurement values taken between the base units and the collar to discount errant measurement values in terms of their contribution to the current calculation of the dogs location. These filtering techniques, in combination with improved signal strength and antenna diversity in the communication between the base units and the collar, improve the accuracy and consistency with which the dogs location within a containment area is tracked so that unwanted corrections are not administered to the dog.