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

Re: [amibroker] New Variable Class - tomasz?



PureBytes Links

Trading Reference Links

True, will be fixed.

Best regards,
Tomasz Janeczko
amibroker.com
----- Original Message ----- 
From: "Dave Merrill" <dmerrill@xxxxxxx>
To: <amibroker@xxxxxxxxxxxxxxx>
Sent: Wednesday, November 05, 2003 3:39 PM
Subject: RE: [amibroker] New Variable Class - tomasz?


> correction to my last post, so as not to confuse. in this paragraph, I said
> 'bar' in one place when I meant STOCK:
> 
> now backtest the NASDAQ 100 again, last 1 bar again, with the old
> backtester. the first stock shows activity, no others. this is also as
> expected, because MyVar is 0 for that first STOCK, buying anything with a
> positive price, and MyVar is 999 for all the rest, buying nothing.
> 
> dave
> 
> 
> > tomasz, I'm not 100% certain, but after a bunch of experiments, I think my
> > confusion came from Status("StockNum") behaving strangely in the portfolio
> > backtester.
> >
> > paste this into the AA window:
> >
> > ----------------------------------------
> > first_stock = (Status("StockNum") == 0);
> >
> > If(first_stock) {
> > MyVar = 0;
> > } else {
> > MyVar = 999;
> > }
> > buy = c > MyVar;
> > sell = short = cover = 0;
> > PositionSize = -10;
> >
> > filter = 1;
> > AddColumn(Status("StockNum"), "StockNum", 1.0);
> > AddColumn(first_stock, "first_stock", 1.0);
> > AddColumn(MyVar, "MyVar");
> > ----------------------------------------
> >
> > first explore and the NASDAQ 100, last 1 bar. in the StockNum
> > column, I see
> > 0, 1, 2, 3 etc. for the first stock only, first_stock is 1, and
> > MyVar is 0.
> > for all other stocks, first_stock is 0, and MyVar is 999. all this is as
> > expected.
> >
> > now backtest the NASDAQ 100 again, last 1 bar again, with the old
> > backtester. the first stock shows activity, no others. this is also as
> > expected, because MyVar is 0 for that first bar, buying anything with a
> > positive price, and MyVar is 999 for all the rest, buying nothing.
> >
> > now portfolio backtest the NASDAQ 100 again, last 1 bar again.
> > the first 10
> > stocks show open long positions, which is NOT what I'd expect. I think it
> > must be because MyVar is always 0. that in turn must mean that first_stock
> > is always true, which in turn must mean that Status("StockNum")
> > is always 0
> > in the new portfolio backtester. can you confirm this?
> >
> > if I'm right, that's what gave me the impression in my earlier tests that
> > variables persisted across stocks. most likely they don't, as you say, but
> > my standard way of initializing them only during the first stock
> > initialized
> > them always, for every stock, and I didn't test specifically
> > enough to tell
> > the difference.
> >
> > make sense?
> >
> > dave
> >
> >
> > > What you say is not correct. No variable 'persists' in
> > portfolio backtest.
> > > Portfolio backtest is not different than scan/exploration/...
> > > in terms of initialization. The variables are initialized at the
> > > entry of each symbol.
> > >
> > > The only set of persistent variables (ranks/signals/etc) is
> > > managed internally by AB
> > > to perform portfolio calculations but you have no control over it.
> > >
> > > Best regards,
> > > Tomasz Janeczko
> > > amibroker.com
> > > ----- Original Message -----
> > > From: "Dave Merrill" <dmerrill@xxxxxxx>
> > > To: <amibroker@xxxxxxxxxxxxxxx>
> > > Sent: Wednesday, November 05, 2003 5:39 AM
> > > Subject: RE: [amibroker] New Variable Class
> > >
> > >
> > > > not that this actually solves this problem, but for portfolio
> > backtests,
> > > > only, variables we create and manage ourselves actually aren't
> > > reset at the
> > > > start of each new stock. it *appears* that they are, unless
> > > your code treats
> > > > them as global to the entire backtest run, which it usually doesn't.
> > > > typically we set everything that needs to be set every time, for every
> > > > stock, erasing anything that might have persisted. to preserve
> > > values across
> > > > all the stocks in a test, you have to detect when you're on the
> > > first stock,
> > > > and initialize your vars at that time, only, then continue to
> > > add to them or
> > > > use them however you want with each stock without resetting
> > > them again from
> > > > scratch.
> > > >
> > > > for instance, say you want to buy and sell based on an
> > indicator applied
> > > > both to the stock itself, and to an overall index. ideally, you
> > > don't want
> > > > to recreate the index indicator over and over again for every
> > > stock, so you
> > > > could do something like this in the portfolio backtester (not
> > > that this is a
> > > > good system):
> > > >
> > > > ----------------
> > > > period = Optimize("Period", 18, 2, 40, 1);
> > > >
> > > > if(Status("StockNum") == 0) { // first stock in test
> > > > index_price = Foreign("!COMP", "C");
> > > >   index_EMA = Wilders(index_price, period);
> > > > index_buy = index_price > index_EMA;
> > > > index_sell = index_price < index_EMA;
> > > > }
> > > >
> > > > stock_EMA = Wilders(c, period);
> > > > stock_buy = c > stock_EMA;
> > > > stock_sell = c < stock_EMA;
> > > >
> > > > buy = stock_buy and index_buy;
> > > > sell = stock_sell or index_sell;
> > > > short = stock_sell and index_sell;
> > > > cover = stock_buy or index_buy;
> > > > ----------------
> > > >
> > > > the if statement block runs only once, when the first stock is being
> > > > examined, but the variables it sets stay valid for the whole
> > > backtest, so
> > > > you can use them to evaluate each stock without recalculating them.
> > > >
> > > >
> > > > there are some unfortunate problems with this approach for
> > > doing on-the-fly
> > > > composites; hopefully tomasz will address them at some point in
> > > the future:
> > > >
> > > > - Status("StockNum") seems to be undefined in explorations, as
> > > it is in the
> > > > old backtester. this means you can't detect when you're on the
> > > first stock,
> > > > to do your initializations. even IsNull(Status("StockNum"))
> > > doesn't return
> > > > anything.
> > > >   besides having Status("StockNum") work in explorations, it
> > > would be nice
> > > > to have Status("FirstStockInTest") and "LastStockInTest", like we have
> > > > FirstBarInTest etc.
> > > >
> > > > - you can't find out which tickers are included in the current
> > > test, or how
> > > > many there are. this means you can't find out when you're on
> > > the last stock,
> > > > or convert the sum of values for each stock to an average, in
> > any way I
> > > > could figure out. you also can't iterate through them all
> > > during the first
> > > > stock of a backtest, to, say, find the top N by volume, and use
> > > that during
> > > > trading of each stock.
> > > >   I've suggested a new feature,
> > > GetCategorySymbols(categoryTypeAutoAnalysis)
> > > > that would return the list of tickers being analyzed; this
> > would make a
> > > > variety of things easier.
> > > >
> > > > dave
> > > >
> > > >
> > > > (btw the index/stock Wilders thing is an example of a
> > > distinctly non-robust
> > > > system. backtest it on the NASDAQ 100 from 3/1/98 to 3/31/03,
> > > and results
> > > > are decent-ish, not great MDD. then optimize and look at the
> > > returns for the
> > > > periods surrounding the default 18. they bite; 18 is a local
> > fluke. try
> > > > other time frames, and again, the generic all-market-types
> > > period is about
> > > > the only one that does as well.)
> > > >
> > > >
> > > > > Currently, all variables (global and local) reflect
> > information about
> > > > > the current symbol only.
> > > > >
> > > > > To perform calculations against multiple securities, you must use
> > > > > AddToComposite which restricts the user to O,H,L,C,V,OI fields along
> > > > > with their pre-defined constraining formats which preclude the
> > > > > calculation and storage of very large numbers. It also usually
> > > > > requires at least two passes against separate AFL or AFL/IB afl code
> > > > > to work with the results.  There is certainly a need for
> > > > > AddToComposite, but I think there is also a need for a
> > simpler set of
> > > > > composite values.
> > > > >
> > > > > I'd like to see a new variable class within AFL for computations
> > > > > across the entire database or watchlist. For lack of a
> > better word, a
> > > > > "composite variable" whose value is maintained across multiple
> > > > > securities and which the AFL engine does not initialize
> > with each new
> > > > > symbol. Also, a composite variable that can be displayed with
> > > > > AddColumn just like the other variables using Filter =
> > LastBar logic.
> > > > >
> > > > > This would allow the user to put together some quick, one-pass
> > > > > explorations for calculating multiple issue stats and to
> > display those
> > > > > figures in the same afl. No ~Composite files would be created, and
> > > > > very large numbers could be calculated and displayed using more
> > > > > flexable variable type declarations of float (or others).
> > > > >
> > > > > I'm posting this here to see if I am alone in wanting this
> > feature, in
> > > > > which case I won't pass it along to TJ as a suggestion.
> > > > >
> > > > > Comments?
> > > > >
> > > > > Phsst
> > > > >
> > > > >
> > > > > Yahoo! Groups Sponsor
> > > > > ADVERTISEMENT
> > > > >
> > > > >
> > > > >
> > > > >
> > > > > Send BUG REPORTS to bugs@xxxxxxxxxxxxx
> > > > > Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
> > > > > -----------------------------------------
> > > > > Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> > > > > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > > > > --------------------------------------------
> > > > > Check group FAQ at:
> > > > > http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> > > > >
> > > > > Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
> > > >
> > > >
> > > >
> > > > Send BUG REPORTS to bugs@xxxxxxxxxxxxx
> > > > Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
> > > > -----------------------------------------
> > > > Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> > > > (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> > > > --------------------------------------------
> > > > Check group FAQ at:
> > http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> > >
> > > Your use of Yahoo! Groups is subject to
> http://docs.yahoo.com/info/terms/
> >
> >
> >
> 
> 
> Send BUG REPORTS to bugs@xxxxxxxxxxxxx
> Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
> -----------------------------------------
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> --------------------------------------------
> Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
> 
> 
> 
> 
> 
> 
> Send BUG REPORTS to bugs@xxxxxxxxxxxxx
> Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
> -----------------------------------------
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> --------------------------------------------
> Check group FAQ at:
> http://groups.yahoo.com/group/amibroker/files/groupfaq.html
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
> 
> 
> 
> 
> 
> 
> Send BUG REPORTS to bugs@xxxxxxxxxxxxx
> Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
> -----------------------------------------
> Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
> (Web page: http://groups.yahoo.com/group/amiquote/messages/)
> --------------------------------------------
> Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
> 
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/ 
> 
> 
>

------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/GHeqlB/TM
---------------------------------------------------------------------~->

Send BUG REPORTS to bugs@xxxxxxxxxxxxx
Send SUGGESTIONS to suggest@xxxxxxxxxxxxx
-----------------------------------------
Post AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx 
(Web page: http://groups.yahoo.com/group/amiquote/messages/)
--------------------------------------------
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/