Creating custom index for stock market

sir
I am trying to create the custom stock market index using the foreign function but due to large no of the foreign function used,amibroker is getting very slow to plot the index. when I reduced the symbols to two or three it is plotting correctly. Can anybody help me with this? Is there any other way to get this

BRITANNIA=117829465*Foreign("BRITANNIA","C");
TCS=1050667718*Foreign("TCS","C");
BPCL=802623515.3*Foreign("BPCL","C");
CIPLA=507950730.6*Foreign("CIPLA","C");
BAJAJAUTO=130215159*Foreign("BAJAJ-AUTO","C");
INFY=3662832777*Foreign("INFY","C");
TotalFreeFloatMarketCap=BRITANNIA+TCS+BPCL+CIPLA+BAJAJAUTO+INFY;

BRITANNIA1=BRITANNIA/TotalFreeFloatMarketCap;
TCS1=TCS/TotalFreeFloatMarketCap;
BPCL1=BPCL/TotalFreeFloatMarketCap;
CIPLA1=CIPLA/TotalFreeFloatMarketCap;
BAJAJAUTO1=BAJAJAUTO/TotalFreeFloatMarketCap;
INFY1=INFY/TotalFreeFloatMarketCap;

Total=BRITANNIA1+TCS1+BPCL1+CIPLA1+BAJAJAUTO1+INFY1;
a=TotalFreeFloatMarketCap*1000;
Plot(a,"",colorRed,styleLine);

https://www.amibroker.com/guide/a_addtocomposite.html

AddtoComposite is designed for your application.

Thank you for your response But i specifically wanted to multiply individual multiplier to each ticker (for example (free float share) *(closing value)) . How this can be done in addtocomposite function??

Not a function I’ve used much myself. Not behind PC either but video link above probably get you going. The videos he’s done that I’ve watched are well done.

Quick google or search on this forum for “addtocomposite custom index” would return plenty of examples.

The key to addtocomposite is your using scan on a watchlist or any other filter to create the index vs your example of calling foreign() multiple times.

Thank you for your advise ,i am working on it

@prabhas,

Only users with "Verified Badge" are allowed to post on this forum.

Search "Verified Badge" for more information on how to get verified.

I have got verified with "Verified Badge".

2 Likes