| 
 PureBytes Links 
Trading Reference Links 
 | 
| 
 Thanks for your effort Al. It is very 
clear, 
  
In one of my earlier posts I posted  
  
// money management 
block 
stopLoss = Ref(bbb*ATR(20),-1); // trade 
risk tr = IIf(Buy,(stopLoss / BuyPrice),stopLoss / (ShortPrice + 
stopLoss)); // renormalisation coefficient rc = 0.02 / tr; // 
positionsize PositionSize = rc * 
-100 
  
  
it actually gives the same result as 
your: 
PositionSize = -2.0 * 
IIf(Buy,BuyPrice,ShortPrice) / 
stopLoss 
  
except for short positions. Exact the same it would 
be if I use: tr = IIf(Buy,(stopLoss / BuyPrice),stopLoss / 
(ShortPrice)); 
  
Unfortunatelly I do not get better results this 
way. Using just a simple PositionSize = -10 still gives somewhat better 
results. 
  
  
rgds, Ed 
  
  
  ----- Original Message -----  
  
  
  Sent: Saturday, December 11, 2004 4:19 
  AM 
  Subject: Re: [amibroker] PositionSize / 
  Capital 
  
  ed nl wrote: 
  
    
    
    Al, 
      
    but how do you implement the risk factor 
    now? 
      
    ed  Ed:
  Let us suppose you have established your risk 
  as 1% (i.e., the maximum you are willing to lose on a trade). Let us also 
  suppose your initial equity is $100,000. So, if the stock you buy (or short) 
  goes down by the amount based on your system, you lose only $1000, keeping you 
  in the game. Now, let us say you defined your volatillty-based stop 
  in terms of 2*ATR(20), which you incorrectly assigned to the variable 
  TrailStopAmount. I say 'incorrectly' because the TrailStop in AB was designed 
  to mimic the Chandelier exit, which is basically a profit target type of stock 
  (it hangs down like a chandelier from the highest high since the trade was 
  initiated, if long). I don't think you want the TrailStop to be your money 
  management stop. Rather, the MM stop is the max stoploss, defined 
  as:
  StopAmt = 2*ATR(20); ApplyStop(0,2,StopAmt,1); 
  So, if 
  your stock declines by 2*ATR(20) from your entry, you exit with a 1% loss. 
  Let's take an example. Stock A is selling for $40/share. It's ATR(20) is 
  $1/shr or 2.5% of 40. Your stop amount is 2*ATR(20), which is $2/shr. How much 
  stock do you buy? You simply divide your risk, $1000, by 2*1, which is 500 
  shares. This amounts to an investment of $40/shr * 500 shrs or $20,000. All of 
  this can be coded in one simple line of AFL plus the 2 lines above defining 
  the MM stoploss:
  PositionSize = -1 * BuyPrice/StopAmt;
  where -1 
  is 1% of current equity (0.01 * 100,000 or $1000), BuyPrice = $40/shr, and 
  StopAmt is 2. Keep in mind that a negative sign means 1% of CURRENT 
  equity, which means compounded equity, not just a constant initial equity of 
  $100,000. If you carry through the above math with your renormalization 
  coefficient notation, you wind up with the exact same answer. 
  One more 
  thing. When you place your order, assuming you are trading with EOD data, you 
  do not know what the buyprice is until you buy the stock, which is the next 
  day. So, what most traders do is base their positionsize on the closing price 
  of the night before the entry. Therefore, to place an order in the evening to 
  be filled in the morning at the open, your positionsize statement would 
  actually be:
  PositionSize = -1 * C/StopAmt;
  where C is the 
  closing price on the night before you buy. So, if you use the code 
  SetTradeDelays(1,1,1,1), then the above formula is OK. However, if you use 
  SetTradeDelays(0,0,0,0), then you have to ref the C back a day. 
  This 
  is probably more information than you were asking about, but I hope it 
  helps.
  Cheers,
  Al Venosa
 
  ed nl wrote: 
  
    
    
    Al, 
      
    but how do you implement the risk factor 
    now? 
      
    ed 
    
      ----- 
      Original Message -----  
      
      
      Sent: 
      Friday, December 10, 2004 5:32 PM 
      Subject: 
      Re: [amibroker] PositionSize / Capital 
      
  Use -1 without the 
      Capital rather than 0.01:
  Positionsize = 
      -1*BuyPrice/TrailStopAmount;
  ed nl wrote: 
      hello,
  I found this question has been asked 
        before but I couldn't find the answer.  If one tries to use 
        moneymanagement techniques I find the following example  in the 
        manual:
  TrailStopAmount = 2 * ATR( 20 ); Capital = 100000; /* 
        IMPORTANT: Set it also in the Settings: Initial Equity  */ Risk = 
        0.01*Capital; PositionSize = 
        (Risk/TrailStopAmount)*BuyPrice; ApplyStop( 2, 2, TrailStopAmount, 1 
        );
  However, in this example the Capital will be constant 
        throughout the  backtest.  I need to use the Capital value of my 
        portfolio as it progresses  through time. What can I 
        use?
  thanks
  rgds, Ed 
 
 
  Check 
        AmiBroker web page at: http://www.amibroker.com/
  Check 
        group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
        
 
 
  
  Check AmiBroker web page at: http://www.amibroker.com/
  Check 
      group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
      
 
 
 
  Check AmiBroker web page at: http://www.amibroker.com/
  Check 
      group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
      
 
 
   
  Check AmiBroker web page 
  at: http://www.amibroker.com/
  Check 
  group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html 
  
 
  
  
Check AmiBroker web page at: 
http://www.amibroker.com/ 
 
Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html
  
 
| Yahoo! Groups Sponsor | 
 
  ADVERTISEMENT
 ![click here]()  |     | 
 
![]()  |  
 
 
 
Yahoo! Groups Links 
  |   
 |