Van Tharp's Max Expectancy - futures io
futures io



Van Tharp's Max Expectancy


Discussion in Psychology and Money Management

Updated
      Top Posters
    1. looks_one rickt with 7 posts (4 thanks)
    2. looks_two Big Mike with 4 posts (4 thanks)
    3. looks_3 verge with 3 posts (1 thanks)
    4. looks_4 caprica with 3 posts (16 thanks)
      Best Posters
    1. looks_one gordo with 5.5 thanks per post
    2. looks_two caprica with 5.3 thanks per post
    3. looks_3 Anagoge with 4 thanks per post
    4. looks_4 rickt with 0.6 thanks per post
    1. trending_up 21,038 views
    2. thumb_up 47 thanks given
    3. group 24 followers
    1. forum 31 posts
    2. attach_file 1 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Van Tharp's Max Expectancy

(login for full post details)
  #1 (permalink)
 caprica 
USA
 
Experience: Master
Platform: NinjaTrader
 
caprica's Avatar
 
Posts: 155 since Jul 2009
Thanks: 45 given, 112 received

I just uploaded another NinjaTrader optimizer type max expectancy. The credit goes to Elliott Wave. Anagoge also helped.

It is here:


If you are not familiar with expectancy, here are few articles to whet your appetite:
Market Talk with Piranha: What is Expectancy?

Advance Your Finance: The Art of Expectancy

Trading 101: Expectancy - Trader Mike

Amazon.com: Trade Your Way to Financial Freedom (0639785305590): Van K. Tharp: Books

To quote a few key pieces of information:


Quoting 
So what is expectancy?

Expectancy is your profit percentage per win multiplied by your win rate minus your loss percentage per loss multiplied by your loss rate.

Expectancy tells you what you can expect to make (win or lose) for every dollar risked. Casinos make money because the expectancy of every one of their games is in their favor. Play long enough and you are expected to lose and they are expected to win because the “odds” are in their favor.


Quoting 
Example, you could have 99 losing trades, each costing you a dollar. Thus, you would be down $99. However, if you had one winning trade of $500, then you would have a net payoff of $401 ($500 less $99)—despite the fact that only one of your trades was a winner and 99% of your trades were losers.

It is my hope you will find this info valuable and can use it to further explore some better trade management, risk management and overall money management systems.

"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

Started this thread Reply With Quote
The following 8 users say Thank You to caprica for this post:

Journal Challenge April 2021 results (now extended!):
Competing for $1800 in prizes from Jigsaw
looks_oneMaking a Living with the Microsby sstheo
(602 thanks from 60 posts)
looks_twoSalao's Journalby Salao
(147 thanks from 26 posts)
looks_3Learning to Profit - A journey in algorithms and optionsby Syntax
(112 thanks from 26 posts)
looks_4Deetee’s DAX Trading Journal (time based)by Deetee
(94 thanks from 30 posts)
looks_5Maybe a little bit different journalby Malykubo
(46 thanks from 29 posts)
 
Best Threads (Most Thanked)
in the last 7 days on futures io
I finally blew up an account
491 thanks
Spoo-nalysis ES e-mini futures S&P 500
63 thanks
The Crude Dude Oil Trading System
61 thanks
The tiyfTradePlanFactory indicator
21 thanks
The New Micro Contract - MICRO BITCOIN coming May 2021
20 thanks
 
(login for full post details)
  #2 (permalink)
 caprica 
USA
 
Experience: Master
Platform: NinjaTrader
 
caprica's Avatar
 
Posts: 155 since Jul 2009
Thanks: 45 given, 112 received

Here is a spreadsheet that can be used to calculate expectancy if you like to use Excel instead of Ninja.

Attached Files
Register to download File Type: xls expectancy.xls (21.0 KB, 522 views)
Started this thread Reply With Quote
The following 7 users say Thank You to caprica for this post:
 
(login for full post details)
  #3 (permalink)
Anagoge
Missouri, USA
 
 
Posts: 2 since Jun 2009
Thanks: 3 given, 1 received


