NexusFi: Find Your Edge


Home Menu

 





Expectancy custom fitness


Discussion in EasyLanguage Programming

Updated
      Top Posters
    1. looks_one Big Mike with 7 posts (0 thanks)
    2. looks_two sam028 with 4 posts (4 thanks)
    3. looks_3 aslan with 1 posts (0 thanks)
    4. looks_4 zerobot007 with 1 posts (2 thanks)
    1. trending_up 10,647 views
    2. thumb_up 6 thanks given
    3. group 4 followers
    1. forum 13 posts
    2. attach_file 1 attachments




 
Search this Thread
  #1 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,759 since Jun 2009
Thanks Given: 3,828
Thanks Received: 4,647

A custom criteria for MC optimization, the expectancy:

 
Code
                            
if ( StrategyPerformance.TotalTrades.Count == || StrategyPerformance.LosingTrades.Count== ) {

  return 
0;
}

return  (
StrategyPerformance.PercentProfitable*StrategyPerformance.AvgWinningTrade StrategyPerformance.WinningTrades*StrategyPerformance.AvgLosingTrade); 
It might be good to be able to optimize a strategy parameters with a Sharpe ratio, as this ratio is already known by MC, but I haven't already found if it's possible or not...


Success requires no deodorant! (Sun Tzu)
Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Iran Deal "In Review" at 87% on Deadline Day - …
Prediction Markets & Event Contracts
Fed Hike Odds at 57% After Warsh: England Surges 12.9%, …
Prediction Markets & Event Contracts
Khamenei Vetoes Uranium Transfer as Peace Odds Surge to …
Prediction Markets & Event Contracts
UCL Final Kicks Off at Noon ET: PSG at 56.5% as Iran May …
Prediction Markets & Event Contracts
Beijing Summit Closes: Xi Pledges Hormuz Help -- $1.14B …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
13 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #3 (permalink)
 
aslan's Avatar
 aslan 
Madison, WI
Market Wizard
 
Experience: Advanced
Platform: ALT
Trading: ES
Posts: 624 since Jan 2010
Thanks Given: 356
Thanks Received: 1,129


I have not done any custom criteria, would you mind explaining how to use that in MC?


Reply With Quote
  #4 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,759 since Jun 2009
Thanks Given: 3,828
Thanks Received: 4,647

Check screenshot below.



There is 18 standard criterias (Net profit, %Profitable, ...), but you can also define yours.


Success requires no deodorant! (Sun Tzu)
Started this thread Reply With Quote
Thanked by:
  #5 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,577

Awesome, thx Sam - I needed this

Mike




We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on X Visit my NexusFi Trade Journal Reply With Quote
  #6 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,577

Hmm, Sam I had problems with your code.

I define expectancy like this:

((avgWinningDollar * pctWinners) - (avgLosingDollar * pctLosers)) / avgLosingDollar

[img]https://nexusfi.com/v/cuhyfh.png[/img]

A real world example:

avgWinningDollar = 405.88
pctWinners = 43.59%
avgLosingDollar = 209.39
pctLosers = 56.41%

The result should be:
(405.88 * 0.4359) - (209.39 * 0.5641) / 209.39

Which gives us:
0.28, a very low and poor expectancy (1.0 or above is desired).

Since my code is dramatically different than yours, I'm including it here. Thanks for forcing me to take the time to do it - needed to be done!

 
Code
                            
// Expectancy
if ( StrategyPerformance.TotalTrades.Count == || StrategyPerformance.LosingTrades.Count== ) {
  return 
0;
}

// (avgWinDollar * pctWin + avgLoseDollar * pctLose) / Abs(avgLoseDollar)
return ((StrategyPerformance.AvgWinningTrade * (StrategyPerformance.PercentProfitable 100)) + (StrategyPerformance.AvgLosingTrade * (- (StrategyPerformance.PercentProfitable 100)))) / -StrategyPerformance.AvgLosingTrade;; 
Mike




We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on X Visit my NexusFi Trade Journal Reply With Quote
  #7 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,577

Hmm, here is another update. Seems I needed to check for some more division by zero.

 
Code
                            
// Expectancy
if ( StrategyPerformance.TotalTrades.Count == || StrategyPerformance.LosingTrades.Count== || StrategyPerformance.PercentProfitable == || StrategyPerformance.PercentProfitable == 100 || StrategyPerformance.AvgWinningTrade == || StrategyPerformance.AvgLosingTrade == ) {
  return 
0;
}

// ((avgWinDollar * pctWin) + (avgLoseDollar * pctLose) / Abs(avgLoseDollar)
return ((StrategyPerformance.AvgWinningTrade * (StrategyPerformance.PercentProfitable 100)) + (StrategyPerformance.AvgLosingTrade * (- (StrategyPerformance.PercentProfitable 100)))) / -StrategyPerformance.AvgLosingTrade
Mike




We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on X Visit my NexusFi Trade Journal Reply With Quote
  #8 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,759 since Jun 2009
Thanks Given: 3,828
Thanks Received: 4,647

Hmm, for me it's:
Expectancy = (Probability of Win * Average Win) - (Probability of Loss * Average Loss)
, and the higher the better.
But I'll check this, I'm maybe wrong.

There is a post on this here.


Success requires no deodorant! (Sun Tzu)
Started this thread Reply With Quote
Thanked by:
  #9 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,577


sam028 View Post
Hmm, for me it's:
Expectancy = (Probability of Win * Average Win) - (Probability of Loss * Average Loss)
, and the higher the better.
But I'll check this, I'm maybe wrong.

There is a post on this here.

Hi Sam,

That post says:


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

Hmm. I got mine from Elliott Wave's version in NinjaTrader.

We do agree, higher the better. An expectancy of less than 1.0 means you can expect it to lose money

I wonder how it will compare to each other in actual optimization testing?

Mike




We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on X Visit my NexusFi Trade Journal Reply With Quote
  #10 (permalink)
 
Big Mike's Avatar
 Big Mike 
Manta, Ecuador
Site Administrator
Developer
Swing Trader
 
Experience: Advanced
Platform: Custom solution
Broker: IBKR
Trading: Stocks & Futures
Frequency: Every few days
Duration: Weeks
Posts: 50,669 since Jun 2009
Thanks Given: 33,669
Thanks Received: 102,577


More from user Elliott Wave here:
Optimizer Type: Max. Expectancy - NinjaTrader Support Forum

Let me know your thoughts!

Mike




We're here to help: just ask the community or contact our Help Desk

Quick Links: Change your Username or Register as a Vendor
Searching for trading reviews? Review this list
Lifetime Elite Membership: Sign-up for only $149 USD
Exclusive money saving offers from our Site Sponsors: Browse Offers
Report problems with the site: Using the NexusFi changelog thread
Follow me on X Visit my NexusFi Trade Journal Reply With Quote




Last Updated on September 29, 2010


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts