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

[amibroker] Re: Scan vs Backtest



PureBytes Links

Trading Reference Links

Hi Tomasz,

Thank you for your clear explanation regarding the trade pair.
I will investigate further to see the working of Backtest / Scan /
Explore.

Sincerely,

intermilan04

--- In amibroker@xxxxxxxxxxxxxxx, "Tomasz Janeczko" <groups@xxx> wrote:
>
> Hello,
> 
> You should check the archives. It was discussed to death already.
> 
> Scan shows RAW signals. 
> RAW signals are all signals generated without any processing.
> 
> Backtester uses TRADES. 
> 
> TRADE is BUY-SELL or SHORT-COVER pair.
> 
> If you have sequence of BUY1-BUY2-BUY3-SELL then it is considered
> as single BUY1-SELL pair (a TRADE) - assuming that you don't use
pyramiding.
> 
> If you use pyramiding, subsequent (redundant) buy signals may be used
> to pyramid (scale in) your position.
> 
> See also this picture
> http://www.amibroker.com/gifs/bt_regular.gif
> 
> it shows clearly how signals build trade candidates (buy-sell) and
how they are
> picked according to user-defined position score.
> 
> Best regards,
> Tomasz Janeczko
> amibroker.com
> ----- Original Message ----- 
> From: "intermilan04" <intermilan04@xxx>
> To: <amibroker@xxxxxxxxxxxxxxx>
> Sent: Wednesday, July 26, 2006 2:14 AM
> Subject: [amibroker] Re: Scan vs Backtest
> 
> 
> > Graham,
> > 
> > I tried backtesting for 7/24 alone (i.e. the Date Range is from 7/24
> > and to 7/24) the Backtest still did not enter on BTU or WFT, which
> > were the top 2 PositionScore according to Scan.
> > 
> > I will attempt to explain what's happening with the following
scenarios:
> > 
> > Scenario 1:
> > - Scan finds 10 signals for a particular day.
> > - Backtester recognizes the same 10 signals as Scan, but only take 4
> > positions due to constraints.
> > 
> > This scenario is OK.
> > 
> > Scenario 2:
> > - Scan finds 10 signals for a particular day.
> > - Backtester only recognizes 7 signals out of 10, and take 4 positions
> > from the 7 signals.
> > 
> > This, is what's happening to me and I'm trying to figure out why.
> > 
> > Regards,
> > 
> > intermilan04
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@> wrote:
> >>
> >> A trade signal occurs on the day the conditions are correct
> >> A trade entry in your backtest occurs when you have the trade
> >> conditions occur in accordance with your settings for that backtest,
> >> just like you would have in your trading. A buy in a backtest is
not a
> >> signal, but the trade entry. Backtests are meant to simulate your
real
> >> trading method.
> >> 
> >> If you have a 1 bar delay setting then your signal occurs on one day
> >> and entry is on the enxt day.
> >> If you have maxopenpositions set to 10 and you already have 10 open
> >> trades in the backtest, then no signal wil be taken in thebacktest,
> >> just like in real trading.
> >> If you ahve $100k equity, and $97k is alrady in open trades and the
> >> next signal requires a trade size of $10k then you will not trade it,
> >> the signal is ignored.
> >> 
> >> 
> >> If you want to maych backtest with your scan then you must have the
> >> settings then same
> >> 
> >> 
> >> 
> >> -- 
> >> Cheers
> >> Graham
> >> AB-Write >< Professional AFL Writing Service
> >> Yes, I write AFL code to your requirements
> >> http://e-wire.net.au/~eb_kavan/ab_write.htm
> >> 
> >> 
> >> On 26/07/06, intermilan04 <intermilan04@> wrote:
> >> > Hi Graham,
> >> >
> >> > Thank you very much for your reply.
> >> > I took your advice and changed the filter to
> >> >
> >> > filter = Ref (Buy, -1);
> >> > PositionScore = Ref(SomeCondition, -1);
> >> >
> >> > to be able to explore what the Backtester takes, in hindsight.
> >> >
> >> > I still feel it's kinda strange that, Scanning for signals on 7/21
> >> > does not match with Exploring for signals of 7/21 on 7/24...
> >> >
> >> > Might anyone know what could be causing the problem?  Is there
a way
> >> > to match the above?  In the meantime, I'm trying to figure out
myself
> >> > by backtesting/exploring/scanning but haven't figured yet.
> >> >
> >> > Regards,
> >> >
> >> > intermilan04
> >> >
> >> > --- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@> wrote:
> >> > >
> >> > > The signal is what explore or scan will see
> >> > > Backtest will take the trade as per your settings (ie 1 bar
delay).
> >> > > If you want expore to include the delay then you need to include
> > this
> >> > > delay in your filter eg
> >> > > filter = ref(buy,-1);
> >> > >
> >> > > --
> >> > > Cheers
> >> > > Graham
> >> > > AB-Write >< Professional AFL Writing Service
> >> > > Yes, I write AFL code to your requirements
> >> > > http://e-wire.net.au/~eb_kavan/ab_write.htm
> >> > >
> >> > >
> >> > > On 25/07/06, intermilan04 <intermilan04@> wrote:
> >> > > > Yes I do.  I provided my "Explore" results of 7/21, and
"Backtest"
> >> > > > result of 7/24, which is the next trading day.
> >> > > >
> >> > > > My plan is to buy stocks that had been signaled a day
before, so
> >> > > > Backtester "seeing" the same thing as "Explore" is critical.
> >> > > > As I had said, I understand that the Backtester doesn't
> > necessarily
> >> > > > take all siginaled positions due to constraints, but at least
> > it needs
> >> > > > to "recognize" the same things as "Explore."
> >> > > >
> >> > > > Regards,
> >> > > >
> >> > > > intermilan04
> >> > > >
> >> > > > --- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@> wrote:
> >> > > > >
> >> > > > > do you have delays in the settings? looks like you have 1
> > bar delays
> >> > > > setting
> >> > > > >
> >> > > > > --
> >> > > > > Cheers
> >> > > > > Graham
> >> > > > > AB-Write >< Professional AFL Writing Service
> >> > > > > Yes, I write AFL code to your requirements
> >> > > > > http://e-wire.net.au/~eb_kavan/ab_write.htm
> >> > > > >
> >> > > > >
> >> > > > > On 25/07/06, intermilan04 <intermilan04@> wrote:
> >> > > > > > Hi Graham,
> >> > > > > >
> >> > > > > > Thank you for your very prompt reply.
> >> > > > > > I am sorry if I'm mistaken, but my understanding was
that the
> >> > Detailed
> >> > > > > > Trade Log of below
> >> > > > > >
> >> > > > > > Entry signals(score):CXG=Buy(1.05648), NYNY=Buy(1.0541),
> >> > > > > > > TWMC=Buy(1.02888), SWFT=Buy(1.02825), FLOW=Buy(1.02709),
> >> > > > > > BCR=Buy(1.00364),
> >> > > > > >
> >> > > > > > contain all the raw trade signals that "Scan" would
see, and
> >> > Backtest
> >> > > > > > picks from the pool?
> >> > > > > >
> >> > > > > > What's happening to me is that the Backtester doesn't see
> > the same
> >> > > > > > Entry signals as Scan.
> >> > > > > >
> >> > > > > > Regards,
> >> > > > > >
> >> > > > > > intermilan04
> >> > > > > >
> >> > > > > > --- In amibroker@xxxxxxxxxxxxxxx, Graham <kavemanperth@>
> > wrote:
> >> > > > > > >
> >> > > > > > > Scan gives all raw trade signals
> >> > > > > > > Portfolio backtest gives actual trades allowable
given the
> >> > limits of
> >> > > > > > > Equity/Trade Size, MaxOpenPositions and any other
> >> > > > > > > settings/options/code specified that will affect the
trades
> >> > taken.
> >> > > > > > >
> >> > > > > > >
> >> > > > > > > --
> >> > > > > > > Cheers
> >> > > > > > > Graham
> >> > > > > > > AB-Write >< Professional AFL Writing Service
> >> > > > > > > Yes, I write AFL code to your requirements
> >> > > > > > > http://e-wire.net.au/~eb_kavan/ab_write.htm
> >> > > > > > >
> >> > > > > > >
> >> > > > > > > On 25/07/06, intermilan04 <intermilan04@> wrote:
> >> > > > > > > > Hi all,
> >> > > > > > > >
> >> > > > > > > > I think I have a case where the backtester does not
> > "see" all
> >> > > > signals
> >> > > > > > > > which appear when I scan for signals.  Here are the
> > details:
> >> > > > > > > >
> >> > > > > > > > OS: Windows XP
> >> > > > > > > > Amibroker: 4.80.2
> >> > > > > > > >
> >> > > > > > > > I have a long system with the following setup:
> >> > > > > > > >
> >> > > > > > > > SetOption("InitialEquity", 30000);
> >> > > > > > > > SetOption("AllowSameBarExit", True);
> >> > > > > > > > SetOption("ActivateStopsImmediately", True);
> >> > > > > > > > SetOption("CommissionMode", 2);
> >> > > > > > > > SetOption("CommissionAmount", 7);
> >> > > > > > > > SetTradeDelays(1, 1, 1, 1);
> >> > > > > > > > PosQty = 4;
> >> > > > > > > > SetOption("MaxOpenPositions", PosQty);
> >> > > > > > > > PositionSize = -100/PosQty;
> >> > > > > > > >
> >> > > > > > > > Here is the result of running "Explore" on 2006/7/21
> > with the
> >> > > > > > > > following setup, sorted by PositionScore:
> >> > > > > > > >
> >> > > > > > > > Filter = Buy;
> >> > > > > > > > AddColumn(PositionScore, "PositionScore", 1.4);
> >> > > > > > > >
> >> > > > > > > > Ticker  Date/Time       PositionScore
> >> > > > > > > > BTU     2006/7/21       1.0794
> >> > > > > > > > WFT     2006/7/21       1.0648
> >> > > > > > > > CXG     2006/7/21       1.0565
> >> > > > > > > > CNX     2006/7/21       1.0557
> >> > > > > > > > EXPD    2006/7/21       1.0554
> >> > > > > > > > VSH     2006/7/21       1.0543
> >> > > > > > > > NYNY    2006/7/21       1.0541
> >> > > > > > > > TSAI    2006/7/21       1.0465
> >> > > > > > > > CMG     2006/7/21       1.0356
> >> > > > > > > > TWMC    2006/7/21       1.0289
> >> > > > > > > > SWFT    2006/7/21       1.0282
> >> > > > > > > > ECOL    2006/7/21       1.0277
> >> > > > > > > > FLOW    2006/7/21       1.0271
> >> > > > > > > > TEN     2006/7/21       1.0171
> >> > > > > > > > PQ      2006/7/21       1.0168
> >> > > > > > > > SHFL    2006/7/21       1.0055
> >> > > > > > > > BCR     2006/7/21       1.0036
> >> > > > > > > > CNW     2006/7/21       1.0006
> >> > > > > > > >
> >> > > > > > > > I then backtested the system between 2006/1/1 to
> > 2006/7/24.
> >> > > > Here is
> >> > > > > > > > the result from 7/24:
> >> > > > > > > > 2006/07/24,
> >> > > > > > > > Entry signals(score):CXG=Buy(1.05648),
NYNY=Buy(1.0541),
> >> > > > > > > > TWMC=Buy(1.02888), SWFT=Buy(1.02825),
FLOW=Buy(1.02709),
> >> > > > > > BCR=Buy(1.00364),
> >> > > > > > > > Exit signals:CNW=Sell, ECOL=Sell,
> >> > > > > > > > Enter Long, CXG, Price: 24.6, Shares: 300,
Commission: 7,
> >> > Rank:
> >> > > > > > > > 1.05648, Equity 37812.5, Margin Loan: 0, Fx rate: 1
> >> > > > > > > > Enter Long, NYNY, Price: 5.4, Shares: 1700,
Commission: 7,
> >> > Rank:
> >> > > > > > > > 1.0541, Equity 37798.5, Margin Loan: 0, Fx rate: 1
> >> > > > > > > > Enter Long, TWMC, Price: 5.54, Shares: 1700,
Commission:
> >> > 7, Rank:
> >> > > > > > > > 1.02888, Equity 37784.5, Margin Loan: 0, Fx rate: 1
> >> > > > > > > > Exit Long, ECOL, Price: 21.33, (Avg. exit pr. 21.33),
> >> > Shares: 400,
> >> > > > > > > > Commission: 7, (Total comm.: 14), Profit: -230
(-2.63 %),
> >> > Entry
> >> > > > > > > > rank:1.05599, Equity: 37784.5, Fx rate: 1
> >> > > > > > > > 3 Open Positions: , CXG (+300), , NYNY (+1700), , TWMC
> >> > (+1700),
> >> > > > > > > > Equity: 38836.5, Cash: 11827.5
> >> > > > > > > >
> >> > > > > > > > If you see the Entry signals(score) line, the
Backtester
> >> > clearly
> >> > > > > > > > missed BTU and WFT, which scored the highest
> >> > PositionScore.  The
> >> > > > > > > > Backtester missed other signals too.  I am aware that
> >> > > > Backtester does
> >> > > > > > > > not always take position in what are being signaled,
> > but it
> >> > > > seems to
> >> > > > > > > > me that the Backtester doesn't even see the same
thing as
> >> > > > "Scan" or
> >> > > > > > > > "Explore."
> >> > > > > > > >
> >> > > > > > > > I am willing to disclose more codes if necessary to
> >> > troubleshoot.
> >> > > > > > > > Any help regarding this matter is greatly appreciated.
> >> > > > > > > >
> >> > > > > > > > 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 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 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 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 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 other support material please check also:
> > http://www.amibroker.com/support.html
> > 
> > 
> > Yahoo! Groups Links
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> >
>