Expectancy custom fitness (please add to built-in options!)

Questions about MultiCharts and user contributed studies.
ctrlbrk
Posts: 79
Joined: 18 Feb 2010
Location: Dallas, TX
Contact:

Expectancy custom fitness (please add to built-in options!)

Postby ctrlbrk » 29 Mar 2010

Here is the custom fitness for Expectancy. I really hope MC will add this to the built-in drop down box so it doesn't take up my one and only custom slot :)

Code: Select all

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

return ((StrategyPerformance.AvgWinningTrade * (StrategyPerformance.PercentProfitable / 100)) + (StrategyPerformance.AvgLosingTrade * (1 - (StrategyPerformance.PercentProfitable / 100)))) / -StrategyPerformance.AvgLosingTrade;;
Mike

ctrlbrk
Posts: 79
Joined: 18 Feb 2010
Location: Dallas, TX
Contact:

Postby ctrlbrk » 29 Mar 2010

Hmm oops, here is a better version -- it seems I needed to do extra checking for division by zero.

Code: Select all

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

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

geektrader
Posts: 100
Joined: 17 Jul 2009
Location: Germany

Postby geektrader » 29 Mar 2010

Thanks a lot, that´s a nice one, didn´t know you could code such complicated formulas in the custom optimization!

Do you have more custom fitness functions for MC?

Thanks a lot again!

Tresor
Posts: 1104
Joined: 29 Mar 2008
Has thanked: 12 times
Been thanked: 53 times

Postby Tresor » 12 Jun 2010

Here you can read about formula that can be used in fitness function to optimise to arive at most linear equity curve: http://kreslik.com/forums/viewtopic.php ... pe&start=0

I think it would be nice to have fitness function built-in MC that will allow you to optimise this way.

From the author: This way, I am not interested in absolute NetProfit, but intead in a smooth, linear equity curve which lends itself to applying position sizing algorithms more easily.


Return to “MultiCharts”