Using IF in FILTER

Hello, is it possible to use an if statement inside the Filter code?

eg, using plain english:

Filter = Cond1 AND Cond2 AND if(marketCap<3000 is true, then Cond4)

I have not been able to achieve this in my trials with if and iif.

In another platform I have two Screens, the results of which I then combine in a spreadhseet. With Amibroker, I am hoping to combine these two processes into one Exploration.

Ignoring if statements, is there any other way to use Filter such that I can achieve this?

Thank you. I hope I am not asking too much. I'm trying to plan the replacement of my existing methods with Amibroker.

No, using if in Filter is not correct
See difference about if-else statements and IIf function

// use IIf not if
Cond4_IIf = IIf(marketCap<3000, Cond4, 0);
Filter = Cond1 AND Cond2 AND Cond4_IIf;

Alternative way without IIf:

Cond4_IIf = (marketCap<3000) * Cond4;
Filter = Cond1 AND Cond2 AND Cond4_IIf;

or just using AND operator (since Cond4 and marketCap<3000 return true or false)

Cond4_IIf = (marketCap<3000) AND Cond4;
Filter = Cond1 AND Cond2 AND Cond4_IIf;

Because of the way how Boolean logic works, your Filter is simply:

Filter = Cond1 AND Cond2 AND marketCap<3000 AND Cond4;

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