So this is what I came up with.
I threw some orders in the market Friday, and was taking screenshots as price moved around, so that I could compare to whatever I wound up with. I will try again on Monday to be sure its working the way I think. In the attached image, you can see to different states of the trade, initially where it was down -5pips, and then up 13pips, so two different PnLs.
The Inputs are:
Pair: Aud/Usd
Balance = B = $35.23
Trade Price = Price = p = 0.7115
Stop Size = SS = 0.00026
Units = U = 200
Margin = m = 0.03 / 3%
The Outputs are:
Stop Cost = SC = Units * StopSize = 200 * 0.00026 = $0.05
Margin Used = mu = Units * Margin * Price = 200 * 0.03 * 0.7115 = $4.27
Nav(Net Asset Value)/Equity = NAV = Balance + Stop Cost = $35.18
Margin Percentage(Percentage of your Used Margin) = MP = Margin Used ÷ NAV = 12%
The Red line above is the one I am after. So if I were to place this trade, I'd know at MAX, I would use 12% of my margin if it runs to my stop. This way, if I happen to have variable stop sizes, I can always use the same Margin amount in my account. You can imagine, if you have a typical stop of 40 pips, and then for whatever reason you have a 5 pip stop... even though you can risk the same dollar amount, the margin used will be wildly different. This will affect your ability to open/maintain additional positions.
The equations I used are:
MP = (mu ÷ NAV) = (U * m * p) ÷ (B + SC) = (U * m * p) ÷ (B + U*SS)
Here I solve for U, as I want to know how many Units to buy to hold a max margin of my account.
U = (B * MP) ÷ (m*p - MP * SS) = (35.23 * 0.12) ÷ (0.03*0.7115 - 0.12* 0.00026) =198
I checked this for the other picture also, when it was in profit, and it matches also.
Also to note... all the inputs and outputs used, where just to solve for what the formula should be. For actual trading, the inputs would be the desire max margin, and not the Units, as the units are what is being solved for.