PureBytes Links
Trading Reference Links
|
At 03:45 PM 7/17/01 -0700, Mark Baze wrote:
>
>I want the rate of decrease in the number of contracts
>("K's") traded to be twice as fast as the rate of
>increase while enduring a drawdown period. Thus, and
>this was modified from a ZapFutures' presentation by
>Ryan Jones, I would like to have the following:
-snip-
Mark -
Here is EL code to do what you want. I was going to
write this some time ago, but never got around to
it until now. Hope this helps. Thanks to Mark Johnson
for his slick one-liner size formula used in my code.
rich
{*********************************************************************
Fixed Ratio MM with decrease twice as fast.
code written by Rich Estrem, 7/17/01.
notes:
this code calculates the next size to trade using the Fixed Ratio
Money Management method, using a rate of decrease which is
twice as fast as the increase rate. To use this in a system, paste
this code into your system and specify "size" as the number of
contracts to trade in your buy/sell orders.
ex: "if ... then buy size contracts at market"
*********************************************************************}
input:MMdelta(1000);
vars:size(1),pft(0),maxpft(0),maxsize(1),PLhi(0),PLlo(0),sz(1),half(0),decr(
0);
pft=netprofit; {I only use closed profits since a large MFE could cause
errors}
if pft > maxpft then begin {calc size if pft is increasing (normal rate):}
maxpft=pft;
if pft >= MMdelta then size =
intportion(0.5+SquareRoot((2*pft/MMdelta)+0.25)) else size=1;
if size > maxsize then maxsize=size;
end else if maxsize > 1 then begin {calc size if in a DD (faster rate):}
if pft < MMdelta then begin
sz=1;
end else begin
sz= intportion(0.5+SquareRoot((2*pft/MMdelta)+0.25));
if sz < maxsize then begin
decr=(maxsize-sz)*2;
PLhi=(MMdelta*(square(sz+1-0.5) - 0.25))/2 ;
PLlo=(MMdelta*(square(sz-0.5) - 0.25))/2 ;
half=(PLhi + PLlo) / 2;
if pft >= half then decr = decr - 1;
sz=maxsize-decr;
if sz < 1 then sz=1;
end;
end;
size=sz;
end;
|