How to Use ParamList within Setforeign

Hello Seniors,

Is there a way to fetch more options with in setForeign() using either paramlist or paramtoggle options?

I am trying to fetch various symbols using setforeign() and would love to change different options using either Paramlist of or toggle options. I tried using the same but unable to fetch any data when used Param() within Setforeign()

Kindly suggest.

Sym= ParamList( "Select Symbol",  " infy | tcs | hcltech  ", 1) ; 

/////////////////////////////////////////////////////////////////////////

//SetForeign ( "Sym");

//setForeign(ParamList( "Select Symbol",  " infy | tcs | hcltech  ") , True, False);

SetForeign( "Infy);

Open1 = Open;
High1 = High; 
Low1 = Low;
Close1 = Close;

RestorePriceArrays();

DBM = Close1 > Ref(Close1,-1);
UBM = Close1 < Ref(Close1,-1);

Plot(BarsSince(DBM),"DBM",colorRed,styleHistogram);
Plot(BarsSince(UBM),"UBM",colorLime,styleHistogram);

Thanks in advance

This should have worked if you had used

SetForeign (Sym);

Instead of

SetForeign ("Sym");

In the line that's commented out.

Remove the spaces first.

Sym= ParamList( "Select Symbol", "infy|tcs|hcltech", 1); 

or by code

Sym= ParamList( "Select Symbol", " infy | tcs | hcltech  ", 1); 
Sym = StrTrim(Sym, " ");

And then insert Sym variable to SetForeign or (since you use Close array only) to Foreign() function (without quotes).

Close1 = Foreign(Sym, "C");
1 Like

Hi,

Checked Your suggestion but no luck . However, the other suggestion by @fxshrat works like charm.. Thanks a lot for your time in responding..

Dear @fxshrat ,

It works perfect. You always have a spot on solution for any kind of query. Can't deny the fact that you are a blessing to Ami forum.

I am a no coder in general but I have always tried and would love to improve my skills further with respect to AFL. I keep seeing new functions or lines of code every single time you respond to any of the forum member's queries.. I am so keen & eager to upgrade myself.. Any kind of suggestions for the way forward or to start with?

Thanks a ton for your time and prompt responses for all my queries ..

2 Likes

Don't forget to mark @fxshrat response as the Solution.

Hi, I have just posted an extended query based on the suggestion received. Since morning it has been waiting for approval from the moderator. I had to delete it and re-post it several times since its unpublished yet.. Any idea on what could be the reason?

My question is as follows

If i have a basket of symbols belong to one particular index, Can I auto plot the Index based indicators based on Symbol selected?

For ex, Symbols YY, ZZ are part of index A & symbols 1a, 1b are part of index B. As soon as I select any of the stocks, the Histogram for the corresponding index of those particular stock selected should be plotted. This will further reduce my dependency on manually changing the param filter.

Pls suggest.
Thanks in advance.

If the index has the same name as the Group, Market, Sector, Industry,... where the stock is part of then you can use e.g.

index_name = MarketID(1);
index_price = Foreign(index_name, "C");

Note: symbol with the name returned by MarketID(1) (of upper sample code) has to be part of DB with own price data.

Will check as you suggested. Thank you.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.