PureBytes Links
Trading Reference Links
|
I figured it out myself. Here's the AFL if anyone is interested. Note
that it manually computes the Buying Power.
function CalcEqualValuePositionSize(NumberOfPositions, BuyingPower,
MaxPosSize)
{
PosSize = BuyingPower / NumberOfPositions;
PosSize = IIf(PosSize > MaxPosSize, MaxPosSize, PosSize);
return PosSize;
}
PosQty = 5;
SetOption("MaxOpenPositions", 1000);
SetOption("AllowPositionShrinking", True);
SetOption("UsePrevBarEquityForPosSizing", True);
SetOption("InitialEquity", 150000);
SetOption("AccountMargin", 25);
Leverage = 3.95;
BuyingPower = Equity() * Leverage;
PoSize = CalcEqualValuePositionSize(PosQty, BuyingPower, 40000);
SetPositionSize(PoSize, spsValue);
--- In amibroker@xxxxxxxxxxxxxxx, "onlyobsession2k3" <jmpatton@xxx>
wrote:
>
> I'd like to code a Position Sizing function that does the following:
>
> Splits all available equity such that,
> 1) There is a minimum of M (e.g., 5) positions opened
> 2) No position is larger than D (e.g. $30,000) amount
>
> I want no maximum # of positions.
>
> Two examples:
> A) $160,000 in equity, M = 5, D = $30,000, should be split such
that
> I have,
> -5 $30,000 positions
> -1 $10,000 position
>
> B) $100,000 in equity, M = 5, D = $30,000, should be split such
that
> I have,
> -5 $20,000 positions
>
>
> Can this be done in AFL?
> Thanks.
>
Content-Description: "AVG certification"
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.18/662 - Release Date: 1/31/2007 3:16 PM
|