What about if you build a Depo on the open and build bridges around it
Build another in your fort and close the gates of your fort
When the merchant come, they'll go for the outside depo
Pull the bridges up and close the ourside depo
Open the fort and let them in.
Reverse when they leave
It's a lot safer than having an open fort, prone for ambushes and kobolts.
There's a couple weaknesses in using this method as described.
Since one can path from almost any map edge to that 'outside depot', your merchants can appear anywhere on the map. This can be unhealthy should there be ambushes or other hostile units on the map.
These merchants can be trying to reach that 'outside depot' at the same time an ambusher unit is heading for them. You might not know this until you've opened your fort, and might discover it in a manner that leads to more casulties than you wished for.
Your method offers no defense for the merchants, presuming that you actually desire to see them conduct buisness with your fortress in a wholesome, profitable, and safe manner.
As an alternative, build that bridge enclosed area as a one wall, two bridged enclave right on the side of your map. The boundary of the area is going to be the map edge, two raised bridges touching that map edge, and an 'inner' wall. The width between the bridges has to be at least 3, and the length between map edge and 'inner' wall must be at least 5. Keeping it close to the minimum size works -better- for this method. Once that wall is built, make a temporary ramp along the wall (outside the enclosed area) so you can get dwarves up there to make another bridge atop the enclosed area, sized to cover the structure as if it were a roof - this will protect it from most fliers. Once construction of the upper bridge is done, deconstruct the ramp so only the rare flying building destroyer can reach that upper 'roof' bridge to force access inside.
Ensure that no trees or boulders block this enclosed area (I usually just keep an eye on it and trample any saplings that start to grow rather than try to pave it) and make a ramp down to an at least 3-tile-wide path that has some length to it and eventually connects to your fortress. This path needs an 'outer gate', a rising bridge that is sealed to the outside, placed fairly close to the map edge, a place for the depot at some point (usually fairly close to the fortress) and an 'inner gate' between the depot and the fortress, that is sealed to the outside. Make sure you place these 'gates' so that merchant guards/your dwarves are not randomly wandering into atom-smashing range.
90% of the time, leave the 'inner gate' sealed and the 'outer gate' open. merchants are forced to spawn where there is a path to a depot. They are forced to spawn in that 'hidden' sealed area, and will immediately start to path inwards.
Enemies spawn anywhere, and may someday spawn on the merchant path, but this is SO rare. Never seen it happen myself, though I once saw a migrant wave spawn inside the path. An enemy that spawns in here can only sit there, unless it wants to destroy the depot - this will let you know it's there. Otherwise, it will eventually wander off the map or into an oncoming caravan.
When the caravan reaches the depot, flip the levers, so now the path is sealed to the outside and open to your fort. Conduct your trading, get everything where you want it, and then flip the levers again so the merchants can leave when they are ready.
This keeps your dwarves safe, your merchants safe, and allows you considerable control of how pathing works in regards to these areas. If you urgently need a 'distant bolt hole' for some reason, you need only open all three sets of rising bridges to allow this, and you have an exit hole leading out of the map.
Rarely the merchants refuse to path out - they dont WANT to leave the side of the map they entered from. In that case, just open the outermost bridges (the ones that form the enclosure) to allow them wider exit, or just let them path out through the fortress main gate by opening the inner gate again, or perhaps have a few side exits carved and blocked by rising bridges to accomodate their departure in relatively complete safety.