Mathemagician Live! on Position Sizing

trading strategies and money management discussion, code, results

Moderator: moderators

aspTrader
rank: 50+ posts
rank: 50+ posts
Posts: 57
Joined: Fri May 19, 2006 5:05 am
Reputation: 0
Gender: None specified

Mathemagician Live! on Position Sizing

Postby aspTrader » Fri Jul 07, 2006 4:12 pm

Tradestation users who have browsed the Tradestation Forum will be acquainted with the work of John Joseph, CTA, of Dimension Creative Technologies. John is the infamous "Mathemagician" and he has agreed to make a presentation on Trade Position Sizing. Specifically...

The presentation begins with a general introduction of constant-account-equity position sizing and a survey of public-domain position sizing methods (e.g. constant contract, constant risk, constant volatility). Next will be a discussion of variable-account-size methods (i.e. compounding, a.k.a. money management) with a survey of public-domain methods (e.g. Fixed Fractional, Fixed Ratio, Optimal F). Throughout the presentation, the emphasis will be on application of the concepts using Tradestation and sample EasyLanguage code will be provided wherever possible. A complete sample trading system is provided.

We might transform some of the TS code that Math provides to NeoTicker during his Webinar during some future Sunday NeoTicker Webinar.

The webinar with Mathemagician is free.

July 16, 5am Pacific Daylight Time (currently GMT -7)

Registration is required before the webinar begins. You may register for it here:

https://www.gotomeeting.com/register/856006095

Cheers!

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.

brwkem
rank: 50+ posts
rank: 50+ posts
Posts: 82
Joined: Fri Jun 23, 2006 2:00 pm
Reputation: 0
Gender: None specified

Postby brwkem » Fri Jul 07, 2006 5:05 pm

Is Math contemplating switching to Neoticker?

aspTrader
rank: 50+ posts
rank: 50+ posts
Posts: 57
Joined: Fri May 19, 2006 5:05 am
Reputation: 0
Gender: None specified

Postby aspTrader » Fri Jul 07, 2006 7:45 pm

brwkem wrote:Is Math contemplating switching to Neoticker?


Not to my knowledge. He's doing this because I asked him to.

I think his views are interesting regardless of what platform he uses.

User avatar
michal.kreslik
rank: 1000+ posts
rank: 1000+ posts
Posts: 1048
Joined: Sat May 13, 2006 2:40 am
Reputation: 36
Location: Monte Carlo, Monaco
Real name: Michal Kreslik
Gender: Male

Postby michal.kreslik » Sun Jul 09, 2006 9:38 pm

I am really looking forward to the "Mathemagician Live!"

Thanks aspTrader for arranging this seminar.

brwkem wrote:Is Math contemplating switching to Neoticker?


aspTrader wrote:Not to my knowledge.


Well I'd say "never say never" BigGrin_Smile

obx
rank: <50 posts
rank: <50 posts
Posts: 41
Joined: Fri May 26, 2006 12:35 pm
Reputation: 0
Gender: Male

Postby obx » Fri Jul 14, 2006 9:55 pm

Please confirm date
Sunday 07/16/06 8:00 AM EDT ??

That is hardcore...

Thx,

obx

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.

User avatar
michal.kreslik
rank: 1000+ posts
rank: 1000+ posts
Posts: 1048
Joined: Sat May 13, 2006 2:40 am
Reputation: 36
Location: Monte Carlo, Monaco
Real name: Michal Kreslik
Gender: Male

Postby michal.kreslik » Fri Jul 14, 2006 10:51 pm

Forsooth, having Mathemagician live on a webinar really is kind of hardcore.. :)

User avatar
TomKeough
rank: <50 posts
rank: <50 posts
Posts: 29
Joined: Sat Jun 17, 2006 1:13 am
Reputation: 0
Location: Jacksonville, Florida
Real name: Tom Keough
Gender: Male
Contact:

MoneyManagement Book by Ralph Vince cited by Mathemagician

Postby TomKeough » Sun Jul 16, 2006 11:44 pm

michal.kreslik wrote:Forsooth, having Mathemagician live on a webinar really is kind of hardcore.. :)

FYI,
I bought the book cited by Mathemagician here:

http://www.powells.com/biblio/HARDCOVER ... =23955#top

for $25 used (no dustcover).
Tom
"We either make ourselves miserable,
or we make ourselves strong.
The amount of work is the same."
- Carlos Castaneda

