The best way to prevent yourself from being farmed is to be as active as possible. If you can be online when the attacker sends his farming raids, you can counteract them fairly easily. When you have an attack inbound, send any troops you may have in the village out to attack any village, say, 1 minute before the incoming arrives. Then, when it is less than 30 seconds away, cancel the attack you just sent. This will ensure that your troops will not be in the village when the attack arrives, so you won't lose any of them.
You should also do the same with your resources. When you have an incoming not very far away, use as many of your resources as you can to queue upgrades in your HQ, and if you have any extra after that use them to queue troops. Once the attack has passed, you can cancel whatever you have queued to get back the resources (bear in mind that when you cancel troop queues you only get back 90% of the resources they cost, but this is still worth it. Losing 10% is better than losing 100%.).
While you are dodging the attacks, you should also be working on training spears and swords to defend your village. Some players would give up on farming you if you simply dodge them often enough, but if he continues to attack then killing his troops might force him to move on to less costly farms. Use your simulator (found in the rally point) to estimate how many and what combination of spears and swords you need to be able to kill his troops. And don't forget to dodge your troops while they are training, you don't want to let him pick off your defense as it is building up. Continue to dodge until you have accumulated enough troops to stop his attack dead. You could also ask your tribemates to send support troops to your village to bolster your own defenses.
EDIT: I should also add that I wouldn't recommend you build up your wall until you have troops with which to defend your village. It may also help to upgrade your hiding place if you can't be active enough to dodge every attack, but if you can be that active then you will be dodging every attack and so won't have any resources to hide there. Also, if you are going to be away from your computer for a few hours you should send all your troops out to attack an unthreatening village. Make sure it is far enough away that the troops will not return until you can be back online. Do the same for your resources: queue an upgrade in the HQ that will take several hours to complete and you can come back at any time (before its completion) and cancel said upgrade to recover the resources.