PureBytes Links
Trading Reference Links
|
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@xxxxxxxxxxxxxxx, "Terry" <MagicTH@xxx> 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@xxxxxxxxxxxxxxx [mailto:amibroker@xxxxxxxxxxxxxxx]
On Behalf
> Of intermilan04
> Sent: Saturday, December 02, 2006 21:15
> To: amibroker@xxxxxxxxxxxxxxx
> 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
>
Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.430 / Virus Database: 268.15.6/566 - Release Date: 12/3/2006 4:36 PM
|