Trades sent to bo.EnterTrade missing in backtest analysis results

Hello,

I am a little bit clueless, hopefully someone will have already had that problem.

I'm using a Low Level CBT (taken from tradingmarkets advanced course "CBT-Limits.afl"), that I have very slightly altered to buy on limit breakouts (it was originally buying limit pullbacks).

Now upon checking if it all behalves as it should, I have found that some trades sent to bo.EnterTrade were not appearing in the backtester UI.

Tracing like that:

_TRACE(WriteVal(dn[bar],8.0,False)+": Entering trade for " +sig.Symbol+" nPos = "+nPos);
bo.EnterTrade(bar, sig.Symbol, sig.IsLong(), sig.Price, sig.PosSize, 0, sig.RoundLotSize);

I get 6 limit orders that reached their limit and should be opened in the Traces :

00003083 18.50150490 [16700] 1210413: Entering trade for IFF nPos = 3
00003084 18.50169373 [16700] 1210413: Entering trade for KREF nPos = 6
00003085 18.50201035 [16700] 1210413: Entering trade for RMBI nPos = 8
00003086 18.50215530 [16700] 1210413: Entering trade for MVBF nPos = 10
00003087 18.50274467 [16700] 1210413: Entering trade for SPWH nPos = 14
00003088 18.50318146 [16700] 1210413: Entering trade for BLD nPos = 17

But only 4 trades appear in the backtester for that day:

Symbol Trade Date Price Ex. date Ex. Price % chg Profit % Profit Shares Position value
KREF Open Long 4/13/2021 19.56391 4/13/2021 19.81 1.26% 6.58 1.12% 30 586.92
RMBI Open Long 4/13/2021 14.13283 4/13/2021 14.01 -0.87% -5.71 -1.01% 40 565.31
MVBF Open Long 4/13/2021 36.17723 4/13/2021 36.25 0.20% -0.07 -0.02% 10 361.77
SPWH Open Long 4/13/2021 17.62353 4/13/2021 17.54 -0.47% -3.31 -0.63% 30 528.71

Since this is the first day backtested and all the logic involving checking of available slots is already done before in the code (and there is lots of slots available), I don't see why some trades would be ignored, especially at such low level.

As anyone had this behavior in the past ?

Thanks a lot for any pointer.

Use "DETAILED LOG", as in advice given here: How do I debug my formula?

Thanks a lot.

The detailed log showed an "insufficient fund, no trade made" message which was due to tradingmarket's template using:

RoundLotSize = IIf(fPort,10,1);

Which will cause issue when backtesting with a realistic budget (e.g. 10K) when some expensive stocks are chosen by the algo and with a maximum position size in the 10-20... which makes it so that each position will be limited to 500 to $1K... obviously if the stock is already 500$ per share the rounding to 10 shares will be 5K so way too much compared to the 500-1K allowed.

Solution was to simply set the RoundLotSize to 1 no matter if it's a portfolio or alltrades backtest.

Solved!

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.