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 Quick Summary with 1 posts (0 thanks)
    4. looks_4 aslan with 1 posts (0 thanks)
    1. trending_up 8,586 views
    2. thumb_up 6 thanks given
    3. group 4 followers
    1. forum 13 posts
    2. attach_file 1 attachments




 
Search this Thread

Expectancy custom fitness

  #1 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629

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)
Follow me on Twitter Started this thread Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
Exit Strategy
NinjaTrader
ZombieSqueeze
Platforms and Indicators
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
NexusFi Journal Challenge - April 2024
Feedback and Announcements
Futures True Range Report
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Get funded firms 2023/2024 - Any recommendations or word …
61 thanks
Funded Trader platforms
39 thanks
NexusFi site changelog and issues/problem reporting
26 thanks
Battlestations: Show us your trading desks!
26 thanks
The Program
18 thanks
  #3 (permalink)
 
aslan's Avatar
 aslan 
Madison, WI
 
Experience: Advanced
Platform: ALT
Trading: ES
Posts: 625 since Jan 2010
Thanks Given: 356
Thanks Received: 1,127


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,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629

Check screenshot below.



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

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter 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,396 since Jun 2009
Thanks Given: 33,172
Thanks Received: 101,534

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 Twitter 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,396 since Jun 2009
Thanks Given: 33,172
Thanks Received: 101,534

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 Twitter 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,396 since Jun 2009
Thanks Given: 33,172
Thanks Received: 101,534

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 Twitter Visit my NexusFi Trade Journal Reply With Quote
  #8 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629

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)
Follow me on Twitter 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,396 since Jun 2009
Thanks Given: 33,172
Thanks Received: 101,534


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 Twitter 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,396 since Jun 2009
Thanks Given: 33,172
Thanks Received: 101,534


More from user Elliott Wave here:
Optimizer Type: Max. [AUTOLINK]Expectancy[/AUTOLINK] - [AUTOLINK]NinjaTrader[/AUTOLINK] 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 Twitter Visit my NexusFi Trade Journal Reply With Quote




Last Updated on September 29, 2010


© 2024 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 - Privacy Policy - Downloads - Top
no new posts