Thomasz, I'm not doing SellPrice = Ref(Open, -1).
I'm doing SellPrice = Ref(Open, 1) because I am selling my stocks next day of purchase no matter what. The thing I was missing was the boundchecking option, which Graham pointed out. I've disabled that option and confirmed that now backtester picks up a huge gap down of OVTI on 12/1. Regards, intermilan04 --- In amibroker@yahoogroups.com, "Tomasz Janeczko" <[EMAIL PROTECTED]> wrote: > > I forgot: > > take also a look at this doc page > http://www.amibroker.com/f?setoption > > specifically "PriceBoundChecking" option > > Best regards, > Tomasz Janeczko > amibroker.com > ----- Original Message ----- > From: "Tomasz Janeczko" <[EMAIL PROTECTED]> > To: <amibroker@yahoogroups.com> > Sent: Monday, December 04, 2006 4:37 PM > Subject: Re: [amibroker] Re: Selling price not set properly sometimes > > > > Intermilan, > > > > Terry is right and you are wrong. > > > > You are doing the following things wrong: > > > > 1. Never delay trade PRICES. > > SellPrice = Ref(Open, -1 ); // WRONG ! > > > > Did you read the User's Guide Tutorial about backtesting? > > http://www.amibroker.com/guide/h_backtest.html > > > > it is must-read. Come on this is not so much text inside > > so it is pretty easy to read it as many times as needed > > to absorb or at least keep in handy and take a look in case of > > doubt. > > > > And it says: > > > > " > > Controlling trade price > > > > [...] > > During back-testing AmiBroker will check if the values you assigned to buyprice, sellprice, shortprice, coverprice fit into > > high-low > > range of given bar. If not, AmiBroker will adjust it to high price (if price array value is higher than high) or to the low price > > (if price array value is lower than low)" > > > > > > > >> I had to design this way because if I simply buy today and sell > >> tomorrow morning, AmiBroker cannot make tomorrow's purchase (since my > >> equity is still held up by yesterday's purchase), then sell my stocks > >> from today and leave me with cash. > > > > Your description is convoluted enough to become un-cipherable > > ("can not make TOMMORROWS purchaase and THEN SELL stocks from TODAY"???? > > - do we have time-space-continuum preserved here or not?) > > > > > > There is however no problem in entering / exiting positions in way described here > > > >>> 1. I scan for signals on Day 1. > >>> 2. I buy signaled stocks at the open on Day 2. > >>> 3. I sell stocks at the open on Day 3. > > > > One thing to watch for is to turn off "allow same day exit". > > > > Best regards, > > Tomasz Janeczko > > amibroker.com > > ----- Original Message ----- > > From: "intermilan04" <[EMAIL PROTECTED]> > > To: <amibroker@yahoogroups.com> > > Sent: Sunday, December 03, 2006 11:09 PM > > Subject: [amibroker] Re: Selling price not set properly sometimes > > > > > >> Hi Terry, > >> > >> SellPrice = Open would not work, because I'm selling on the same day > >> of purchase but appending tomorrow's opening price as my SellPrice. > >> > >> I had to design this way because if I simply buy today and sell > >> tomorrow morning, AmiBroker cannot make tomorrow's purchase (since my > >> equity is still held up by yesterday's purchase), then sell my stocks > >> from today and leave me with cash. > >> > >> Regards, > >> > >> intermilan04 > >> > >> --- In amibroker@yahoogroups.com, "Terry" <MagicTH@> wrote: > >>> > >>> Just set SellPrice = Open; > >>> > >>> You are trying to "fix" something that Amibroker already handles with > >>> SetTradeDelays. > >>> > >>> // Options > >>> SetTradeDelays(1, 1, 1, 1); > >>> > >>> BuyPrice = SellPrice = Open; > >>> Buy = SomeCondition; > >>> Sell = Ref(Buy, 0); > >>> > >>> -- > >>> Terry > >>> -----Original Message----- > >>> From: amibroker@yahoogroups.com [mailto:[EMAIL PROTECTED] > >> On Behalf > >>> Of intermilan04 > >>> Sent: Saturday, December 02, 2006 21:15 > >>> To: amibroker@yahoogroups.com > >>> Subject: [amibroker] Selling price not set properly sometimes > >>> > >>> Hi all, > >>> > >>> I have a trading system which is intended to work in the following way: > >>> > >>> 1. I scan for signals on Day 1. > >>> 2. I buy signaled stocks at the open on Day 2. > >>> 3. I sell stocks at the open on Day 3. > >>> > >>> In a nutshell, here is a portion of my code that are relevant. > >>> > >>> // Options > >>> SetTradeDelays(1, 1, 1, 1); > >>> > >>> Buy = SomeCondition; > >>> BuyPrice = Open; > >>> Sell = Ref(Buy, 0); > >>> SellPrice = Ref(Open, 1); > >>> > >>> I'm deliberately doing Sell = Ref(Buy, 0); so that I can free up my > >>> Equity for next day's purchase of new stocks. If I do Ref(Buy, 1), > >>> the Backtester tries to buy stocks next morning, can't do so because I > >>> have positions from previous day, and sell my stocks, and I end up > >>> with a cash position which could have been utilized on new stocks. > >>> > >>> Well, that became a lengthy explanation but the problem is the > >>> SellPrice = Ref(Open, 1); code. While it works most of the times, it > >>> does not work 100%. Here is a situation where it failed; > >>> > >>> Ticker Trade Date Price Ex. date Ex. Price % chg > >>> Profit % Profit > >>> REGN Long 2006/11/30 21.5 2006/11/30 21.54 0.19% 18 > >>> 0.10% > >>> OVTI Long 2006/11/30 16.6 2006/11/30 16.04 -3.37% -574 > >>> -3.46% > >>> TLAB Long 2006/11/30 9.99 2006/11/30 10.05 0.60% 88 > >>> 0.52% > >>> BRCM Long 2006/11/30 32.88 2006/11/30 32.66 -0.67% -124 > >>> -0.75% > >>> > >>> I have no problem with REGN, TLAB, BRCM; the Ex. Price is that of the > >>> Open price of next day. > >>> But for OVTI, the 16.04 exit price is filthily wrong. The stock > >>> gapped down big time to 14.22, and my AmiBroker quote for OVTI of 12/1 > >>> shows 14.22 as well, so it is not the case of me having corrupted > >>> quote data. It appears that the 16.04 exit price is the low price of > >>> the day, but then, I never set my SellPrice at Low. > >>> > >>> I will greatly appreciate any insights as to why my problem has > >>> occurred. It's driving me crazy because if things like this happen, I > >>> might get rosier results than what reality might bring. > >>> > >>> Regards, > >>> > >>> intermilan04 > >>> > >>> > >>> > >>> 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 > >>> > >> > >> > >> > >> > >> 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 > >> > >> > >> > >> > >> > > > > > > > > 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 > > > > > > > > > > >