Jim,
As I tried to explain below, I believe
it works correctly unless you do something with PositionSize as in the following example AND you are trading Next Day OPEN.
Simply setting the PositionSize as you have done is fine. You will not get a
"looks into the future" error with this example, but it effectively
does look into the future:
TradeDelays(1,1,1,1);
PositionSize = = -100 / 6;
BuyPrice = SellPrice = ShortPrice = CoverPrice = Open;
//Your code to get a signal goes here
//…
SetForeign("$RUT"); //Market is OK to trade when $RUT RSI > 30.
MarketOK = IIf(RSI(14) > 30,1,0);
RestorePriceArrays();
PositionSize = PositionSize *
MarketOK; //This is the
problem code
Buy = yourCondition;
//and so
on…
This looks into the future because the
evaluation of MarketOK and PositionSize is taken on the day of the trade, which
is tomorrow. This info cannot be known in real-time because the RSI depends on
the Close.
To fix the above problem do this
instead:
//PositionSize = PositionSize * MarketOK; //Delete this line of
code
Buy = yourCondition AND MarketOK; //Now we are using MarketOK on the signal day instead of the
trading day
SIDE NOTE: There is a similar problem
with using AA->Settings->Portfolio tab->"Limit trade size as % of
entry bar volume" when using TradeDelays(1,1,1,1) and OPEN prices because
the Volume that is used is tomorrow's closing Volume (which IS the entry bar
volume, but it is info that cannot be known at the time of the trade). When
running in real-time it will use Today's volume since tomorrow's volume does
not yet exist. This is not as significant a problem because it just allows a somewhat
larger or smaller trade that you would get by using Today's volume as the
limit.
-----Original Message-----
From: amibroker@yahoogroups.com [mailto:amibroker@yahoogroups.com] On Behalf Of James Hutchison
Sent: Friday, June 02, 2006 05:16
To: amibroker@yahoogroups.com
Subject: RE: [amibroker]
Backtester picks wrong stocks
I have experienced this problem also when the setting
is SetTradeDelays(1, 1, 1, 1). SetOption
( "MaxOpenPositions", 6);
PositionSize = -100 /
6;
The system I am working on Trades and sells on open the next
morning. I have been testing the system each evening after my new data is
in and I find that some times some of my previous trades disappear and are
replaced with a different stock. I have used the check button and have no
future bars. Does this mean I can not use my system to find tomorrow's
trade or is there an other way.
Thank You
Jim Hutchison
At 10:36 PM 6/1/2006, you wrote:
PositionScore works correctly, but if you use
PositionScore to modify
the PositionSIZE, then this is done on the trading day and you have that
set to 1,1,1,1. So, you would see the effect you describe. In essence,
it looks forward a day.
Lest I get in trouble with TJ, if this is your problem it just cannot be
coded that way. Instead of modifying PositionSize, just make
PositionScore part of your Buy statement to block certain trades.
If you are not doing the above, then you'll have to post code to
evaluate.
Have you tried the CHECK button in the editor? It needs to say you are
not using forward looking code. If it does say you are looking into the
future, then you have to find that code and eliminate it (if it affects
Buy/Sell code).
--
Terry
-----Original Message-----
From: amibroker@yahoogroups.com [ mailto:amibroker@yahoogroups.com] On
Behalf Of intermilan04
Sent: Wednesday, May 31, 2006 23:58
To: amibroker@yahoogroups.com
Subject: [amibroker] Backtester picks wrong stocks
Hi all,
I have a daytrade system which buys at open, sells at close.
The system has SetTradeDelays(1, 1, 1, 1);
The idea here is I download the market data at night, scan for signals
then place market orders overnight so I will buy at open the next day.
The problem I'm facing is this:
Suppose I run my system at night and it signals Stock A, B, and C. I
place orders and buy them tomorrow morning. The following night, I
run backtest and see which ones my backtester picked. Strangely, the
backtester does not always pick out Stock A, B, and C, despite having
signaled them the night before.
I am ranking my signals by PositionScore variable, but criteria used
by PositionScore looks at past quotes, not future quotes.
Has anyone explanation as to why this happens? If the backtester does
not pick what it had signaled, it is a grave situation because you
can't really follow with the system no matter how good it is.
Thank you in advance,
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 other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links
------------------------ Yahoo! Groups Sponsor --------------------~-->
Everything you need is one click away. Make Yahoo! your home page now.
http://us.click.yahoo.com/AHchtC/4FxNAA/yQLSAA/GHeqlB/TM
--------------------------------------------------------------------~->
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 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/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/
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 other support material please check also:
http://www.amibroker.com/support.html
SPONSORED LINKS
YAHOO! GROUPS LINKS