(I'm still quite bad with Schedules, which I didn't even use for the longest time because they weren't a thing, instead I'd have a standing army training and if things got to needing me to I'd draft in others... But mostly I got good at Turtling and keeping everyone safe, including preventing death-diving archers from atop my walls.)
For quite a while, there has been the idea of formations. Without wanting to turn it into the Rock-Paper-Scissors of various other games I see ads about, the ability to ask a unit to maintain a formation (line, square, wedge) and expect it to be performed (at least while the degree of training still overcomes other pressures, like excitement or loss of morale). Player-led as necessary, but experience (or inate skill) of squad commanders could autonomously apply the appropriate offensive or defensive formation as seems to be required (while still respecting such a "charge"/”advance"/"stand"/(re)"form up"/"fall back"/”flee" overall overseer wish, with or without over-commander squad leaders applying a strategy across sub-militias/etc.
Programmatically... Difficult. But certainly a (training-numbers inspired) "have a minimum number of N troops reach this staging point before then charging off against the first enemy they see" feature would help, and as they gather they could mill into a mutually-defensive formation with very basic info on passable/impassible info and where the nearest enemy actually is (e.g. line up across the wagon-corridor, where the threat is at one end of it, or build up a circle/arc in the open where the enemy can come in/loose projectiles from any direction but are currently mostly in one big lump in one direction).
In the interests of noobs (and probably myself, given my lack of work in this arena of DF's gameplay, even if I've had a fair amount of tabletop experience with dice of various face-counts) it should probably initially default to something like "half the (surviving) squad must arrive at a waypoint/patrol-marker before doing moving on" (while not overwhelmed by fight-or-flight pressures) and could stick to merely milling about with handy status indicator to clue the player in on why they aren't doing more[1]. Advanced changes (form a shield-wall against pointy attackers, square against mounted, space out vs projectiles, wedge up to break an enemy line, "cross the T" with mounted archers vs a column... whatever works for whatever the game can actually accomodate) would be fine-tuned and perhaps become available with tactician skills.
[1] Though most without DF experience would expect them to do no more, so long as the enemy aren't actively attacking (which will trigger their defensive reaction) and if you set them to gather away from trouble then re-stationed the (eventually) fully supplied-up and equipped unit in the midst of the foe once you had them massed as much as you were comfortably able to, then the skirmish is started. (Though currently the enemy is unlikely to hang back without other inducements in the direct gift of the player only if the game's internal Artificial Stupidity is skillfully handled.)