I feel like I am missing something. I am running portfolio backtests using a strategy (and have not included the specific code, only the code relevant to what I am trying to solve).
My initial portfolio capital is 20k, trading ASX shares on daily bars. Only going long, with zero margin, risking 1% of equity per trade.
The problem I am facing is in portfolio backtester, it generates many trades for me, and generates more than 50 trades that send me into -$50k. It places trades when my total equity is thousands of dollars negative, even though I don't have the money to take them!
I want the strategy to STOP making any trades as soon as my equity hits $0.
Does anyone have any ideas...??
Code: Select all
input: double Capital( 20000 ) ;
Input: minEquity (5000);
Var: Equity (0) ;
Equity = Capital + NetProfit + OpenPositionProfit ;
if marketposition = 0
and Equity > minEquity
then
Buy ( "MACrossLE" ) vShares Shares next bar at market ;
My vShares calculation is based on Van Tharp's CPR model, and Equity = Capital + NetProfit + OpenPositionProfit
ANY help would be greatly appreciated!