ParamList query

When using either of the following code in a formula for a index ribbon it works ok:
IndexToggle = ParamToggle("Index Toggle","On|Off",0);
IndexSymbol = ParamStr("Index Symbol", "$SPX");
IndexSymbol = ParamStr("Index Symbol", "$");
So I have been trying to change it to a drop down list per the following, however the ribbon changes to gray, i.e. is not recognizing this code?
IndexSymbol = ParamList("Index Symbol", "$SPX | $");
Have tried a number of variations and explored the forum but are struggling to find the correction.
Any assistance appreciated.

You need to post the afl code for help. Without that it is only guessing game..

1 Like

@DazN, did you try to remove the extra spaces in this line:

// IndexSymbol = ParamList("Index Symbol", "$SPX | $");
IndexSymbol = ParamList("Index Symbol", "$SPX|$");

(Alternatively, if you, for legibility prefer to have the extra spaces in your ParamList values string, you can remove them using the StrTrim() function.

IndexSymbol = StrTrim(ParamList("Index Symbol", "| $SPX | $"), " ");
// _TRACE("Index symbol [" + IndexSymbol + "]");

By the way, if you modify it as follow you can remove also the first line (in your formula you could adapt the logic to consider the index off if the IndexSymbol<(code> is an empty string)

IndexSymbol = ParamList("Index Symbol", "|$SPX|$");

Beppe, legend, it's always the obvious in hindsight, thanks and very much appreciated.
Yogyatrader, full code that now works:

_SECTION_BEGIN("Index Filter");
IndexToggle = ParamToggle("Index Toggle","On|Off",0);
IndexSymbol = ParamList("Index Symbol", "$SPX|$");
IndexS = Foreign(IndexSymbol,"C");
MAPeriod = Param("Index MA Period",10,1,1000,1);
IndexUp = IndexS > MA(IndexS,MAPeriod);
IndexDn = IndexS < MA(IndexS,MAPeriod);
Index = IIf(IndexToggle,1,IndexUp);
RibbonColour = IIf(IndexUp,colorGreen,colorRed);
Ribbon = IIf(IndexToggle,Null,1);

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