I mentioned this in the NT forum thread concerning this, but it might be worth repeating here. In my opinion, expectancy is a useful bit of data to know about your trading system and evaluate risk/reward, but it is not a very good way to optimize a trading system. The reason is that the expectancy number ignores the number of trades. Expectancy will be higher for a system that averages $100 per trade but only trades once a week compared to a system that earns $50 per trade and trades every hour. For this reason, I'd definitely recommend SQN over expectancy for optimizing. An exception to this might be if you are optimizing a strategy that you only want to trade occasionally, and you are willing to invest your money in alternative strategies when this one isn't issuing signals. In that case, having a system with limited signals (but high expectancy) may not be a problem.

Reply With Quote
The following 4 users say Thank You to Anagoge for this post:
 
(login for full post details)
  #4 (permalink)
 caprica 
USA
 
Experience: Master
Platform: NinjaTrader
 
caprica's Avatar
 
Posts: 155 since Jul 2009
Thanks: 45 given, 112 received


Anagoge View Post
I mentioned this in the NT forum thread concerning this, but it might be worth repeating here. In my opinion, expectancy is a useful bit of data to know about your trading system and evaluate risk/reward, but it is not a very good way to optimize a trading system. The reason is that the expectancy number ignores the number of trades. Expectancy will be higher for a system that averages $100 per trade but only trades once a week compared to a system that earns $50 per trade and trades every hour. For this reason, I'd definitely recommend SQN over expectancy for optimizing. An exception to this might be if you are optimizing a strategy that you only want to trade occasionally, and you are willing to invest your money in alternative strategies when this one isn't issuing signals. In that case, having a system with limited signals (but high expectancy) may not be a problem.

i wrote a custom formula that weighs the net profit, expectancy, and number of trades per day. it throws out (return double.NegativeInfinity) values that also have fewer than a certain number of trades per set/job.

i am really finding it quite useful. i like SQN as well but like expectancy better with my custom weighted formula.

still what you've said is absolutely true.

"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

Started this thread Reply With Quote
The following user says Thank You to caprica for this post:
 
(login for full post details)
  #5 (permalink)
rickt
ma
 
 
Posts: 9 since Oct 2009
Thanks: 0 given, 4 received

I think that I like 'expectancy score' better because it also takes into account time. I found it at URC Trading - Expectancy Score vs Sharpe Ratio and is expectancy * opportunity where expectancy = (aw*pw+al*pl)/|al| and opportunity = # trades * 365/studydays. A good explanation is provided at the link I gave.

Reply With Quote
 
(login for full post details)
  #6 (permalink)
 samurai 
CO
 
Experience: Intermediate
Platform: NinjaTrader
 
Posts: 29 since Sep 2009
Thanks: 228 given, 45 received

rickt

Since Trade Your Way to Financial Freedom, Tharp has expanded on the concept of system quality by creating a variation of the Student's T-Test called System Quality Number (SQN).
SQN = SquareRoot(N) * (Avg Trade Result/Standard Deviation(Avg Trade Result))
Where:
N = # of Trades (Truncated at 100 -- this is Tharp's variation)
Avg Trade = another way to determine expectancy
This formula takes frequency (N), reliability (Standard Deviation of avg trade), and expectancy (Avg Trade) and produces an objective score of any system.

Tharp goes into more detail in his book, The Definitive Guide to Position Sizing.

I find SQN to be a much better measure of a system's overall performance than expectancy alone.

-Samurai

Reply With Quote
The following 2 users say Thank You to samurai for this post:
 
(login for full post details)
  #7 (permalink)
rickt
ma
 
 
Posts: 9 since Oct 2009
Thanks: 0 given, 4 received

I understand about SQN, but I think it is lacking because it does not take time into account. An investment that returns 10% in 2 days is better than an investment that returns 10% in more than 2 days.

Expectancy score is NOT the same as expectancy. It uses expectancy and then multiplies by opportunity, which is where time is factored in.

To my way of thinking, time is a critical element in any trading or investing strategy.

Reply With Quote
The following user says Thank You to rickt for this post:
 
(login for full post details)
  #8 (permalink)
 verge 
Cape Town, South Africa
 
Experience: Beginner
Platform: NinjaTrader
Broker: Zen-fire
Trading: EUR/USD
 
Posts: 41 since Aug 2009
Thanks: 22 given, 12 received


