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,498 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

(login for full post details)
  #1 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,761 since Jun 2009
Thanks Given: 3,823
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
The following 2 users say Thank You to sam028 for this post:

Can you help answer these questions
from other members on NexusFi?
Request for MACD with option to use different MAs for fa …
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
The space time continuum and the dynamics of a financial …
Emini and Emicro Index
News alerts
Traders Hideout
ISO Equity Curve Indicator
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Tao te Trade: way of the WLD
36 thanks
Deaddogs Stock Trading
27 thanks
GFIs1 1 DAX trade per day journal
25 thanks
Supertradersams Thread Journal on NQ/MNQ
24 thanks
Leaving CFD trading and learning futures
12 thanks

(login for full post details)
  #3 (permalink)
 
aslan's Avatar
 aslan 
Madison, WI
 
Experience: Advanced
Platform: ALT
Trading: ES
Posts: 623 since Jan 2010
Thanks Given: 351
Thanks Received: 1,123


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

Reply With Quote
(login for full post details)
  #4 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,761 since Jun 2009
Thanks Given: 3,823
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
The following user says Thank You to sam028 for this post:
(login for full post details)
  #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
Posts: 50,233 since Jun 2009
Thanks Given: 33,105
Thanks Received: 101,350

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


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


Lifetime Elite Membership: Sign-up for only $149 USD
Receive exclusive 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
(login for full post details)
  #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
Posts: 50,233 since Jun 2009
Thanks Given: 33,105
Thanks Received: 101,350

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


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


Lifetime Elite Membership: Sign-up for only $149 USD
Receive exclusive 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
(login for full post details)
  #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
Posts: 50,233 since Jun 2009
Thanks Given: 33,105
Thanks Received: 101,350

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


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


Lifetime Elite Membership: Sign-up for only $149 USD
Receive exclusive 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
(login for full post details)
  #8 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,761 since Jun 2009
Thanks Given: 3,823
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
The following user says Thank You to sam028 for this post:
(login for full post details)
  #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
Posts: 50,233 since Jun 2009
Thanks Given: 33,105
Thanks Received: 101,350


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


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


Lifetime Elite Membership: Sign-up for only $149 USD
Receive exclusive 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
(login for full post details)
  #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
Posts: 50,233 since Jun 2009
Thanks Given: 33,105
Thanks Received: 101,350


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


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


Lifetime Elite Membership: Sign-up for only $149 USD
Receive exclusive 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