jhtumblin
rank: 50+ posts
rank: 50+ posts
Posts: 113
Joined: Tue Jun 13, 2006 3:42 am
Reputation: 0
Location: Atlanta, GA
Gender: None specified

Postby jhtumblin » Mon Jul 17, 2006 3:33 am

After listening to John's presentation today, It still seems to me that the most important aspect of successful trading is figuring out which type of position sizing fits best with the methodology you trade. And in turn without a solid method, sizing doesn't matter at all.

I can't necessarily agree with him that there are some types of postioning which are unacceptable for any trading system, which is what I assumed he was implying from the shoot down of the Martingale methods. I have seen this method applied to many systems which use near even odds and some of them have been quite successful.

One idea he presented did spark my interest though, and that is when he stated "if you trade long enough using a non-optimal sizing method you will eventually experience its weakness, in turn causing you to lose everything." I know it's not a perfect quote, but I can see how after a period of time, you have to quit trading period, or at least reduce your risk capital in order to actually realize profits.

It was a good presentation and I appreciate him and the organizers taking the time for putting it on.

User avatar
TomKeough
rank: <50 posts
rank: <50 posts
Posts: 29
Joined: Sat Jun 17, 2006 1:13 am
Reputation: 0
Location: Jacksonville, Florida
Real name: Tom Keough
Gender: Male
Contact:

Optimal f MoneyManagement code from a trading system

Postby TomKeough » Mon Jul 17, 2006 4:29 am

I found this Optimal f MoneyManagement code for a trading system.
Here is the code:

Code: Select all

Notes for this Money Management Position Sizing Strategy:

Description

An Optimal F money management/position sizing strategy. Optimal F Money Management was developed by Ralph Vince as an aggressive way to grow your account balance. Optimal F is simply the optimal amount of capital that should be invested in each trade.

Optimal F has it's critics - with one of the major criticisms being that it is too risky. The money management strategy presented here focuses on the practical issues on how to implement Optimal F for a real trading system, and as such commentary about the wisdom of using Optimal-F is beyond the scope of this money management strategy. There are plenty of resources on the internet that discus Optimal F in great detail.

As the Optimal-F formula uses the trading history of the system in it's calculation the first issue that we first have to consider is what to do before there are enough trades for the results of Optimal-F to be statistically meaningful. The simplest solution - the one adopted here - is to wait for X trades to occur, and then use the real Optimal-F value. We then recalculate the value of Optimal-F after each trade.

This Optimal-F strategy is controlled by two variables: $mintrades and $defaultf. The value of $mintrades contains the number of trades that have to occur before the real value of Optimal-F is used. If the number of trades is less than $mintrades, the value of $defaultf is used to calculate the size of the position. These values can be changed in the PositionSize function.

All orders are supported with this money management, but for the case of stop and limit orders this money management expects to be passed the stop and limit prices. The actual position size that is calculated is suitable for stocks but with a little tweaking it can be used for futures or forex.

The calculation of Optimal-F that is used within this money management is extremely inefficient.


 Notes for this Money Management Position Sizing Strategy:



 PositionSize:




###########################
# Optimal F Money management - read notes for a description
# Play around with the vars below to change the settings of this MM
#
my $mintrades = 20;    #Minimum number of trades before optimal-f is used
my $defaultf  = 0.30;  #The value of optimal-f if we havn't got enough trades
#
#
############################

sub OptimalF {
  #This function uses a brute force approach to calculate the optimal f
  #and can be made *much* more efficient.
  #define our variables
  my ($BestTWR,$OptimalF,$f,$TWR,$HPR,$WSC);

  $WSC=LargestLosingTrade;
 
  #Loop round for all the values of f - in this case
  #all values between 1 and 100
  foreach my $per (1..100) {
    $f=$per/100; #Set F to be a percent
    $TWR=1;      #reset the TWR
    #Loop round all trades for this system
    foreach my $trade (TradeHistory) {
      #Work out the HPR and TWR
      $HPR=1+($f*($trade->NetProfit / $WSC));
      $TWR*=$HPR; 
    }
    #Output "f $f is TWR $TWR";
    #Is this the best f so far?
    if ($BestTWR<$TWR) {
      $BestTWR=$TWR;
      $OptimalF=$f;
    }
  }
  #Output "best $BestTWR Optimal F $OptimalF";
  #Return the optimal f
  return $OptimalF;
}

#Set the optimal-f to the default value
my $optimalf=$defaultf;