rickt View Post
I think that I like 'expectancy score' better because it also takes into account time. I found it at URC Trading - Expectancy Score vs Sharpe Ratio and is expectancy * opportunity where expectancy = (aw*pw+al*pl)/|al| and opportunity = # trades * 365/studydays. A good explanation is provided at the link I gave.


rickt

I agree with you - after reading the article at the link you posted.

Do you have code for the "expectancy score" that you can share?

Verge

Reply With Quote
 
(login for full post details)
  #9 (permalink)
rickt
ma
 
 
Posts: 9 since Oct 2009
Thanks: 0 given, 4 received

Sorry - the only 'code' that I have it in is EXCEL. Maybe one of these days I will learn what it is you guys here use.

Reply With Quote
 
(login for full post details)
  #10 (permalink)
 verge 
Cape Town, South Africa
 
Experience: Beginner
Platform: NinjaTrader
Broker: Zen-fire
Trading: EUR/USD
 
Posts: 41 since Aug 2009
Thanks: 22 given, 12 received



rickt View Post
Sorry - the only 'code' that I have it in is EXCEL. Maybe one of these days I will learn what it is you guys here use.


I had a look at the original thread started by Ellio Wave here :

Optimizer Type: Max. Expectancy - NinjaTrader Support Forum

He mentions early in the thread that he only got the "expectancy score" version working.

I now had a look in the Expectancy optimizer type. The following formula is used:
expectancyTemp = (aveWin * percentWin + aveLose * percentLose)/ Math.Abs(aveLose)

Note the devision by the absolute value of the losing trades - which may not be what everyone thinks it should be.



Reply With Quote
The following user says Thank You to verge for this post:
 
(login for full post details)
  #11 (permalink)
rickt
ma
 
 
Posts: 9 since Oct 2009
Thanks: 0 given, 4 received

If you posted the whole formula that is used, it is missing the opportunity portion which takes time into account.

I wonder what would happen if the absolute value of the losing trades was replaced by the standard deviation of all the trades? Would that have any merit??

Reply With Quote
 
(login for full post details)
  #12 (permalink)
 verge 
Cape Town, South Africa
 
Experience: Beginner
Platform: NinjaTrader
Broker: Zen-fire
Trading: EUR/USD
 
Posts: 41 since Aug 2009
Thanks: 22 given, 12 received

Here is the complete formula:

percentWin = (double) systemPerformance.AllTrades.WinningTrades.Count / systemPerformance.AllTrades.Count;
percentLose = (double) systemPerformance.AllTrades.LosingTrades.Count / systemPerformance.AllTrades.Count;
aveWin = systemPerformance.AllTrades.WinningTrades.TradesPerformance.Currency.AvgProfit;
aveLose = systemPerformance.AllTrades.LosingTrades.TradesPerformance.Currency.AvgProfit;
expectancyTemp = (aveWin * percentWin + aveLose * percentLose)/ Math.Abs(aveLose);

btw - I opened it with Sharpdevelop (at www.sharpdevelop.net) which is a free C# IDE.

Give it a try and make all the changes you want. Personally I need to try the optimization formulas out there first before I go and change things.

Reply With Quote
 
(login for full post details)
  #13 (permalink)
rickt
ma
 
 
Posts: 9 since Oct 2009
Thanks: 0 given, 4 received

Thanks.

I examined the code and it is missing the part that differentiates expectancy from expectancy score. What the presented code gives is a modified expectancy. If we take expectancyTemp and multiply it by opportunity as presented by the article I linked to in a previous post in this thread, we would then have expectancy score.

I would love to give it a try and make changes, but I really, at this time, have no idea about how to use the testing platform thyat you use. I will get thereb though.

Reply With Quote
 
(login for full post details)
  #14 (permalink)
rickt
ma
 
 
Posts: 9 since Oct 2009
Thanks: 0 given, 4 received

I have just run a bunch of tests on several strategies that I am playing with and have calculated SQN, expectancy score, and a few other metrics for those tests. I am in a quandry.

Theoretically, when looking at several strategies, there is one that is better than all the others when run over the same time frame for the same set of securities. But better in what regard? That is the question. I am afraid that the answer is in the eye of the beholder.

In this thread we have discussed expectancy, sqn, and expectancy score. Looking at these 3 metrics against my tested strategies, I have not found any correlation reflecting the goodness of any strategy. In other words, what is shown to be best by one indicator is not shown to be best by any other indicator.

