PureBytes Links
Trading Reference Links
|
I have made this a function but it wont provide a result. does it need to be
inside the system rather than a function?? ie, not getting enough profti
information?
{*********************************************************************
Fixed Ratio MM with decrease twice as fast. code written by Rich Estrem,
7/17/01. 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(numeric);
vars:size(1),pft(0),maxpft(0),maxsize(1),PLhi(0),PLlo(0),sz(1),half(0),decr(
0);
pft=netprofit; {only use closed profits since a large MFE could cause
errors}
{calc size if pft is increasing (normal rateof adjustment):}
if pft > maxpft then
begin
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 {calc size if in a DrawDown (2x the normal rate of adjustment)}
if maxsize > 1 then
begin
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;
Csize=sz;
end;
|