Tomasz,
Thank you for your answer.
I would need to use the formula in a monthly basis provided that the system works in that time frame.
"CLI.EU" has only one daily close for the whole month.

It represents the Composite Leading Indicator for Euro Zone by OCDE. I use those indicators as filters for certain monthly systems, like in the following example:
LongCLI = Ref(Foreign("CLI.EU", "Close"), -1) >= Ref(Foreign("CLI.EU", "Close"), -2);
ShortCLI = Ref(Foreign("CLI.EU", "Close"), -1) < Ref(Foreign("CLI.EU", "Close"), -2);
Buy = LongCondition1 AND LongCondition2 AND LongCLI;
Short = ShortCondition1 AND ShortCondition2 AND ShortCLI;
I will represent the filter by the following formula:
LongCLI = Ref(Foreign("CLI.EU", "Close"), -1) >= Ref(Foreign("CLI.EU", "Close"), -2);
ShortCLI = Ref(Foreign("CLI.EU", "Close"), -1) < Ref(Foreign("CLI.EU", "Close"), -2);
B = IIf(LongCLI, 1, IIf(ShortCLI, -1, 0));
Plot(B, "B", colorRed, styleLine, Null, Null, 0, 0, 2);
Plot(0, "0", colorBlue, styleLine, Null, Null, 0, 0, 1);
This is the result:
I

As you can check, "CLI.EU" ticker is falling down by the last close available (30/04), and consequently the filter shows B = -1. However, if I applyied that formula to "$SXXP-STX" (whose last close availible is 20/07), the filter turns up and shows B = 1 for those month without data for . "CLI.EU". I intend that the filter shows B = 0 in that case.
If I switch to daily chart and I use the formula from the original example, it works as shown in the following image:
B = IsNull(Foreign("CLI.EU", "C", 0));
Plot(B, "B", colorRed, styleLine, Null, Null, 0, 0, 2);

B = 0 for the first day of every month, if it is a working day, since "CLI.EU" has data just for the first day of every month. It works fine in a daily chart, but I would need to use it in a monthly basis.
Thank you in advance for your help.
Regards.