So again, the question comes down to exactly what are we looking for to determine goodness?

We are all doing this to make money. So that must be a criteria - how much money is returned. But because we all invest different amounts, the dollars returned must be a percentage of dollars invested. And because we know that 2% returned over 2 days is better than 2% returned over more than 2 days, we can divide the % dollars returned by the time frame (either minutes or days depending on whether we day trade or not). Taking that a step further, because we all invest over different time frames, we can multiply the result by 365 (for non day traders) or 480 (for day traders) in order to better compare the results.

Performing all of this, we have the following equation

($ returned / $ invested) * (365 / days in market) or
($ returned / $ invested) * (480 / minutes in market)

I am trying to decide whether this metric is sufficient or whether we must also account for variability using standard deviation or some such in which case we coulod end up with the following

(($ returned / $ invested) / stdev) * (365 / days in market) or
(($ returned / $ invested) / stdev) * (480 / minutes in market)

Thanks for letting me theorize here. I needed some place to discuss it. I would appreciate any and all input.

Rick

Reply With Quote
The following 3 users say Thank You to rickt for this post:
 
(login for full post details)
  #15 (permalink)
 samurai 
CO
 
Experience: Intermediate
Platform: NinjaTrader
 
Posts: 29 since Sep 2009
Thanks: 228 given, 45 received

Rick,

I believe it all comes down to one's personal preference.

Trader A may prefer a system that has a lower expectancy but also a lower variability over a system with a very high expectancy but with a larger variability of returns. Whereas Trader B may be looking for much higher returns and is willing to risk greater variability to get them.

Personally, I need to have an idea of the variability of the system I'm trading. That's why a metric which accounts for variability suits me better.



Regards,

Samurai

Reply With Quote
 
(login for full post details)
  #16 (permalink)
wuming79
Singapore
 
 
Posts: 3 since Apr 2010
Thanks: 0 given, 0 received

Hi, I hope someone reads this.

May I know how do I classify breakeven trades as? Do I count them as a win or a loss in the expectancy calculation???

Reply With Quote
 
(login for full post details)
  #17 (permalink)
 Big Mike 
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: Custom solution
Trading: Futures & Crypto
 
Big Mike's Avatar
 
Posts: 50,068 since Jun 2009
Thanks: 32,530 given, 98,483 received


wuming79 View Post
Hi, I hope someone reads this.

May I know how do I classify breakeven trades as? Do I count them as a win or a loss in the expectancy calculation???

The chance a trade is ever exactly breakeven is extremely slim, if you include commission (which you should).

Your platform can be configured to include commission in the net profit so I advise you do this, and as long as your commission is not exactly the equal to a tick of profit, then there should never be an exactly breakeven trade.

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/

Visit other sites? Please spread the word about your experience with our community!
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #18 (permalink)
rickt
ma
 
 
Posts: 9 since Oct 2009
Thanks: 0 given, 4 received

My understanding is that you do not count them as a win or a loss, but that you do not reduce the total trades. In other words, if you have 2 wins, 3 losses, a 4 breakevens, you would use 2 as the # of wins, 3 as the # of losses, and 9 as the # of total trades.

Of course, it should be a rare occurence to have a truly breakeven trade unless you are trading commissionless securities which would happen with mutual funds or some of the ETFs available through Fidelity.

Reply With Quote
 
(login for full post details)
  #19 (permalink)
wuming79
Singapore
 
 
Posts: 3 since Apr 2010
Thanks: 0 given, 0 received

Oh, I see. yah, I forgot about the commissions. Thanks guys.

Reply With Quote
 
(login for full post details)
  #20 (permalink)
wuming79
Singapore
 
 
Posts: 3 since Apr 2010
Thanks: 0 given, 0 received


rickt View Post
My understanding is that you do not count them as a win or a loss, but that you do not reduce the total trades. In other words, if you have 2 wins, 3 losses, a 4 breakevens, you would use 2 as the # of wins, 3 as the # of losses, and 9 as the # of total trades.

Of course, it should be a rare occurence to have a truly breakeven trade unless you are trading commissionless securities which would happen with mutual funds or some of the ETFs available through Fidelity.

