I want to know if there is a reserved word that can allow the system to take position that
doesn't exceed the initial capital invested.
for example if a have an initial capital of 10000$ all the open positions simultanesly have to never be greater than 10000$ over all the backtest.
Here is my code:
Code: Select all
Input:
StopLossPct( .2 ),
NbarExit(5),
RegimeLookback(200),
TradeSize(10000),
RISK_PER_POSITION(0.2);
Variables:
vShares(100),
MA200(0),
ExitMA(0),
con(0),
nshares(0);
MA200 = Average(Close, RegimeLookback);
ExitMA = Average(Close, MAExitPeriod);
con=TradeSize*RISK_PER_POSITION;
nshares=con/C;
If condition1 and condition2 then buy nshares shares this bar at close;