Create Weighted Custom Index with predefined weights

Dear Group,

I wish to create a custom index from a watchlist wherein weight for each stock in the list is predefined e.g.
The weights of each constituent in the portfolio is as below
Model Weights
How do I assign a predefined multiple to each constituent?
While equal weight index maybe checked through back test mode, I wish to back test the custom index through BUY & HOLD strategy

1 Like

I think you can try like this

// Name() is the actual symbol code

switch( Name() ) {
case "RELIANCE":
	PositionSize = -15;
	break;
case "BPCL":
	PositionSize = -5;
	break;	
case "HDFCBANK":
	PositionSize = -12;
	break;
	// All the scrips in your portfolio in their own case
	//
	// inserted above this
default: 
	PositionSize = 0;
	break;
}

The negative sign as per the manual is for % allocation.
Then you should not use SetPositionSize() or anything that changes PositionSize.

I don't know the frequency or how you have thought about rebalancing it practically when the weightage changes in the account.

1 Like

Dear nsm51,

Thanks for the take through. That certainly helped as far as creating the portfolio.
However the equity graph is not coming up in panes. Probably I am still a newbie on it.

I don't know what you mean by Equity graph ? please explain in "detail"
Also read the KB and manual.

There is an option button "Equity" next to "Report" button in the exploration rather back-test window. This draws comparative chart of the portfolio vs any chart. Refer the lower pane in attached image.
Lower Pane

1 Like

@puskan, this seems unrelated to the thread topic.

In your settings, you changed the default "Formulas" path.
This is done from the Preferences dialog / AFL tab:

image

The required _Portfolio_Equity.afl is under the Drag-drop folder in the original Formulas folder under the directory where you installed AmiBroker.
Just copy it to the corresponding folder as per your customization (see the displayed error for the destination path).

(Note that the "Drag-drop" folder by default is an hidden folder).

3 Likes

@beppe as always very helpful. Thanks

1 Like

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.