Your account's "Margin level" is the relation of used margin to the funds available. Watch your margin level closely. When your account's margin level drops to 50% or below, the liquidation process for your positions is activated.
The available balance/margin calculation depends on the sign of unrealized PNL. When the unrealized PNL is positive it's calculated as Balance - Margin. If the unrealized PNL is negative, it's calculated as Equity - Margin.