Sharing ADE Collections

Studies that have been contributed to the community by other users. If you’ve got something useful to share, that’s great!
k-hen
Posts: 8
Joined: 08 Dec 2009

Sharing ADE Collections

Postby k-hen » 28 May 2010

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;

k-hen
Posts: 8
Joined: 08 Dec 2009

Postby k-hen » 16 Jun 2010

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;

User avatar
TJ
Posts: 7742
Joined: 29 Aug 2006
Location: Global Citizen
Has thanked: 1033 times
Been thanked: 2222 times

Postby TJ » 16 Jun 2010

that's useful to know.
thanks for sharing


Return to “User Contributed Studies and Indicator Library”