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

[amibroker] Expectancy



PureBytes Links

Trading Reference Links

TJ:

I noticed an error in your Example 3 calculation of Expectancy. Here is the questionable line:

Risk = ( MaxLossPercentStop / 100 ) * trade.GetEntryValue();

In your text, you write:

// risk is calculated as the maximum value we can lose per trade
// in this example we are using  max. loss stop
// it means we can not lose more than (MaxLoss%) of invested amount
// hence risk


The third comment line should read: //it means we cannot lose more than MaxLoss% of total equity per trade. It does NOT mean we cannot lose more than MaxLoss% of INVESTED AMOUNT. That would be way too conservative. We always compute risk as a fraction of TOTAL CURRENT EQUITY.

The term "trade.GetEntryValue()" is the investment or dollar value of a particular trade, i.e., its positionsize in dollars. Since risk is a fraction of total EQUITY you are willing to lose on any given trade, you cannot use trade.GetEntryValue() in the risk assignment code. So, if, at the very beginning of a backtest, you start out with an initial equity of $100,000, each trade initiated risks $1,000, regardless of the stock's price or positionsize. If you buy 5 stocks on day 1, the risk PER STOCK is $1,000, whether the positionsize is $10,000 or $45,000; so, your total risk for the first day is 5% (5 trades * $1,000 per trade). What you have done is divided your $1,000 risk among all 5 stocks. So, the trade.GetEntryValue() term must be replaced by an equity function (InitialEquity for the first trades on Day 1, and Equity for subsequent trades). As of yet, I don't know how to call InitialEquity() or Equity() in this new interface. What would you use in place of trade.GetEntryValue()?

Al Venosa




Check AmiBroker web page at:
http://www.amibroker.com/

Check group FAQ at: http://groups.yahoo.com/group/amibroker/files/groupfaq.html




Yahoo! Groups Links