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

[amibroker] Re: Expectancy - and related



PureBytes Links

Trading Reference Links

Hi Gerry,

Pleased to see you are alive and well and that the brain cells are 
ticking over.

Well, it is a live discussion group so sometimes we make little 
mistakes - readers understand that - if people are following the 
discussion it isn't a problem since the mistakes become obvious and 
they are part of the learning curve (interested readers get their 
calculators out and check the math, as well as making their own value 
judgements - just another day at the office).

I have started writing an "Evaluation Metrics" post for the UKB that 
brings together some of the recent discussion from the 'evaluation' 
threads.

My beef is that root cause evaluation, and tracing the maths 
precedents for the eq curves, including the propogation of 
error/variance has been sadly neglected in the trading literature 
(mostly).......and that we can do a bit better, at explaining the 
metrics ourselves if we start from first principles. 

The gist of the post is:

- the fundamental model for trading is binomial
- the binomial inputs are Wins/Losses and value per Win/Value per 
loss (as $,points,%, or as a volatility unit).

My argument is that expectancy is a restatement of the binomial 
relationship and that mathematically extracting expectancy from that 
is a rather convoluted method - hence my view that 'we' would be 
better off going straight to the geometric mean as expectancy 
expressed in % per trade (coin toss).

Your summary of Van Tharps work shows very nicely how we have to tie 
ourselves in knots to get expectancy out of the standard binomial 
equation.

The Geometric mean is far easier to calculate and, what is more 
important, it has somewhere to go, once you have it (it is easily 
annualised as PA% and it plugs straight into Money Management 
calculations, via Vinces's optimalF equations etc.

Here is what I mean by the standard binomial relationship (and how 
sheds some light on your comments):

a) A fair sided coin == PowerFactor 1/1 == value of win/value of loss

Note: that it is a ratio and not a numerator/denominator (this is 
confusing as all heck, since that is counter intuitive to our normal 
maths expectations of this notation).

b) we subtract the bottom line from the top to get nett gain

== 1-1 = 0 (in this no win game).

c) if there was a net expectancy, say PF = 2/1
then nett gain == 2-1 = 1

d) this gain is the product of two coin tosses (you have to get the 
win followed by the loss to calculate the standard binomial factor.

Note: no matter how many coin tosses (trades) are involved in the 
evaluation PowerFactor, or other variants of the standardised 
binimila relationship, always summarises it as two 'average trades' 
i.e. the value of the win side of the coin and the value of the loss 
side of the coin == two trades.

e) so we have divide nett gain by two == 0.5 per expectancy per coin 
toss (I call this the standard unit of binomial expectancy).

f) but! PF (the standard binomial relationship) is unitless, so we 
have to then backcalculate the ave loss and multiply that by the 
standard unit, to get a value for expectancy.

Also the ave standardised loss$== total loss$/(total number of 
trades/2) - since the standardised binomial equation assumes 1 win 
and 1 loss i.e. each side of the coin.

This is what Van Tharp is doing in a round about way.

Why bother going through all of that when we can get expectancy (as 
geometric mean%) as easy as eating mom's apple pie?

Of course, if we want to start at the backend, calculate the final 
equity and then use expectancy$ == (total$won - total$loss)/total 
number of trades then it is not so hard but you just have a metric 
that is all dressed up with nowhere to go.

I will be starting an argument on this point, and other related 
matters, at the UKB soon.

Thanks for your post.

