I would appreciate it if someone could help me with the following doubt.
I have stored fundamental data in symbols named after the ticker of the company (for example, annual ROE value for MSFT would be "MSFT_AN_ROE") in order to call that data by a Foreign function.
ROE = Foreign(Name() + "_AN_ROE", "Volume");
That symbol has one input per year, depending on the publication of the data (for this example, that would be 30/06/2008)
I would need to call that value during the whole year up to the publication of the following one. In order to make all the following bars replicate that value, I have used ValueWhen.
You're expecting Null values in ROE, but there aren't any, there are just zeroes. So try this instead:
LastROE = ValueWhen(ROE != 0, ROE);
Of course, if 0 is a valid value for ROE, then you'll need to come up with a better way to manage your data, because the line of code above will basically ignore values of 0.
I believe you could also take a simplified approach and just use:
ROE = Foreign(Name() + "_AN_ROE", "V", 2);
This will cause AmiBroker to fill in missing values with the previous value, as described in the documentation for Foreign().