I am trying to programm positionsize of my system based on equity value. The idea is I inwest 1 future contract for every 10000 pln. So I start with my initial equity of 10000 and 1 contract. When my equity grows to 20000 I invest 2 contract, when it grows to 30000 I invest 3 contracts itc.I also want to decrease the number of contracts when my equity decreases. I used this logic in the code below...

```
SetBarsRequired( sbrAll, sbrAll );
SetOption("MaxOpenPositions",1 );
SetOption("AllowPositionShrinking",True);
SetOption("InitialEquity",10000);
SetOption("AllowSameBarExit",True);
SetOption("FuturesMode",True);
SetOption("CommissionMode",3);
SetOption("CommissionAmount",9);
SetOption("AccountMargin",100);
SetOption("ReverseSignalForcesExit",True);
SetOption("UsePrevBarEquityForPosSizing", True);
PositionSize=-32;
MarginDeposit=3200;
PointValue=20;
SetTradeDelays(1,1,1,1);
BuyPrice=Open;
SellPrice=Open;
ShortPrice=Open;
CoverPrice=Open;
```

This is a simple logic I used. It is as simple as possible, maybe to simple. This code at the first glance works, but the problem is according to this code my eguity can not go below 10000, if it does, I will go bankrupct. This is what Monte Carlo shows me. I want to correct this code in the way, that I will go bankrupct only if my equity goes below my margin deposit which in this case is 3200. I wonder if it can be done in the regular bactesting . Any guidance from you how I should proceed further with this code will be appreciated.

Thank you.