Hi, I'm reading Van Tharp's "Trade Your Way to Financial Freedom". I don;t quite understand how the opportunity cost is calculated. Does anyone knows how he calculate it? The book seems to be measuring by number of opportunity per day. How does one calculate when he is doing forward testing?

Reply With Quote
 
(login for full post details)
  #21 (permalink)
 gunsnmoney 
Santa Clara, CA
 
Experience: Intermediate
Platform: NT8,
Broker: Tradier, TastyTrade
Trading: ES, Fx
 
Posts: 19 since Jul 2010
Thanks: 13 given, 18 received


rickt View Post
So again, the question comes down to exactly what are we looking for to determine goodness?

We are all doing this to make money. So that must be a criteria - how much money is returned. But because we all invest different amounts, the dollars returned must be a percentage of dollars invested. And because we know that 2% returned over 2 days is better than 2% returned over more than 2 days, we can divide the % dollars returned by the time frame (either minutes or days depending on whether we day trade or not). Taking that a step further, because we all invest over different time frames, we can multiply the result by 365 (for non day traders) or 480 (for day traders) in order to better compare the results.

Rick

Rick, this is why Van's concept of R is so important. If used correctly it normalizes the system to any account size (provided the account is of adequate trading size to begin with).

Here is a cool expectancy tool I found:

Random Equity Curve Simulator of a trading system. Learn it before you trade

G&M

Reply With Quote
The following user says Thank You to gunsnmoney for this post:
 
(login for full post details)
  #22 (permalink)
 gordo 
Tonganoxie, Kansas
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: CL,6E
 
gordo's Avatar
 
Posts: 160 since Nov 2009
Thanks: 129 given, 400 received

I wrote two optimization types (that work in NT 7 quite nicely) based on the information from this thread and Van Tharp's book. Here are the links:

Expectancy Score (which includes expectancy X opportunity), and

Expectancy (which does not include opportunity).

I use the Expectancy optimization all the time and find it gives me great direction when I am optimizing my stategies.

Gordo

Visit my futures io Trade Journal Reply With Quote
The following 11 users say Thank You to gordo for this post:
 
(login for full post details)
  #23 (permalink)
 Big Mike 
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: Custom solution
Trading: Futures & Crypto
 
Big Mike's Avatar
 
Posts: 50,068 since Jun 2009
Thanks: 32,530 given, 98,483 received

Nice work

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/

Visit other sites? Please spread the word about your experience with our community!
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
The following user says Thank You to Big Mike for this post:
 
(login for full post details)
  #24 (permalink)
mehol
United Arab Emirates
 
 
Posts: 2 since Oct 2011
Thanks: 0 given, 0 received

I want to understand more about a system ? how do i develop a system for myself ?

Reply With Quote
 
(login for full post details)
  #25 (permalink)
 gordo 
Tonganoxie, Kansas
 
Experience: Intermediate
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: CL,6E
 
gordo's Avatar
 
Posts: 160 since Nov 2009
Thanks: 129 given, 400 received

I have been doing some serious thinking about expectancy and the routines I wrote. I think my fundamental theory is flawed. The expectancy and expactancy score routines do the math correctly, but they utilize the NT Optimizer to operate. The optimizer (or backtesting if you will) is a serial analysis. That is you start in trade 1 long and follow that trade until you hit profit or you stop out. Then you look for trade 2 which let's say is a short and follow that one along until profit and or stop is reached and so on.

I think the way it SHOULD be done is in parallel. That is, you take every possible trade (long or short) and determine what results you would have achieved with your strategy and then you optimize to that.

I don't believe you can get their with Ninja. So where does that leave us? A different kind of optimizer...[on sale now for only $49.95...but if you act within the next 30 minutes, we will send you not one, but two optimizers...but wait there's more...we also have these amazing ginsue knives that we will give to the first 40 callers...so call now at BR-549!]

Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #26 (permalink)
 Big Mike 
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: Custom solution
Trading: Futures & Crypto
 
Big Mike's Avatar
 
Posts: 50,068 since Jun 2009
Thanks: 32,530 given, 98,483 received

Well different optimizers are possible, but extremely complex and based on my last experience a couple years ago they either didn't work with NT7 or worked very poorly.

