SETUP
Your setup will depend on a few things:
1) the number of units your attacker sends at each flank
2) the type of units (ranged or melee) as well as the strength of the units (travelling knight>veteran macemen>two-handed swordsmen>normal macemen)
3) the strength and number of tools your attacker is using
4) the type of tools your attacker is using
5) how strong your own defenses are in terms of how many defenders you can fit on your walls and how strong your tools are.
6) your defense unit type. But if you don't have veterans or heavy green units (halberdiers and longbows) by now you should probably be reading my other guide.
Time to explain why these matter. My explanations assume that the reader has fully expanded castle walls and and fully upgraded level 3/4 towers (for at total number of defenders between 200-260).