PureBytes Links
Trading Reference Links
|
Anthony --
After comparing your attached results with my running of your code, I
have a few observations to make.
1. At first, I was thrown off by the entry and exit dates being the
same in backtesting. However, now I understand and accept that.
2. You must have checked,
"Allow same bar exit" in
settings.
3. MOST
IMPORTANT, your code produces very accurate trades, MOST of the time.
However, I noticed what appear to be arithmetic errors on BOTH your
attachment and my backtesting. From the first 10 trades, 8/1/07 -
8/13/07, three trades dated, 8/9/07, 8/13/07, and 8/14/07 are
problematic. The tables below show the problems. The labels
'Anthony', 'Adj', 'Keith', and 'UnAdj' refer to, respectively, your
test results, Yahoo adjusted prices, my test results, and Yahoo
unadjusted prices. My QP3 data base has prices identical to Yahoo
unadjusted, at least for the tables below.
Previous
8/9/07 Close Open High Low Close
Anthony 19.6375 19.208
Adjust 19.71 19.21* 19.64* 18.46* 18.84
Keith 19.70 19.27
UnAdj 19.77 19.27 19.70 18.52 18.90
8/13/07
Anthony 18.8119
18.9216
Adjust 18.79 18.92* 19.82* 18.81* 19.43
Keith 18.87 18.98
UnAdj 18.85 18.98 19.89 18.87 19.49
8/14/07
Anthony 19.418
19.3482
Adjust 19.43 19.35* 19.42* 18.61* 18.66
Keith 19.47 19.40
UnAdj 19.49 19.40 19.47 18.66 18.71
* indicates calculated adjusted values, using simple subtraction.
underlined Prev. Closes should each match the values immediately
below.
instead they match values underlined in other columns.
I did not check any values after the first ten trades.
4. I also tried the following
code below:
SetTradeDelays(0,0,0,0);
Buy = 1;
BuyPrice
= Close;
Sell =
Buy;
SellPrice = Ref(Open, 1);
Short
= Cover
= False;
// long only strategy
It also produces weird results.
However the mismatches are in the Open column rather than in the Prev.
Close column.
-- Keith
Anthony Faragasso wrote:
Keith,
Here is a screen shot of my
results....it produces every day...
I selected current stock and ticker
is Sprint
with a from to range as depicted in
the screen shot
Anthony
----- Original Message -----
Sent:
Saturday, January 30, 2010 12:54 PM
Subject:
Re: [amibroker] Simple Buy on Close, Sell on Open not as expected
Anthony --
Thanks for your effort. I tried your exact code (copy and paste). It
still skips every other day.
Also, I reduced the code to absolute minimum as:
Buy = 1;
BuyPrice = Close;
Sell
= Ref(Buy, -1);
SellPrice = Open;
Been through my settings many times. Still the same.
BTW, I'm running 5.26beta.
-- Keith
Anthony Faragasso wrote:
Keith
give this a try:
Settings window:
allow same bar exit is enabled
all stops are disabled
In the trades window of the
settings I set up the trades as follows probably do not need it :
buy=close, delay 0;sell=open,
delay 0
short=close, delay 0 ,cover =
open, delay 0
// BuyClose SellOpen Daily.afl
SetTradeDelays(0,0,0,0);
Buy = Ref(Close,-1);
BuyPrice = ValueWhen(Buy,Ref(C,-1));
Sell = Open;
SellPrice = Open;
Short = Cover = False;
// long only strategy
-----
Original Message -----
Sent:
Saturday, January 30, 2010 1:09 AM
Subject:
[amibroker] Simple Buy on Close, Sell on Open not as expected
Just fooling around with a very simple idea, but can't get
the code to work.
The idea is to sell at close of every day, hold over night, and sell at
open the following day.
Code below sorta works, but skips every other day. For example:
Day 1, buy on close; Day2, sell on open.
Day 3, buy on close; Day4, sell on open.
etc.
But I can't make it buy on close of days 2, 4, etc.
Tried "Allow same bar exit" in settings, but that makes it sell the
same day that it buys, which is wrong.
// BuyClose SellOpen Daily.afl
SetTradeDelays(0,1,0,0); // has no effect
Buy = Close;
BuyPrice = Close;
Sell = Open;
SellPrice = Open;
Short = Cover = False; // long only strategy
Buy = ExRem(Buy, Sell); // has no effect
Sell = ExRem(Sell, Buy); // has no effect
Well?
-- Keith
|
|