- Max out the number of garrisoned troops - Nothing says stay away like a full garrison. Initially you'll want to max this out with copper troops. As you unlock silver troops, you'll want to start replacing your copper garrisoned troops with silver ones and likewise as you unlock gold units you'll want to replace copper troops with these. Unless you're a big spender, you'll not be able to completely replace copper troops with silver troops, so you'll probably have a mix, but make sure to replace the weakest, lowest level garrison troop with better troops as you progress through the game.
- Find a buddy to defend you - If no one is defending you, the number of troops in your garrison is white. When a buddy defends you, the number of garrisoned troops turns green with a green '+' sign. The enemy player can't see who's defending you, all they see is white or green text. Green text is always a deterrent because not only do they have to defeat your garrisoned troops, but also your ally's troops. Most likely they'll go for an easier target.
- Keep your lootable resources to a minimum - If you go into your city and check your warehouse, that should show how many of your resources are protected from enemy players. Any resources you have beyond that protection limit can be stolen. At the beginning of the game, you'll want to keep gold, lumber, and elixer surplus to a minimum. You'll want to unlock silver units as soon as possible so you can keep the mithril, crystals, and blood diamonds surplus to a minimum as well. There may be times where you're saving up for an expensive rare resource unit (gold siege units for example) and need to accumulate 1000+ of a rare resource, you may consider moving to the capital for a time to make sure you can't be attacked and lose those resources. Remember to note that if you attack another castle, they can revenge you and attack you even if you're in the capital.
- Make sure to keep upgrading your walls - this increases your wall defense. The greater your wall defense, the less resources a player can steal from you. If you and another player have the same amount of lootable resources but you have a higher wall defense than the other player, the player with lower wall defense is more likely to be attacked because the enemy player will get more loot in a single attack.
- Increase in power - if a two players have the same amount of lootable resource but one is 10k power and the other is 100k power, the 10k player will be looted. High power means high level defending troops and more losses for the enemy player, this is a great deterrent.
These tips have been enough to help me from being attacked. It's only happened once in 1.5 months of play on server 60. The PvP system is all about risk vs reward. You wait 2 hours for 1 stamina on each of your heroes. You want to maximize loot and minimize troop losses. You're not going after the player with 300k wall defense, 100 garrison defenders, defended by an ally, who has a power of 130k, who has minimal lootable resources. You take away the reward and make the risk too high and you'll be just fine. Just don't piss anyone off, then they'll come after you no matter the risk.
If you have any further suggestions, just comment below!