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", "$XAO.au");
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 | $XAO.au");
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 | $XAO.au");
IndexSymbol = ParamList("Index Symbol", "$SPX|$XAO.au");

(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 | $XAO.au"), " ");
// _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|$XAO.au");
2 Likes

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|$XAO.au");
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);
Plot(Ribbon,"",RibbonColour,styleArea|styleOwnScale|styleNoLabel,-0.0001,190);
_SECTION_END();

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