Look here:




Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/

Visit other sites? Please spread the word about your experience with our community!
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
 
(login for full post details)
  #27 (permalink)
 szilard 
budapest
 
Experience: Advanced
Platform: nj
Trading: bund
 
Posts: 1 since Jun 2012
Thanks: 0 given, 0 received

Hi Everyone,

I have read the expectancy's threads, thanks for the optimalization script. My question , is it possible to add custom fields to the backtest result tab (to the summary grid) ? For example if it is possible I would like to edit that tab , and add it an expectancy field.

Thanks,
Szilard

Reply With Quote
 
(login for full post details)
  #28 (permalink)
 tornadoatc 
Ft. Lauderdale Florida
 
Experience: Intermediate
Platform: Tradestation
 
Posts: 17 since Apr 2010
Thanks: 31 given, 3 received


Timot View Post
If you are looking for positive expectancy systems all you have to do is look for positive net profit! No need to calculate the expectancy - it is a total waste of time. By definition, all systems with positive P/L will have positive expectancy. !!!

Maybe said another way is that a "positive expectancy system" should have an equity curve that is smooth and upward sloping.

An older now unavailable product called "The Grail" provided a nice means of quickly being able to see the resultant equity curve for each of the system tests. I personally found this a good means of identifying the systems that were worth evaluating further.

My thought is if would be possible to create an fitness function that identify systems with a strong upwardly sloping equity curve and was very smooth.

Maybe ... <Slope of Linear Reqression of Equity Curve> * <function that calculates "linearness" Equity Curve>

Maybe this is the end result of some of these advanced fitness algorithms ?

Reply With Quote
The following user says Thank You to tornadoatc for this post:
 
(login for full post details)
  #29 (permalink)
 Big Mike 
Site Administrator
Swing Trader
Data Scientist & DevOps
Manta, Ecuador
 
Experience: Advanced
Platform: Custom solution
Trading: Futures & Crypto
 
Big Mike's Avatar
 
Posts: 50,068 since Jun 2009
Thanks: 32,530 given, 98,483 received

In Al Brooks recent webinar on futures.io (formerly BMT):
Webinar: Al Brooks on Probabilities, Timing, Scaling

What he calls "The Traders Equation" is the same as Van Tharp's Expectancy. It's a good webinar.

A more advanced webinar on risk is here, from Ernie Chan on futures.io (formerly BMT):
Webinar: Ernest Chan - Capital Allocation and Risk Management

Mike

We're here to help -- just ask

For the best trading education, watch our webinars
Searching for trading reviews? Review this list

Follow us on Twitter, YouTube, and Facebook

Support our community as an Elite Member:
https://futures.io/elite/

Visit other sites? Please spread the word about your experience with our community!
Follow me on Twitter Visit my futures io Trade Journal Reply With Quote
The following 3 users say Thank You to Big Mike for this post:
 
(login for full post details)
  #30 (permalink)
Ocean69
Tillsonburg, Ontario, Canada
 
 
Posts: 1 since Oct 2012
Thanks: 0 given, 1 received

Timot

"More importantly I think after doing some studying that if you want to express the expectancy in terms of multiple R you can only do that when the risk per trade is a fixed amount. This is also obvious. This is also flawed. You will not risk the same with a high beta stock as with a low beta one.

Too much hype in this industry... "



Some people adjust for the beta using ATR as their stop. This allows you to trade consistently over each market type.

Reply With Quote
The following user says Thank You to Ocean69 for this post:
 
(login for full post details)
  #31 (permalink)
 aventeren 
Bellingham, WA USA
 
Experience: Beginner
Platform: NT
Broker: Mirus (Broker), Continuum (Data), Dorman (Clearing)
Trading: Futures
 
aventeren's Avatar
 
Posts: 202 since Mar 2013
Thanks: 428 given, 201 received


gordo View Post
I wrote two optimization types (that work in NT 7 quite nicely) based on the information from this thread and Van Tharp's book. Here are the links:

Expectancy Score (which includes expectancy X opportunity), and

Expectancy (which does not include opportunity).

I use the Expectancy optimization all the time and find it gives me great direction when I am optimizing my stategies.

Gordo

@gordo--

Thanks for coding the Expectancy Score optimizer.

I'm currently exploring the use of a few optimizers, and I have taken a look at the rationale behind the Expectancy Score, which appears pretty decent. So thanks for coding it up.

I did notice that the Expectancy Score does not appear to take commissions or slippage into account when calculating winsAmount or losesAmount.

Was the exclusion of commission and slippage on purpose?

It seems to me that we should be optimizing to a net expectancy score as opposed to a gross expectancy score.

What are your thoughts?

Thanks,

Aventeren

Here is the code for those that have not downloaded the .cs file.

 
Code
#region Using declarations
	using System;
	using System.ComponentModel;
	using System.Drawing;
	using NinjaTrader.Cbi;
	using NinjaTrader.Data;
	using NinjaTrader.Indicator;
	using NinjaTrader.Strategy;
#endregion

namespace NinjaTrader.Strategy
{
	// Expectany score calculations based on Van K. Tharp's book 'Trade Your Way to Financial Freedom'.
	// Portions of this code borrowed from fluxsmith at futures.io (formerly BMT).  Thanks for the start!
	// 4/28/2011.  Gordon Brest.
	[Gui.Design.DisplayName("Expectancy Score")]
    public class ExpectancyScore : OptimizationType
	{
		#region variables
			private int normalizedNumberTradesPerYear;
			private int numberScratchTrades;
			private int numberOfTrades;
			
			private double studyDays;
			private double averageWinningTrade;
			private double probabilityOfWinning;
			private double averageLosingTrade;
			private double probabilityOfLosing;
			private double nonScratchTrades;
			private double valueScratchTrades;
			private double winsAmount;
			private double winsCount;
			private double losesAmount;
			private double losesCount;
			private double expectancy;
			private double opportunity;
			private double commission;
			
			private bool init = false;
			
			private double val;
			
			public double expectancyScore;
			
			private DateTime start = new DateTime();
			private DateTime stop = new DateTime();
			private TimeSpan span = new TimeSpan();
		#endregion
		
