[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[amibroker] Re: How do I backtest placing a restricted number of limit orders each night?



PureBytes Links

Trading Reference Links

hi Ton,

yes that's true sometimes you miss out on very good signals, but also
you avoid very bad ones. There is code to use redundant signals within
1 symbol. Or if signals occur for another symbol you could set up your
code differently and only assign say 5000$ to each trade. Then if you
have enough money you can add as much trades you like. Seems to me
when you have an infinite amount of cash you can add all the signals
your system comes up with.

But basicly what you are saying is that the winner/loser
characteristics of the trades that are chosen by the backtester
differs from the winner/loser characteristics of the complete set of
signals? This is not what I find and not what I would expect.

regards, Ed



--- In amibroker@xxxxxxxxxxxxxxx, "Ton Sieverding"
<ton.sieverding@xxx> wrote:
>
> As far as I understand Ed and assuming EOD trading, PositionScore is
selecting the best signals coming from the same day. So when at Day1
there are 10 different signals where only one is needed then
PositionScore is selecting the 'best' signal. But what if the next day
all stocks in portfolio are filled and the system generates another 10
signals? They are lost ... until the system gives a SELL. Therefore
the next BUY is based upon the next SELL. Put the 500 stocks of the
SP500 in a WatchList, take whatever AFL rules for the BUY and the SELL
and a portfolio with say max. 10 stocks. Do a Backtest and what you
see is that only a small part of the signals were used to fill the
portfolio. Simply because you have this portfolio constraint. If all
signals would give you the same Winner/Looser characteristics than
there should be no problem. But that's not true. Therefore the
portfolio filling proces for me has a random character and the result
is based upon luck ... Unless I am missing something ... And that's my
question. 
> 
> Regards, Ton.
> 
> 
>   ----- Original Message ----- 
>   From: ed2000nl 
>   To: amibroker@xxxxxxxxxxxxxxx 
>   Sent: Monday, August 27, 2007 12:58 PM
>   Subject: [amibroker] Re: How do I backtest placing a restricted
number of limit orders each night?
> 
> 
>   hi Ton,
> 
>   I'm not sure if I understand what you mean. There are often more
>   signals then you can use but the backtester is instructed to pick the
>   best signals using PositionScore. I can exactly perform my backtest in
>   the real world, excluding the shorts I am not allowed to enter by my
>   broker. The signals the backtester chooses are not pure luck but
>   chosen using positionscore. But I guess I do not understand your
question,
> 
>   rgds, Ed
> 
>   --- In amibroker@xxxxxxxxxxxxxxx, "Ton Sieverding"
>   <ton.sieverding@> wrote:
>   >
>   > Morning Ed,
>   > 
>   > My problem when using the Backtester and in general a Backtester
>   based upon portfolio result is the fact that in the real world an
>   investor will have a portfolio with
>   > let's day 20 stocks. Therefore when the portfolio has been filled,
>   all other BUY signals
>   > will be lost until you've a SELL signal. For this reason when doing
>   a Backtest
>   > I always do an Explore analysis of all signals. In general what I
>   get is something like
>   > 200 Transactions from the Backtester and 1.000 Transactions from the
>   Explore analysis.
>   > What makes things worse, I often get a RAR from the backtest of
>   let's say 25% with
>   > 75% of the signals being winners. When looking to the Explore
>   analysis of all the
>   > signals I only get something like 35% of winners. Therefore the
>   result coming from
>   > the Backtester must be pure luck. The backtester 'randomly' chooses
>   the signals to
>   > fill the portfolio. I have no idea how to solve this problem ...
>   > 
>   > Regards, Ton.
>   > 
>   > 
>   > 
>   > ----- Original Message ----- 
>   > From: Edward Pottasch 
>   > To: amibroker@xxxxxxxxxxxxxxx 
>   > Sent: Sunday, August 26, 2007 8:45 PM
>   > Subject: Re: [amibroker] How do I backtest placing a restricted
>   number of limit orders each night?
>   > 
>   > 
>   > 
>   > hi,
>   > 
>   > the way you set it up it shoudl not be possible. However, what can
>   happen is that the backtester finds exits for the next day and
>   immediatelly fills them with new positions. So you need to make sure
>   that you first exit your positions and tell the backtester to enter
>   only on the next bar. This is usually the problem. There are several
>   ways to achieve this. Maybe you will get a more satisfactory result
>   when you set settradedelays(1,1,1,1). 
>   > 
>   > I use setttradedelays(0,0,0,0) but I make sure that the trade is
>   entered 1 bar after the signal (same with the exits),
>   > 
>   > Ed
>   > 
>   > 
>   > 
>   > 
>   > ----- Original Message ----- 
>   > From: Michael White 
>   > To: amibroker@xxxxxxxxxxxxxxx 
>   > Sent: Friday, August 24, 2007 11:37 AM
>   > Subject: [amibroker] How do I backtest placing a restricted
>   number of limit orders each night?
>   > 
>   > 
>   > Can anyone help me model the following scenario?
>   > 
>   > - Assume a portfolio is allowed to consist of some fixed number
>   > of "slots" with equity equally divided among them (e.g. 10 slots at
>   > 10% of equity).
>   > - Check for setup criteria at close of each day.
>   > - Place next day limit buy orders for as many unfilled slots as are
>   > currently available (e.g. if already have 2 fills after day 1, then
>   > there are only 10 - 2 = 8 slots remaining for day 2, etc.).
>   > - Buy orders are prioritized by a calculated value.
>   > 
>   > My problem is that if I receive a setup for more symbols than I
>   have 
>   > available slots (e.g. receive 20 setups but only have 8 available 
>   > slots), my script will try to fill all 8 slots from the 20 
>   > candidates, and the portfolio manager will correctly prevent me
>   from 
>   > having more positions than allowed (e.g. no more than 10).
>   > 
>   > However, in reality, I will only have placed as many limit
>   orders as 
>   > I have available slots (e.g. 8 limit orders when 8 available slots, 
>   > not limit orders for all 20 candidates, since I only have funds to 
>   > cover placing 8 orders).
>   > 
>   > What is happening is that my script is filling orders that I would 
>   > not have placed! I need a way to indicate that despite 20 setups, 
>   > only 8 limit orders were placed.
>   > 
>   > Following is some script snippets.
>   > 
>   > /*
>   > * Assume an initial purse and brokerage fees ($0.01/share)
>   > */
>   > SetOption("InitialEquity", 50000);
>   > SetOption("CommissionMode", 3);
>   > SetOption("CommissionAmount", 0.01);
>   > 
>   > /*
>   > * Carry fixed number of positions, dividing 100% of Equity between
>   > * them (based on previous bar's closing).
>   > */
>   > PositionSize = -100/10; // Each position is 10% of equity
>   > 
>   > SetOption("MaxOpenPositions", 10); // No more than 10 positions
>   > SetOption("UsePrevBarEquityForPosSizing", True);
>   > 
>   > /*
>   > * We recognize the sale signal at the close of a bar and execute the
>   > * sale at the open of the next one, delay sale by 1 day.
>   > */
>   > SetTradeDelays(0, 1, 0, 0);
>   > 
>   > /*
>   > * Trigger a Buy signal when previous bar meets the setup
>   > * requirements AND this bar's Low has dropped to less than a fixed
>   > * percentage below the previous bar's close. This emulates having
>   > * placed a limit order the night before after having seen the signal
>   > * on that day's close.
>   > */
>   > setup = ... // Some position entry logic.
>   > PositionScore = ... // Some prioritization logic.
>   > 
>   > BuyPrice = Ref(Close, -1) * 0.95;
>   > Buy = Ref(setup, -1) AND Low <= BuyPrice; // Problem here!!!
>   > 
>   > Sell = ... // Some sell logic.
>   > 
>   > As indicated in my earlier comments. The problem is that in
>   reality I 
>   > will not actually have placed orders for all candidates, but rather 
>   > only for as many as there are available slots (e.g. 8). However,
>   the 
>   > script will attempt to fill the available slots based on all 
>   > candidates (e.g. 20).
>   > 
>   > How can I restrict the Buy assignment to only apply to the top X
>   of Y 
>   > candidates based on priority (e.g. top 8 of 20 in example above).
>   > 
>   > Thanks in advance.
>   >
>




Please note that this group is for discussion between users only.

To get support from AmiBroker please send an e-mail directly to 
SUPPORT {at} amibroker.com

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/