PDA

View Full Version : Money Management Alghtms.


magicboiz
01-12-2009, 08:58 AM
Hi all,

I'm looking for some money management algorithms like Kelly-F, Optimal-F, Secure-F, etc.

I'd search in the forum, and Id find a Kelly-F post (http://www.ninjatrader-support2.com/vb/showthread.php?t=12137&highlight=magicboiz), but nothing else...... do you know if anybody using NT has developed these algorithms?

Regards

NinjaTrader_Josh
01-12-2009, 09:05 AM
Hi magicboiz,

I am not aware of any released publicly on our forums, but you can check the file sharing section to see if you find anything suitable.

TCT-Peter
01-13-2009, 06:51 PM
Hi magicboiz,

I am not aware of any released publicly on our forums, but you can check the file sharing section to see if you find anything suitable.

I usually export the Win/Loss ratio and Pcnt Profitable to an excel spreadsheet and calculate Kelly Statistic there. It's defined simply as:

P-Q/W where P = Percent Probability of Profit, Q = (1-P) or Percent Probability of Loss, and W is the Win Size/Loss Size Ratio.

Optimal F can't be done with a simple formula. It's a brute force approach iterating over all trades for all potential value of optimal f until the optimum value is found. Once again, I do it in a separate Excel spreadsheet from the trades list. It would be possible to do in NT but the effort is probably not worth it.

I find that the Kelly statistic is generally more conservative than optimal F, so I just use Kelly as a simple "goodness" measure.

NinjaTrader_Bertrand
01-14-2009, 05:51 AM
Thanks for the valuable input Peter!

shiptastic
01-15-2009, 01:35 PM
I'm trying to calculate Kelly realtime but everytime my code gets to the calculation it freezes and I can't figure out why. It compiles fine but I think it's running into something strange I'm not a good enough programmer to figure out...or it's simple and I just need someone to give me a wake up call... here it is

if(Performance.AllTrades.LosingTrades.Count > 10 && Performance.AllTrades.WinningTrades.Count > 10)
{

avgwin = Convert.ToDouble(Performance.AllTrades.WinningTrad es.TradesPerformance.Currency) / Convert.ToDouble(Performance.AllTrades.WinningTrad es.Count);
avgloss = Convert.ToDouble(Performance.AllTrades.LosingTrade s.TradesPerformance.Currency) / Convert.ToDouble(Performance.AllTrades.LosingTrade s.Count);
winpct = Convert.ToDouble(Performance.AllTrades.WinningTrad es.Count) / Convert.ToDouble(Performance.AllTrades.Count);
wlratio = avgwin / avgloss;
kelly = winpct - ((1-winpct)/wlratio);
Print("Kelly = ");
Print(kelly);
}

Thanks,

Shiptastic

shiptastic
01-15-2009, 01:36 PM
oh and those spaces that are showing up on what I pasted aren't there in the actual code...

NinjaTrader_Josh
01-15-2009, 01:43 PM
You can cast to double just by doing (double).

(double) someVariable

Other than that you will just need to add Print functions into your code to figure out which line is causing problems. Then go from there to fixing it.

shiptastic
01-16-2009, 09:28 AM
I'm surprised you didn't catch it. I figured out what I was doing wrong.

The actual call I should of been using was:

Performance.AllTrades.WinningTrades.TradesPerforma nce.GrossProfit

Not "".Currency

I like the trick with the (double) though, that's nice.

NinjaTrader_Josh
01-16-2009, 09:32 AM
shiptastic,

Glad you got it resolved.