Entry signals after discarded signal due to insufficient funds

Hello,

the system I’m currently testing generates Buy signals which sometimes don’t lead to a new trade due to insufficient equity size, since sometimes the stop loss distance is too high ( position size is based on % of equity and stop loss distance). I’m testing this system on Futures contracts.
Nevertheless after this skipped signal, sometimes the stop distance reduces which would allow new position to be opened.
Using the Flip function I have Buy signals for every bar since the first Buy signal until I get a Sell Signal.
I was expecting the back-tester to generate buy signals every bar and if the trade size was ok, open a new position.
From Detailed Report it seems that if a Buy signal is skipped due to insufficient funds, the back-tester doesn’t “receive” any Buy signals until a new sell signal appears.

Am I I interpreting this well and is there any way to achieve what I’m trying to do? Possibly only with CBT?

thanks in advance,
pm

Entering lower-scored signals after you run out of funds is really not good idea.
Why? Because very often you end up in your portfolio with small amounts of cash like $100 or less and then built-in mechanisms protects you from entering smallest ranked stocks only because they happen to be cheapest.
If you do what you are asking for, you would end up with some penny stocks polluting your results.

But if you really want it - yes you can write low-level custom backtester code that will not stop after running out of funds. Example how to implement low level CBT are in the Users Knowledge Base at:
http://www.amibroker.org/userkb/2008/03/16/amibroker-custom-backtester-interface-2/

1 Like

Thanks for your reply.

Please note that I’m not running out of funds. This test deals with Futures (not stocks).
What happens is that sometimes the dollar amount of my stop is too large and since I’m risking a % of equity sometimes equity is not enough. Since the stop distance keeps varying every bar, and if the Buy signal is still valid (until sell signal occurs), I would like to enter the trade.

Although these Buy signals don’t show in the detailed log report, if I use CBT and loop through entry signals, these will not be removed in the second part of the backtest? Did I understand correctly?

Thanks again for your help.

If so, I would suggest turning on “allow position shrinking” option. If these signals don’t appear in detailed log they were removed earlier (in first phase) usually because of too low position score. The graphic here: http://www.amibroker.com/guide/h_portfolio.html shows when and why signals are removed in regular backtest. You can use one of the “raw” backtest (backtestRegularRaw) modes if you don’t want them being removed. See http://www.amibroker.com/f?setbacktestmode

Or… you can use single contract position size in first phase and you apply final sizing in second phase. There are many ways to skin a cat.

I am wondering however because in your first post you mentioned that you get “insufficient funds” message which is displayed ONLY in the detailed report when your signal appears in the list of signals but it is not entered due to insufficient funds. But in the second message you wrote that you don’t see that in the detailed report.

That is why providing screenshots and other actual evidence in your question helps getting better answers.

1 Like

Maybe my description was not clear.

I see the insufficient funds message and also see the 1st Buy signal in the detailed report.
What I didn’t see were Buy signals following the insufficient funds message.
I thought that default behavior was: if there were not enough funds to trade a symbol at a certain bar and if in the next bar I have a new buy signal for the same symbol, the buy signal was not removed. I understand why it is removed now.
Your suggestion to use “raw” backtestermode is a good help and solves this issue for single symbol testing. For portfolio mode, however, when there are insufficient funds for a symbol, the following signals are not evaluated.
For portfolio mode I’ll use low level-CBT. At first impression it seems not be too as complicated as I thought.

Thanks very much for your help.

You are mistaken.
Raw mode is good for portfolio mode. It is especially good for portfolio mode.
It is specifically provided for portfolio mode.
Custom backtest has THREE modes, not one. What you are talking about is default processing (i.e. high level).
I am talking about low-level CBT. You can do WHATEVER you want there.
You can use signals or you can ignore them.
You can enter or skip any signal you can enter any symbol. Everything is under your control.
There are simple EntryTrade and ExitTrade methods that allow you to act your way.
Again here is the doc:
http://www.amibroker.org/userkb/2008/03/16/amibroker-custom-backtester-interface-2/

There is even Code Snippet included in AmiBroker for low-level CBT.

1 Like

Hello Tomasz,

I am aware that Raw backtest mode is good for portfolio mode.

What I meant by my last message was that, just adding SetBacktestMode( backtestRegularRaw ) without changing anything else was enough to achieve what I wanted in single symbol backtest.

For multi symbol testing, though, I’ll will use the low level CBT part to do the custom signal processing.

Thanks again for your help.