Most battles with advanced opponents are decided by two or three desperate turns where each side culls one or two units from the other during his turn. The loser is usually the first one to be unable to 'cull' a unit on a turn because of low overall army or unit morale. The opponent who hits first will end up with an advantage if he is able to cull a unit because of the lowering of his opponents overall morale and because he should end up ahead on points. The 2nd mover now has to counterattack to raise his morale back up and to regain points/flags. Often, the opponent who gets in the first blow will be able to maintain his advantage. Therefore, even when on defense, I want to inflict the first blow, by hitting my opponent first. As an attacker, nothing makes me salivate more than a defender who doesn't hit my advancing line with the pre-emptive stike that I normally use. (Although it usually also makes me sad as I realize that the 'good' opponent that I have selected isn't as good as I thought.)
This rule doesn't serve as gospel in 100% of defensive cases but in certainly well over 75%.
The first rule of advanced defense is try mightily not to be passive. Get the enemy to attack you over ground you have prepared. Feint, scout and maneuver in such a way that he attacks you where wish to be attacked. Ideally, he will attack you over ground that is covered by your artillery, harassed by your sharpshooters and up a hill where your infantry line lies 'hull down' on the back side of the hill. This 'hull down' position (Yes I used to be a tank platoon leader and Company XO in the Army.) enables your defensive line to rest, without being hit by artillery while your opponent slogs through a hail of fire toward 'unprotected' guns. A turn before he gets close enough to attack your artillery, up pops your infantry line ready to counter attack the assaulting infantry. He moves up next to your arty and infantry units the following turn and then you hit him first on your own turn. Ideally, you cull several of his units and destroy the morale of the remaining attackers and you occupy the high ground. That doesn't leave many options for the hapless attacker. If he stands and fights, he likely makes flags that the defender will be able to keep and if he retreats, you managed to get in a lick without him replying. (Regarding those flags that are being created on ground you know you will hold: Try to attack enemy units on existing flags in order to increase their value. Don't do it if it will disrupt your slashing and burning, but choose the flag hex if you have a reasonable choice of where to hit the enemy. If you aren't going to hold that ground, of course try not to create them or increase their value.)
An alternative to this method is for your infantry 'screen', (remember them from the artillery section?) which doesn't have to be strong and can be deceptively weak, to withdraw two hexes at a time towards the hill you want the enemy to attack. At the appropriate time, your reserve units that rested behind the hill, join the line and you now have the same situation as described above that should enable you to prevail.
Of course for either of these strategies to work, you must have a reserve. In the larger battles, a reserve division, or maybe even two or three are nearly always necessary. Plan ahead to create this reserve and try to keep it's position/existence unknown to the enemy. When playing as the Rebs at Gettysburg, I keep my reserve behind cemetary hill ready to respond to threats from either the south of cemetary or the north. Countless times I have been able to use a reserve division or two there to smash one attack from the south and then rushed the same units north to smash an attack there as well. In Gettysburg, natural reserve units are those that were 'smashed' on day one as you fought to capture cemetary. After they rest, they can become part of the reserve and continue to rest.
If your opponent has prepared well and looks like he will prevail in the upcoming battle due to overwhelming numbers, artillery support, etc., then it is better to withdraw and fight at another place. If at all possible, withdraw to the next defensible piece of terrain where other weak units that have rested further can now join your defense. Try to slow the enemy advance with a screen so that your units have time to get into the new position.