if (TotalTrades> $mintrades) {
  #we have enough trades - calculate the optimal-f
  $optimalf=OptimalF;
}
#Calculate the number of units we should hold for this position
my $units=int(($optimalf * LiquidatingValue)/ClosePrice);

return $units;


 BuyMarket event logic:




if (ShortPosition) {
  #If we have a short position, close it.
  PlaceBuyOpen('OptimalF');
}
else {
  #we have no position, or we are long.
  my $num=PositionSize();
  PlaceBuyOpen('OptimalF',$num) if $num;
}

 BuyStop event logic:




my $stop=shift;
#Stop trading if we do not have a stop price
die 'No stop price for BuyStop' unless $stop;

if (ShortPosition) {
  #If we have a short position, close it.
  PlaceBuyStop('OptimalFClosingShort',0,$stop);
}
else {
  #we have no position, or we are long.
  my $num=PositionSize();
  PlaceBuyStop('OptimalFGoingLong',$num,$stop) if $num;
}


 BuyLimit event logic:




my $limit=shift;
#Stop trading if we do not have a limit price
die 'No limit price for BuyLimit' unless $limit;

if (ShortPosition) {
  #If we have a short position, close it.
  PlaceBuyLimit('OptimalFClosingShort',0,$limit);
}
else {
  #we have no position, or we are long.
  my $num=PositionSize();
  PlaceBuyLimit('OptimalFGoingLong',$num,$limit) if $num;
}


 BuyStopLimit event logic:




my ($stop,$limit)=@_;
#Stop trading if we do not have a stop and limit price
die 'No limit price for BuyStopLimit' unless $limit;
die 'No stop price for BuyStopLimit' unless $stop;

if (ShortPosition) {
  #If we have a short position, close it.
  PlaceBuyStopLimit('OptimalFClosingShort',0,$stop,$limit);
}
else {
  #we have no position, or we are long.
  my $num=PositionSize();
  PlaceBuyStopLimit('OptimalFGoingLong',$num,$stop,$limit) if $num;
}

 SellMarket event logic:




if (LongPosition) {
  #If we have a long position, close it.
  PlaceSellOpen('OptimalFClosingLong');
}
else {
  #If we have no position or we are short, place the order
  my $num=PositionSize();
  PlaceSellOpen('OptimalFGoingShort',$num) if $num;
}


 SellStop event logic:




my $stop=shift;
#Stop trading if we do not have a stop price
die 'No stop price for BuyStop' unless $stop;

if (LongPosition) {
  #If we have a long position, close it.
  PlaceSellStop('OptimalFClosingLong',0,$stop);
}
else {
  #If we have no position or we are short, place the order
  my $num=PositionSize();
  PlaceSellStop('OptimalFGoingShort',$num,$stop) if $num;
}

 SellLimit event logic:




my $limit=shift;
#Stop trading if we do not have a limit price
die 'No limit price for BuyStop' unless $limit;

if (LongPosition) {
  #If we have a long position, close it.
  PlaceSellLimit('OptimalFClosingLong',0,$limit);
}
else {
  #If we have no position or we are short, place the order
  my $num=PositionSize();
  PlaceSellLimit('OptimalFGoingShort',$num,$limit) if $num;
}

 SellStopLimit event logic:




my ($stop,$limit)=@_;
#Stop trading if we do not have a stop and limit price
die 'No limit price for BuyStopLimit' unless $limit;
die 'No stop price for BuyStopLimit' unless $stop;

if (LongPosition) {
  #If we have a long position, close it.
  PlaceSellStopLimit('OptimalFClosingLong',0,$stop,$limit);
}
else {
  #If we have no position or we are short, place the order
  my $num=PositionSize();
  PlaceSellStopLimit('OptimalFGoingShort',$num,$stop,$limit) if $num;
}

I found it here:
http://www.seertrading.com/SID/512.html
Tom
"We either make ourselves miserable,

or we make ourselves strong.

The amount of work is the same."

- Carlos Castaneda

Ali Son
rank: 150+ posts
rank: 150+ posts
Posts: 179
Joined: Sun May 28, 2006 1:30 am
Reputation: 0
Location: Boston, MA
Gender: None specified

Postby Ali Son » Mon Jul 17, 2006 8:07 am

Damn, I registered but was not able to catch it. I am sorry I missed it. Was the webcast recorded and is available to be seen? Or, can somone provide a cogent, 1 page summary?

-OS

Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.


Return to “strategy trading & money management”