Help with AddToComposites

Hi folks
I am creating trying to create custom Indexes(equal weighted) using watch lists. I am using the following code

Buy =0;
for(i = 0 ; CategoryGetName(categoryWatchlist, i) != ""; i++)
vIndexName = "~" + CategoryGetName(categoryWatchlist,i);
list = CategoryGetSymbols( categoryWatchlist, i );
vOpen = 0;
vHigh = 0;
vLow = 0;
vClose = 0;
vVolume = 0;
vAux = 0;
vCount = 0;

for( j = 0; ( vSymbol = StrExtract( list, j ) ) != ""; j++ )
  vOpen 	+= Nz(Foreign(vSymbol,"O"),0);
  vHigh 	+= Nz(Foreign(vSymbol,"H"),0);
  vLow 	+= Nz(Foreign(vSymbol,"L"),0);
  vClose 	+= Nz(Foreign(vSymbol,"C"),0);
  vVolume 	+= Nz(Foreign(vSymbol,"V"),0);
  vAux 	+= Nz(Foreign(vSymbol,"1"),0);
  vCount      += 1 ;

AddToComposite(vOpen / vCount  ,vIndexName,"O");
AddToComposite(vHigh / vCount  ,vIndexName,"H");
AddToComposite(vLow / vCount  ,vIndexName,"L");
AddToComposite(vClose / vCount  ,vIndexName,"C");
AddToComposite(vVolume  ,vIndexName,"V");


But the output for certain months/days is erratic as in Open, High, Low Close is same for certain days and Volume is not getting populated. Would be great if someone can help me resolve this


1 Like

looks like the problem is with your data or splits etc

I also think it may be an issue with the data. But need some pointers as to how to get to the bottom of this. Here's what I tried.

  1. Created a watch list with only one symbol.
  2. Checked the data for that particular symbol. Data is getting displayed properly for that symbol
  3. But when the Index is created , with just that one symbol it should simply replicate the same data.But I run into the same issues for the same set of dates. No match which symbol I use

Would be great to receive some pointers as to what may be causing this. If this is a data issue, I need to be able to prove this to my data provider also

Thanks in advance

How is your Pad and align to reference symbol set ?


Yeah, had tried that too, Enabled Pad & Allign and set the appropriate Index . Did not solve the issue.

Check TIMESTAMPS of your data. You seem to be using plugin (unauthorized, unsupported Indian one, so called "truedata"). Apparently they feed you with misaligned data (wrong timestamps).

AddToComposite "just works". Any issues are caused by users and/or data.