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
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
// 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.
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.
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.
@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:
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).