Remember that when we mostly start testing out a system we don't test with a starting capital. We usually run the backtest with flat lots and the capital requirement suggestion after is based on the normalized drawdown and largest margin requirement during the testing period. To simulate what would have happened if you had started out with a fixed capital with re-investment, you can program in this
Code:
if(ProfitOpen+ProfitClosed < -250) { // margin call
    exitLong();
    exitShort();
    return;
  }


Where the 250 is the capital you would have started with.