Remember; your storage area isn't like a real-life bank. Keeping too many resources on hand only serves to incite your enemy into raiding you; you don’t gain interest and you don’t gain any advantage by holding onto them!
Upgrade your bunker or safe storage area when you can – well, every time you can afford to - to keep your Resources safe from prying enemy hands.
Most online games have a bank/bunker/safe area where resources, items and troops can be stored and remain untouched by your enemies. The most obvious thing to do to keep your assets safe is to deposit them in said location. Whilst there, you can lie safe in the knowledge that your hard work is not going to waste.
An effective, but much more difficult trick is to rely on this simple principle: if there's nothing there, they can't steal it! Now, it might not sound like an idea that ranks up there with the invention of the light bulb, but believe me; it's effective!
If you know when a raid is coming and cannot store it all in your bunker, simply move your resources off-base. To do so, send as much of your resources as you can on a long-distance trade mission. When the raid is finished, quickly cancel and recall your trade. This will help minimize your losses and let any potential “farmers” know that you’re not an easy target.
Another trick, possible in almost every online strategy game I’ve played with a trading system, is to offer up your resources for trade in massively unreasonable quantities. I’m talking silly amounts, amounts nobody would ever accept.
Your single bean in exchange for their Ferrari, perhaps. This ties your resources up in the trade system, meaning your aggressors won’t be able to get their hands on them when they raid you. Then, when all is said and done, you simply cancel the offer and your resources are back in your bank. Simple!
If all else fails and you can’t relocate your resources off-base, you can always spend your resources by queuing up as many units as possible in your production or construction queue to make them equally as inaccessible to your opponents. Be careful though, setting your construction or building queues up to maximum and leaving them overnight, will usually result in you losing a massive amount of troops – effectively just wasting the money anyway. Usually, this is worth the risk as it still prevents any of your enemies from increasing their resources, regardless of the outcome to you.
If possible, invest in permanent structures or additions to your base; ones that can be temporarily destroyed or damaged, but will not be a complete waste when you return in the morning. Another consideration you must make is to, as always, know your enemy! Check when the players around you are active, check their time zones, check their nation of origin, check everything you can!
In war, knowledge is power. Humans are creatures of habit, so by building up a knowledgebase of your immediate dangers, you also gain knowledge on when you are free, uninterrupted to do as you please. Use this time to gain as much ground on your enemies as you can.
If you know the day-cycle of those around you, you will have everything you need (aside from god-given smarts, of course) to potentially outsmart them!