InWatchlistName not working when I have two WL in Analysis

I've got a market regime filter that returns 1 or 0. When 1 I want to trade one set of symbols, when 0 I want to trade a different set of symbols.

Here is a test case:

InMarketWLName="S&P 500";  // A
InCashWLName="NASDAQ 100"; // AAPL

sym=Name();
InMarket=1;
Mult=IIf(InMarket,InWatchListName(InMarketWLName),InWatchListName(InCashWLName));
printf("%f\t%s\t%f\n",InMarket,sym,Mult);

// then...
// PositionScore=10000+(ROCValue*Mult);

In the debugger I went through all 4 permutations, with the active chart either A or AAPL.

In all cases, Mult returns 1.

Is this working incorrectly, or am I doing something wrong? I assume I should be able to specify two watchlists, since the UI certainly supports this.

Remember and repeat as mantra everyday:

EVERY FUNCTION IN AMIBROKER IS WORKING FINE

It is ALWAYS user error.

Typically users ASSUME that something that is not true. For example you believe that some function returns this and it in fact returns something else.

So don't assume. DISPLAY IT! Show it on screen. Don't ever assume anything.

To get better understanding of what is happening in your code and how functions work, use advice given here: How do I debug my formula?

You need to use ADDCOLUMN (Exploration) to actually SEE all variables, otherwise you are thinking one thing but reality is something else.

// run exploration and display EVERY variable and every part of it separately
var1 = InWatchListName(InMarketWLName);
var2 = InWatchListName(InCashWLName);
var3 = IIF( InMarket, var1, var2 );
AddColumn( var1, "In 1");
AddColumn( var2 , "In 2");
AddColumn( var3, "Var3");
Filter=1;
2 Likes

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