Van Tharp's Max Expectancy - Psychology and Money Management | futures io social day trading
futures io futures trading

Van Tharp's Max Expectancy
Updated: Views / Replies:17,370 / 31
Created: by caprica Attachments:1

Welcome to futures io.

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

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

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

Thread Tools Search this Thread

Van Tharp's Max Expectancy

  #31 (permalink)
Patient Discipline
Bellingham, WA USA
Futures Experience: Beginner
Platform: NT
Broker/Data: Mirus (Broker), Continuum (Data), Dorman (Clearing)
Favorite Futures: Futures
aventeren's Avatar
Posts: 202 since Mar 2013
Thanks: 426 given, 191 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.



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?



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

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

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 (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();
		public override double GetPerformanceValue(SystemPerformance systemPerformance)
			#region Logic Description
			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
			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) 
			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.
			/// 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;

Last edited by aventeren; February 20th, 2014 at 02:33 PM. Reason: Added code...
Reply With Quote
The following user says Thank You to aventeren for this post:
  #32 (permalink)
Elite Member
Toronto, Ontario, Canada
Futures Experience: Advanced
Platform: Ninja, MultiCharts
Favorite Futures: ES
Posts: 13 since Feb 2014
Thanks: 27 given, 15 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 > > > Van Tharp's Max Expectancy

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Upcoming Webinars and Events (4:30PM ET unless noted)

Wyckoff Hunting for Great Risk/Reward Ratio w/Gary Fullett

Elite only

Digging into the Details of iSystems w/Stage 5 & iSystems

Jun 5

Similar Threads
Thread Thread Starter Forum Replies Last Post
Van Tharp Books Dusty909 Psychology and Money Management 22 August 15th, 2016 11:57 AM
Van Tharp's Secrets of Trading Game caprica The Elite Circle 2 March 8th, 2012 10:26 AM
Position Sizing by Van Tharp Laserdan Psychology and Money Management 21 July 8th, 2011 10:37 AM
What Type Trader Are You? - more from Van Tharp Trader.Jon Psychology and Money Management 0 November 12th, 2009 08:47 AM

All times are GMT -4. The time now is 11:38 PM.

Copyright © 2018 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432,
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
Page generated 2018-05-27 in 0.08 seconds with 20 queries on phoenix via your IP