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

RE: [amibroker] Re: Need a Numerical Stock reference



PureBytes Links

Trading Reference Links




Keith:
 
A couple of observations. First, in your assignment of Eqty=50000 and your 
subsequent assignments of Max_Trade, Max_risk, etc., you are not compounding 
your profits. In order to compound, you should use a negative sign for your 
positionsize statement. To simplify, all you need are 2 statements:
 
SetOption("InitialEquity",50000); //this hard codes your initial equity or 
it can be set in Settings
PositionSize = -1 * BuyPrice/(2 * ATR(10)); 
 
The second line above says risk 1% of CURRENT equity (not just INITIAL 
equity) adjusted by the buyprice divided by volatility (if you have set your 
buyprice to be the open, which is not clear from your message). The way you are 
doing it, your investment will always be a constant 1% of $50,000 regardless of 
how large your equity grows. I presume you are using a 1-day delay between 
the buy signal and the actual entry. In other words, you can hard code this as 
well with the following statement: SetTradeDelays(1,1,1,1);
 
In your position size code lines, you state that, if PosSize2 
>=Max_Trade, use Max_Trade, otherwise use possize2. This mixes units: the 
units of Max_Trade is dollars, which in your case is $5000, whereas the units of 
PosSize2 is shares. It makes no sense. Thus, mathematically, in order for your 
possize2 to ever be >= Max_Trade, the ATR must be less than 0.05, which is 
very tiny unless you are buying penny stocks. Thus, most if not all of the time, 
your positionsize will be equal to possize2, which is in shares. PositionSize in 
Amibroker is always in dollars. So, make sure your units always match. If you do 
not want to compound your winnings, then my interpretation of what you want 
is:
 
Eqty = 50000;
Max_Trade = 0.1*Eqty;
Risk = 0.01 * Eqty;
PositionSize = Min(BuyPrice*risk/ATR(10), Max_Trade);
 
As to your question about the program missing some stocks, Chuck suggested 
a possible reason in regards to your roundlot size. Is it also possible that the 
stocks missed are relatively new issues that don't have the same history as the 
other stocks in your watchlist? You didn't mention your date range. Eventually, 
those stocks will trade, according to your code, even though they came into 
existence later than the others in your watchlist. Did you check the entire 
trade list to see if those 4 stocks did eventually trade later? 
 
Regards,
 
Al Venosa
 
<BLOCKQUOTE 
>
  ----- Original Message ----- 
  <DIV 
  >From: 
  <A title=traderkeith2000@xxxxxxxxxxxx 
  href="">Keith Osborne 
  To: <A title=amibroker@xxxxxxxxxxxxxxx 
  href="">amibroker@xxxxxxxxxxxxxxx 
  Sent: Wednesday, January 07, 2004 12:55 
  AM
  Subject: [amibroker] Portfolio Backtester 
  & Watchlist - Help required
  
  
  Hi, can anyone help 
  me with the following code. It is a simple system I coded to understand how 
  the backtester works.
  The postion sizing 
  and the trailing stop portions work fine but when I run this code against the 
  backtester using a watchlist of some 50 stocks then it does not pick up the 
  5th, 6th, 8th and 10th stocks in the watchlist and create a long position. 
  
  <SPAN 
  class=363443701-07012004>The question I have is "does the backtester evaluate 
  each stock in the order of the watchlist", if so why does it miss some stocks 
  and pick the next one?
  <SPAN 
  class=363443701-07012004>TIA....Keith
  <SPAN 
  class=363443701-07012004>Code......................
  Eqty = <FONT 
  face=Arial>5<FONT color=#ff00ff 
  size=1>0000;<FONT 
  face=Arial>Max_Trade = <FONT color=#ff00ff 
  size=1>0.1*Eqty; // 10% 
  of Equity per trade //Max_Risk 
  = 0.01<FONT 
  size=1>*Eqty; // 1% of Equity at risk on 
  each trade //ATR_risk 
  =2<FONT 
  size=1> ; // Multiple of ATR for position 
  sizing calcs //PosSize2 = 
  Max_Risk/(ATR_risk*<FONT color=#0000ff 
  size=1>ATR(<FONT color=#ff00ff 
  size=1>10)); // No. of 
  Shares based upon risk and ATR //<FONT 
  face=Arial>PositionSize = <FONT 
  face=Arial>IIf<FONT 
  size=1>(PosSize2>=Max_trade, Max_trade,possize2); <FONT 
  color=#008000 size=1>// Positon sizing based upon equity or risk limits 
  //// SYSTEM AREA 
  //trailstopamount = 
  2<FONT 
  size=1>*ATR(<FONT 
  color=#ff00ff size=1>10); <FONT color=#008000 
  size=1>// The stop used is a trailing stop defined as a multiple of ATR(10) 
  //// The system is 
  very simple...Buy<FONT 
  face=Arial> = C><FONT color=#ff00ff 
  size=1>0;<FONT 
  size=1>Sell = C<<FONT color=#ff00ff 
  size=1>0;<FONT color=#0000ff 
  size=1>ApplyStop<FONT 
  size=1>(2,<FONT 
  color=#ff00ff size=1>2<FONT 
  size=1>,trailstopamount,True,True);<FONT 
  face=Arial color=#008000 size=1>//PositionScore = 100-RSI(); // Prefer stocks 
  that have low RSI;<FONT 
  face=Arial>AddColumn<FONT 
  size=1>(PositionSize,"Pos 
  Size",1.0<FONT 
  size=1>);<FONT face=Arial color=#008000 
  size=1>//AddColumn(PositionScore,"Pos Score",1.2);<FONT 
  color=#0000ff size=1>AddColumn<FONT 
  face=Arial>(posSize2,<FONT color=#ff00ff 
  size=1>"POSsize2",<FONT color=#ff00ff 
  size=1>1.0);<FONT color=#0000ff 
  size=1>AddColumn<FONT 
  size=1>(ATR(<FONT 
  color=#ff00ff size=1>10),<FONT color=#ff00ff 
  size=1>"ATR",<FONT color=#ff00ff 
  size=1>1.4);<FONT color=#0000ff 
  size=1>AddColumn<FONT 
  size=1>(trailstopamount,"Trail 
  Stop",1.4<FONT 
  size=1>);<FONT 
  face=Arial>AddColumn<FONT 
  size=1>(C,"Price"<FONT 
  size=1>,1.2<FONT 
  size=1>);Send BUG REPORTS to 
  bugs@xxxxxxxxxxxxxSend SUGGESTIONS to 
  suggest@xxxxxxxxxxxxx-----------------------------------------Post 
  AmiQuote-related messages ONLY to: amiquote@xxxxxxxxxxxxxxx (Web page: <A 
  href="">http://groups.yahoo.com/group/amiquote/messages/)--------------------------------------------Check 
  group FAQ at: <A 
  href="">http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  
  
  Yahoo! Groups Links
  
    To visit your group on the web, go to:<A 
    href="">http://groups.yahoo.com/group/amibroker/  

    To unsubscribe from this group, send an email to:<A 
    href="">amibroker-unsubscribe@xxxxxxxxxxxxxxx  

    Your use of Yahoo! Groups is subject to the <A 
    href="">Yahoo! Terms of Service. 
  
  
<BLOCKQUOTE 
><FONT 
  face="Courier New">---Outgoing mail is certified Virus 
  Free.Checked by AVG anti-virus system (<A 
  href="">http://www.grisoft.com).Version: 6.0.552 
  / Virus Database: 344 - Release Date: 
12/15/2003


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





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:amibroker-unsubscribe@xxxxxxxxxxxxxxx 
Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.