Variable Position Sizing

Hello All,

I was wondering if any one could help me out with dynamic position sizing - I have looked here and there but couldn't find what I was looking for. I apologize if this has already been covered and would appreciate it if you could let me know where to look.

I am trying to design an investment strategy that would also be invested in two assets QQQ/TLT (or their leveraged equivalents) with the position size being a multiple of the current draw-down from 52-week highs (or similar).

Example:

QQQ is 0.9 x 52w high -> Position: 90% QQQ / 10% TLT
QQQ is 0.8 to 0.9 x 52-w high -> Position: 80% QQQ / 20% TLT
QQQ is 0.7 to 0.8 x 52-w high -> Position: 70% QQQ / 30% TLT
etc..

Can anyone help me please?

Cheers to all.

@shavedlemon,

The question you have asked is a very advanced one. Personally, my coding skills are not yet that affluent to be able to answer precisely, however, since you asked for:

AFAIK there is a book I can refer you to - its a very tough read (at least for me) - but you will get your answers, the author has tried to keep it simple.


In the Introduction section itself, the author mentions, "on portfolio construction in terms of optimal position sizes (i.e., in the vein of an optimal f approach)".

And "optimal f" is extensively discussed in Chapter # 4 - 5.

P.S. These things helps (probably more academically) but at EOD everything boils down to the System or the Trading Logic.

@Cougar - thank you very much for answering.

My apologies I realize that that my question what not clear enough now... what I am actually looking for is the AFL code to change the % allocations...

All my other systems are ON/OFF type systems where I am either in a position or not... I have never actually played with variable position sizes with Amibroker...

This is where I got this far but I can't help by feeling there is something wrong:


market_close 	=	Foreign( "QQQ", "Close", True );
market_high 	=	HHV( market_close, 40 );
market_relative =	market_close / market_high;

market_position = IIf( market_relative >= 0.90, 100 , IIf( market_relative >= 0.85, 70, 0 ) ) ;
treasuries_position = 100 - market_position;

ScaleIn = Cross ( market_relative , 0.90 ) OR Cross ( market_relative , 0.85 )  ;
ScaleOut = Cross ( 0.90 , market_relative ) OR Cross ( 0.85 , market_relative ) ;

	RoundLotSize = 1;

	SetOption	( "InitialEquity"			,	100000	) ;
	SetOption	( "AllowPositionShrinking"	, 	1	) ; 
	SetOption	( "MinShares"				, 	1 	) ;

	SetOption	( "MaxOpenLong"			,	2	) ;
	SetOption	( "MaxOpenShort"			,	0	) ;
	SetOption	( "MaxOpenPositions"		, 	2	) ;

	SetTradeDelays 	( 1 , 1 , 1 , 1 ) ;
	
	BuyPrice= Open;
	SellPrice=Open;


if ( Name () == "QQQ" ) { 

	Buy = 1 + sigScaleIn * ScaleIn;
	Sell = 0 + sigScaleOut * ScaleOut;

	SetPositionSize( market_position, spsPercentOfEquity ) ;

}

if ( Name () == "TMF" ) { 

	Buy = 1 + sigScaleIn * ScaleOut;
	Sell = 0 + sigscaleout * ScaleIn;

	SetPositionSize( treasuries_position, spsPercentOfEquity ) ;

}