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( weightLow , "~GoldStockIndex", "L" );
Plot( C, "Price", colorRed, styleLine );