Making an Index for Canadian and American gold stocks

I'm trying to make an index of the largest Canadian and American gold mines to help me determine when to buy them. I came up with the formula below. It works but whenever there is an unshared American or Canadian holiday the index price falls in half. I'm stuck trying to figure out a way to filter out these low values for my index. Does anyone have an idea how I might do this?

//from http://www.tradewithtrend.com/amibroker-afl-weighted-custom-index/
//uses market cap for weights
//Symbols used CDE,HL,PVG,ABX,NEM,GG,AEM,KGC,RGLD,GFI,MUX,FNV.TO,BTO.TO,IMG.TO,YRI.TO,AGI.TO,DGC.TO,EDV.TO,ELD.TO,OGC.TO,NGD.TO,CG.TO,TXG.TO,NG.TO,GUY.TO,SMF.TO,SLW.TO
Buy=Sell=0;

weight =
IIf( Name() == "CDE", 1.40,
IIf( Name() == "HL", 1.94,
IIf( Name() == "PVG", 1.95,
IIf( Name() == "ABX", 24.43,
IIf( Name() == "NEM", 19.11,
IIf( Name() == "GG", 11.16,
IIf( Name() == "AEM", 13.66,
IIf( Name() == "KGC", 5.29,
IIf( Name() == "RGLD", 5.64,
IIf( Name() == "GFI", 3.55,
IIf( Name() == "MUX", 0.72,
IIf( Name() == "FNV.TO", 18.20,
IIf( Name() == "BTO.TO", 3.06,
IIf( Name() == "IMG.TO", 3.33,
IIf( Name() == "YRI.TO", 3.20,
IIf( Name() == "AGI.TO", 2.90,
IIf( Name() == "DGC.TO", 2.89,
IIf( Name() == "EDV.TO", 2.16,
IIf( Name() == "ELD.TO", 1.90,
IIf( Name() == "OGC.TO", 2.21,
IIf( Name() == "NGD.TO", 2.48,
IIf( Name() == "CG.TO", 1.98,
IIf( Name() == "TXG.TO", 1.55,
IIf( Name() == "NG.TO", 1.66,
IIf( Name() == "GUY.TO", 0.74,
IIf( Name() == "SMF.TO", 1.03,
IIf( Name() == "SLW.TO", 10.51,

0 ))))))))))))))))))))))))))); //using market cap in billions for weight
AddToComposite( weight* Close, "~GoldStockIndex", "C" );
AddToComposite( weightOpen , "~GoldStockIndex", "O" );
AddToComposite( weight * High, "~GoldStockIndex", "H" );
AddToComposite( weight
Low , "~GoldStockIndex", "L" );

Plot( C, "Price", colorRed, styleLine );

image

1 Like

@Marcel why try to re-invent the wheel?

There are two ETF’s that have almost identical constituents to what you are trying to recreate. Is your strategy so unique that it needs an index that is a small fraction of a percentage different than the existing ETF’s?

On the TSX there is XGD,

https://www.blackrock.com/ca/individual/en-ca/products/239848/ishares-sptsx-global-gold-index-etf?nc=true&siteEntryPassthrough=true

On the NYSE there is GDX,
https://www.etfchannel.com/lists/?a=stockholdings&symbol=GDX

But if you insist on using your home made solution perhaps just continue to use the previous CLOSE on the day that half of your stocks are not trading to calculate your custom Index. That is after all the most recent value of those stocks.

3 Likes