I agree that we should discuss the ins and outs of the metrics (since 
it hasn't been done all that well elsewhere) and that we should know 
all about them before we use them.

I don't think we will get to the bottom of it in a hurry, but we have 
to start somewhere.

Also we shouldn't accept that our current (collective) understanding 
is the endpoint - we can still go further - I have a few new 
speculative metrics to throw into the discussion (not to mention 
BinomialSimulation - which IMO throws a bit of a spanner into the 
works).

Cheers,

brian_z

--- In amibroker@xxxxxxxxxxxxxxx, "gerryjoz" <geraldj@xxx> wrote:
>
> 
> Hi Brian,
> Because this is rather long, I'll net it all out at the beginning.
> 
> van Tharp expectancy as a dollar amount=average profit per all 
trades.
> 
> He gets there by starting out with the concept of what you are 
risking
> per trade.
>  Expectancy=e*R, 
> where R is the the amount at risk, empirically the average loss of
> losers. "e" takes a little calculation but its easier to just take 
the
> average profit per trade and divide by the average loss of losers.
> e=(net profit/number of trades)/(average loss per losing trade)
> 
> you are right that 
> Mathematical Expectation = ?"[i = 1,N](Pi*Ai)
> > where
> > P = Probability of winning or losing.
> > A = Amount won or lost.
> > N = Number of possible outcomes. 
> In my copy of his book i didn't see that as his explicit definition 
of
> expectancy, nor did i see
> expectancy == (probability of a win * ave Win)- (prob loss * ave 
Loss)
> explicitly either.
> He uses expectancy as a measure against the amount at risk.
> 
> i copied how the formula read, not what Van Tharp actually used in 
his
> calculations. So i got his ideas wrong in my previous note (or being
> cheeky, his text and his numbers didn't quite line up, but i should
> have noticed that).
> So please discard my earlier calculation of expectancy.
> My apologies for that.
> 
> What he wrote on page 204 was
> 
> Expectancy=average profit/per trade
> divided by
> average loss.
> 
> His actual calculation was
> average profit = net profit/total number of trades
> 
> it is net profit that is the numerator not average profit, and what 
it
> is not, is the average profit of winners. The average loss though is
> the loss of losers divided by the number of losers.
> So how it really should have looked in his book to be consistent 
with
> his calculations is:
> expectancy= average profit over all trades/average loss per losing
> trade as a factor to be applied to average loss.
> 
> For van Tharp the average loss is the amount at risk, in effect what
> you expect to lose on a losing bet. His expectancy tells you how 
much
> in dollars you expect to win as a proportion of that, which as you 
say
> comes out as a dollar amount.
>  
> In my copy of his book, 2nd ed  page 198 he writes "expectancy is 
your
> average gain or loss stated in terms of R" where R is empirically
> approximated by the average loss, the sum of the losing trade values
> divided by the number of losers. BUT his average gain in the
> calculation is net profit divided by all trades.
> 
> All that appears to reduce to van Tharp saying (In effect)
> expectancy = (net profit (or loss)/total trades) times average loss 
of
> losers.
> 
> Let's take a simple example and follow van Tharp:
> 100 trades, 60 losers 40 winners, the total profit of winners is 80
> ($2 each), and of losers is 30 ($.5 each), net profit=50.
> Van Tharp according to the book, has
>  average profit/per trade= net profit/total number of trades=
> 50/100=.5
> average loss= 30/60=.5.
> expectancy=(average profit/average loss)* average loss 
> expectancy= (.5/.5) *R
> r=.5.
> But mathematical expectation is 50. The difference is the need to
> divide by the number of trades to get expectancy.
> 
> here are the numbers from the book 
> 
> net profit=10843
> number of trades=103
> average profit (of all trades)=105.27
> average loss (of losers)=721.73=R
> expectancy =.15 R
> my calculation
> 
> e=105.27/721.73
> e*R=105.27= net profit per trade.
> 
> Or to put it simply:
> Net profit per trade is expectancy.
> 
> That's a whole chapter for him to tell you that you need to make a 
net
> profit on average per trade, and you should be comfortable with the
> amount at risk per trade.
>  
> 
> 
> 
> 
> --- In amibroker@xxxxxxxxxxxxxxx, "brian_z111" <brian_z111@> wrote:
> >
> > Hello Gerry,
> > 
> > Gee you are putting me under the pump now.
> > 
> > It is easy to get lost amongst the various definitions that float 
> > around.
> > 
> > For expectancy I have:
> > 
> > van Tharp
> > 
> > expectancy == (probability of a win * ave Win) - (prob loss * ave 
> > Loss)
> > 
> > My understanding is that the ave W or L is measured in $ values.
> > 
> > This definition is consistent with 'mathematical expectation"
> > 
> > From Ralph Vince
> > 
> > Published by John Wiley & Sons, Inc.
> > Library of Congress Cataloging-in-Publication Data
> > Vince. Ralph. 1958-The mathematics of money management: risk 
analysis 
> > techniques for traders / by Ralph Vince
> > 
> > 
> > MATHEMATICAL EXPECTATION
> > By the same token, you are better off not to trade unless there 
is ab-
> > solutely overwhelming evidence that the market system you are con-
> > templating trading will be profitable-that is, unless you fully 
> > expect the market system in question to have a positive 
mathematical 
> > expectation when you trade it realtime.
> > Mathematical expectation is the amount you expect to make or 
lose, on 
> > average, each bet. In gambling parlance this is sometimes known 
as 
> > the player's edge (if positive to the player) or the house's 
> > advantage (if negative to the player):
> > (1.03) Mathematical Expectation = ?"[i = 1,N](Pi*Ai)
> > where
> > P = Probability of winning or losing.
> > A = Amount won or lost.
> > N = Number of possible outcomes.
> > The mathematical expectation is computed by multiplying each pos-
> > sible gain or loss by the probability of that gain or loss and 
then 
> > sum-ming these products together.
> > Let's look at the mathematical expectation for a game where you 
have 
> > a 50% chance of winning $2 and a 50% chance of losing $1 under 
this 
> > formula:
> > Mathematical Expectation = (.5*2)+(.5*(-1)) = 1+(-5) = .5
> > In such an instance, of course, your mathematical expectation is 
to 
> > win 50 cents per toss on average.
> > Consider betting on one number in roulette, where your mathemati-
cal 
> > expectation is:
> > ME = ((1/38)*35)+((37/38)*(-1))
> >  = (.02631578947*35)+(.9736842105*(-1))
> >  = (9210526315)+(-.9736842105)
> >  = -.05263157903
> > Here, if you bet $1 on one number in roulette (American double-
zero) 
> > you would expect to lose, on average, 5.26 cents per roll. If you 
bet 
> > $5, you would expect to lose, on average, 26.3 cents per roll. 
Notice 
> > that different amounts bet have different mathematical 
expectations 
> > in terms of amounts, but the expectation as a percentage of the 
> > amount bet is always the same. The player's expectation for a 
series 
> > of bets is the total of the expectations for the individual bets. 
So 
> > if you go play $1 on a number in roulette, then $10 on a number, 
then 
> > $5 on a number, your total expectation is:
> > ME = (-.0526*1)+(-.0526*10)+(-.0526*5) = -.0526-.526 .263 = -.8416
> > You would therefore expect to lose, on average, 84.16 cents.
> > This principle explains why systems that try to change the sizes 
of 
> > their bets relative to how many wins or losses have been seen 
> > (assuming an independent trials process) are doomed to fail. The 
> > summation of negative expectation bets is always a negative 
> > expectation!
> > The most fundamental point that you must understand in terms of 
money 
> > management is that in a negative expectation game, there is no 
money-
> > management scheme that will make you a winner. If you con-tinue 
to 
> > bet, regardless of how you manage your money, it is almost 
certain 
> > that you will be a loser, losing your entire stake no matter how 
> > large it was to start.
> > This axiom is not only true of a negative expectation game, it is 
> > true of an even-money game as well. Therefore, the only game you 
have 
> > a chance at winning in the long run is a positive arithmetic 
> > expectation game. 
> > 
> > van Tharps expectation is a restatement of Vinces 
> > Mathematical Expectation = (.5*2)+(.5*(-1)) = 1+(-5) = .5 since 
the 
> > loss confers negative sign to the second part of the equation.
> > 
> > I had to use a simple example to sort out my comments:
> > 
> > trade 3 times
> > win twice * $2 each
> > ave$ won == 2
> > lose once * $1
> > ave $ loss = 1 
> > gross win == $4
> > gross loss == $1
> > gross $won/gross $ lost == 4 == ProfitFactor (definition used by 
AB)
> > nett $gain = 4 - 1 == 3
> > expectancy $ = net $gain/#trades in total == 3/3 == $1
> > 
> > PF (also) == W/L * ave$W/ave$L = 2/1 * 2/1 == 4/1
> > 
> > van Tharp expectancy
> > 
> > probality of win == 2/3 == 0.666
> > prob of loss == 1/3 == 0.3333
> > expectancy == (0.666 * 2) - (0.333 * 1) == 1.332 - 0.333 
> > van Tharp expectancy is approx == $1
> > this is the same as PF expectancy
> > 
> > 
> > I went off Profit Factor as a metric because of the errors 
introduced 
> > when adjusted data is used (using unadjusted data biases 
backtesting 
> > for EOD trades).
> > 
> > I use expectancy in a different way - I am not a mathematician 
but 
> > the way I use it is a lot closer to geometrical mean than 
anything 
> > else - I use expectancy in % terms - for my own use I changed the 
> > name to PowerFactor - it also has a better mathematical 
relationship 
> > to some other useful metrics, including some used in portfolio 
> > management.
> > 
> > Thanks for your post - important topics that are always worth the 
> > discussion.
> > 
> > brian_z
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > --- In amibroker@xxxxxxxxxxxxxxx, "gerryjoz" <geraldj@> wrote:
> > >
> > > In an earlier post, expectancy was associated with profit 
factor. 
> > > It is more closely related to payoff ratio.
> > > In Van Tharp's book, 2nd edition, "Trade your way...", page 204 
et
> > > seq, he calculates 
> > > Expectancy = average profit/ # trades
> > >   divided by average loss.
> > > Payoff ratio is average profit/average loss,
> > > so 
> > > Expectancy = payoff ratio/# trades.
> > > --which can give very low numbers, and makes the concept rather
> > > dubious if you are using it as an absolute value for comparing 
> > systems
> > > with different numbers of trades. It might be better to use 
trades 
> > per
> > > annum.
> > > To be fair Van Tharp only gives that way of calculating 
expectancy 
> > as
> > > a default if the risk of a trade isn't able to be calculated 
taking
> > > into account a pre-determined proportion of equity. For that, 
you 
> > need
> > > to read the whole chapter.
> > > Personally i find CAR/MDD, RRR more relevant, along with the raw
> > > Payoff ratio.
> > >   
> > > The K-ratio isn't worth the space it takes up: RRR is simpler.
> > > 
> > > regards 
> > > Gerry
> > >
> >
>



------------------------------------

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 NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:amibroker-digest@xxxxxxxxxxxxxxx 
    mailto:amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

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