Help neede for code to increase trade size per $1000 increase in account balance

 

How do you write a code to increase the trading lot size by every (full)  $1000 gain in account balance and the lot size should not round up ?

eg

Balance   lot size

$1000     0.01

$1450     0.01

$2000     0.02

$2990     0.02

$3100     0.03

 
double lots;
if(OrderSelect(0,SELECT_BY_POS,MODE_HISTORY)) {
  if(OrderType()==6 && OrderProfit()>0) {
  if(AccountFreeMargin()>OrderProfit()*2) lots=MathAbs(MathCeil(-AccountFreeMargin()/OrderProfit()))*0.01;
  }
  else Comment("...not loaded all trades history... or it is maybe >0 ?1");
 }
else Comment("...not found first depo...");
Comment("lots=",lots);

or

if(AccountFreeMargin()>1000*2) lots=MathAbs(MathCeil(-AccountFreeMargin()/OrderProfit()))*0.01;
else lots=0.01;
Reason: