PureBytes Links
Trading Reference Links
|
Hello everyone,
The following is code extracted from a posting by "Z"
on the TraderClub Forum website and it works fine.
"Num" is substituted in a strategy for the number of
contracts to be traded and the code then provides for
a fixed ratio (Ryan Jones) type of increase in the
number of contracts traded as one's account becomes
larger. This version gives the same rate of decrease
as increase when the account is shrinking in size.
For example, if the account grows from $20,000 to
$21,000 the number of contracts increases from 1 to 2;
at $23,000 from 2 to 3; at $26,000 from 3 to 4, and so
on. Likewise, if the account falls below $26,000 but
is larger than $23,000, the number of contracts will
decrease from 4 to 3; if the account drops below
$23,000 but is larger than $21,000 the number goes to
2; below $21,000 and you're back to trading 1 contract
again.
My problem is that I would like for the rate of
decrease to be faster than the rate of increase, i.e.,
have the number of contracts decrease at some higher
account value than was used to trigger the original
increase. Using the above example, maybe have the
number of contracts drop to 2 when the account goes
below $25,000 (instead of $23,000) when the account is
losing money. Delta1 is determing the increment
levels so it seems that there should be a way to
provide for two different "Delta1" values depending on
whether the account is increasing or decreasing in
size but nothing I've tried has worked correctly (for
example, have Delta1 = 1000 when the account is
growing, and have Delta1 = 1500 when the account is
shrinking).
Any suggestions?
Thanks,
Mark
{Start of code}
Inputs: Delta1(1000), AcctSize(20000);
Vars: TotAcct(0), Test(0), XXX(0), Num(1);
TotAcct=NetProfit {+ Openpositionprofit} + AcctSize;
Test=AcctSize +(1* Delta1);
xxx=1;
while TotAcct >=Test
begin
xxx=xxx+1;
Test=test + (xxx*Delta1);
end;
Num = xxx;
{End of code}
|