Page 1 of 1

Sharing ADE Collections

Posted: 28 May 2010
by k-hen
Hi - I'm trying to create a shared map using ADE/ELCollections. It works fine locally within an indicator but I can't seem to retrieve any shared ones. I'm using Version 6.0 Beta 3. Any help would be greatly appreciated.

Thank you.

(p.s. big thanks to damageboy for the overview and Economic Events indicator that I've been using as a guide)

Code: Select all

// this is a test indicator to store and retrieve an ADE map
variables:
test_map(MapSC.Share("TestMap")), test_map2(MapSC.New),
test_list(ListS.New), test_list2(ListS.New)
;

if barnumber=1 then begin
print("symbol is: "+ symbol+", barinterval is: "+ NumToStr(ADE.BarInterval,2));
//add some values to the list and map
value1=ListS.Resize(test_list, 3);
value1=ListS.Insert(test_list, 1, "A");
value1=ListS.Insert(test_list, 2, "B");
value1=ListS.Insert(test_list, 3, "C");
value1=MapSC.Put(test_map, "TestList", test_list);
print("2nd val is: "+ ListS.Get(test_list, 2));
print("test map/list created");

//retrieve the values from the map (locally)
test_map2=ADE.GetRequiredMap("TestMap", symbol, ADE.BarInterval);
//test_list2=MapSC.Get(test_map2, "TestList");
//print("2nd val retrieved: "+ ListS.Get(test_list2, 2));
end;

Posted: 16 Jun 2010
by k-hen
Hi everyone,
After reading through the ELCollections documentation again I found the solution I was looking for. In order to retrieve the map you simply call the MapSC.Share() method again and if it exists will return the existing one again. Below is the updated code example. In practice the retrieval section would be in a separate indicator. Hopefully this will help someone.

Kevin

Code: Select all

// this is a test indicator to store and retrieve an ADE map
variables:
test_map(MapSC.Share("TestMap")), test_map2(MapSC.New),
test_list(ListS.New), test_list2(ListS.New)
;

if barnumber=1 then begin
print("symbol is: "+ symbol+", barinterval is: "+ NumToStr(ADE.BarInterval,2));
//add some values to the list and map
value1=ListS.Resize(test_list, 3);
value1=ListS.Insert(test_list, 1, "A");
value1=ListS.Insert(test_list, 2, "B");
value1=ListS.Insert(test_list, 3, "C");
value1=MapSC.Put(test_map, "TestList", test_list);
print("2nd val is: "+ ListS.Get(test_list, 2));
print("test map/list created");

//retrieve the values from the map (locally)
test_map2=MapSC.Share("TestMap", symbol, ADE.BarInterval);
test_list2=MapSC.Get(test_map2, "TestList");
print("2nd val retrieved: "+ ListS.Get(test_list2, 2));
end;

Posted: 16 Jun 2010
by TJ
that's useful to know.
thanks for sharing