		public override double GetPerformanceValue(SystemPerformance systemPerformance)
		{
			#region Logic Description
			/*
			Reference:  http://www.unicorn.us.com/trading/expectancy.html
			
			EXPECTANCY is how much you expect to earn from each trade for every dollar you risk. Opportunity is how often your strategy trades. 
			You want to maximize the product of both.
			
			Expectancy = (AW × PW + AL × PL) ⁄ |AL| 
			(expected profit per dollar risked)
			
			Expectancy score = Expectancy × Opportunity
			
			where 
			AW = average winning trade (excluding maximum win) 
			AL = average losing trade (negative, excluding scratch losses) 
			|AL| = absolute value of AL 
			
			PW = probability of winning: PW = <wins> ⁄ NST (where <wins> is total wins excluding maximum win) 
			PL = probability of losing: PL = <non-scratch losses> ⁄ NST  
			Opportunity = NST × 365 ⁄ studydays   (opportunities to trade in a year) 
			
			where
			NST = <total trades> − <scratch trades> − 1
			In other words, NST = non-scratch trades during the period under test (a scratch trade loses commission+slippage or less) minus 1 (to exclude the maximum win). 
			studydays = calendar days of history being tested 
			
			NOTE:  The above verbage from the referenced website has been copied into the code below to explain the code's logic.
			*/
			#endregion
			
			/// Number of trades.
			numberOfTrades = systemPerformance.AllTrades.TradesPerformance.TradesCount;
			normalizedNumberTradesPerYear = (int)(systemPerformance.AllTrades.TradesPerformance.TradesPerDay * 365.0);
			commission = systemPerformance.AllTrades.TradesPerformance.Commission / numberOfTrades * -1;
			// studydays = calendar days of history being tested 
			foreach (Trade allTrades in systemPerformance.AllTrades)
			{
				if (!init)
				{
					init = true;
					start = allTrades.Entry.Time.Date;
				}
				stop = allTrades.Entry.Time.Date;
			}
			span = stop.Subtract(start);
			studyDays = span.TotalDays + 1;
			
			/// Calculate scratch trades.
			numberScratchTrades = 0;
			valueScratchTrades = 0;
			// NST = <total trades> − <scratch trades> − 1
			// In other words, NST = non-scratch trades during the period under test (a scratch trade loses commission+slippage or less) minus 1 (to exclude the maximum win). 			foreach (Trade myTrade in systemPerformance.AllTrades.LosingTrades)
			foreach (Trade losingTrades in systemPerformance.AllTrades.LosingTrades)
			{
				if (losingTrades.ProfitCurrency >= 1.25 * commission)
				{
					numberScratchTrades ++;
					valueScratchTrades += losingTrades.ProfitCurrency;
				}
			}	
			nonScratchTrades = numberOfTrades - numberScratchTrades - 1;
			winsCount = systemPerformance.AllTrades.WinningTrades.Count;
			losesCount = systemPerformance.AllTrades.LosingTrades.Count - numberScratchTrades;
			
			/// Reject optimizations that do not make any trades.
			if ( normalizedNumberTradesPerYear == 0 )
				return 777;
			
			/// Reject optimizations that trade less than once a week.
			if ( normalizedNumberTradesPerYear < 50 )
				return 888;
			
			/// Reject optimizations that do not have any losing trades as unrealistic.
			if ( systemPerformance.AllTrades.LosingTrades.Count == 0 )
				return 999;
			
			/// Calculate averages.
			// AW = average winning trade (excluding maximum win) 
			winsAmount = systemPerformance.AllTrades.TradesPerformance.GrossProfit - systemPerformance.AllTrades.TradesPerformance.Currency.LargestWinner;
			averageWinningTrade = winsAmount / (systemPerformance.AllTrades.WinningTrades.Count - 1);
			
			// AL = average losing trade (negative, excluding scratch losses) 
			losesAmount = systemPerformance.AllTrades.TradesPerformance.GrossLoss - valueScratchTrades;
			averageLosingTrade =  losesAmount / (systemPerformance.AllTrades.LosingTrades.Count - numberScratchTrades);
			
			/// Calculate probabilities.
			// PW = probability of winning: PW = <wins> ⁄ NST (where <wins> is total wins excluding maximum win) 
			probabilityOfWinning = winsCount / nonScratchTrades;
			// PL = probability of losing: PL = <non-scratch losses> ⁄ NST  
			probabilityOfLosing = losesCount / nonScratchTrades;
			
			/// Final calculations.
			// Expectancy = (AW × PW + AL × PL) ⁄ |AL| where |AL| = absolute value of AL.
			expectancy = (averageWinningTrade * probabilityOfWinning + averageLosingTrade * probabilityOfLosing) / Math.Abs(averageLosingTrade);
			
			//val = expectancy;
			// Opportunity = NST × 365 ⁄ studydays   (opportunities to trade in a year) 
			opportunity = nonScratchTrades * 365 / studyDays;
			
			// Expectancy score = Expectancy × Opportunity
			expectancyScore = expectancy * opportunity;
			
			/// Return the final value.
			return expectancyScore;
		}
	}
}

Reply With Quote
The following user says Thank You to aventeren for this post:
 
(login for full post details)
  #32 (permalink)
 VolTrading 
Toronto, Ontario, Canada
 
Experience: Advanced
Platform: Ninja, MultiCharts
Trading: ES
 
Posts: 14 since Feb 2014
Thanks: 36 given, 17 received

@rickt - Replying to your post about dividing by AvgLoss vs. dividing by Std(TradeResults), I think that the latter gives a sense as to the likelihood that the TotalProfit occurred by chance or due to a true edge. This van Tharp approach strikes me as just a variation of the Sharpe Ratio (for good or ill).

In contrast the division by AvgLoss gives you what your results would look like over an extended period in terms of how much better your gains did over your losses, provided your system makes it over that extended period.

I like to analogize this to betting on the race car driver that wins the most races in a season as opposed to the one that is the wildest, fastest driver in the season's first three events but then crashes out in flames.

Reply With Quote


futures io Trading Community Psychology and Money Management > Van Tharp's Max Expectancy


Last Updated on January 22, 2015


Upcoming Webinars and Events

NinjaTrader Indicator Challenge!

Ongoing

Journal Challenge w/$1,800 in prizes!

May 7

The Cold Hard Truth: Maybe I Am Not Good Enough w/Chris Gray @ Earn2Trade

Elite only
     



Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada), info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts