SetForeign Showing Different Result for Different Tickers


I have an unexplained issue when I use SetForeign. I am also using Norgate Data Updater Beta Plug Ins.

I have the following formula to plot a ribbon at the bottom of the screen. Basically, green if index $XAO is uptrend, red if downtrend:

Index_Uptrend = C > MA(C,60); 

Plot(1,"",IIf(Index_Uptrend,colorGreen,colorRed),styleOwnScale | styleArea, -0.5,100);

When I test it against the original index $XAO, it is showing the correct color. 1Aug-4Aug: Green,Green,Green,Red

When I test it against a stock code CBA, it is showing the correct color. 1Aug-4Aug: Green, Green, Green, Red

When I test it against a stock code ELD, it is showing the correct color. 1Aug-4Aug: Green, Green, Green, Red

However, when I test it against a stock code GEM, it is showing a different color even though the date is the same? 1Aug-4Aug: Green, RED, RED, Red

Shouldn’t it be the same as I am referencing the same foreign ticker at the same time frame?

Thank you for the help.

I have uploaded the video showing the issue.

No, you don’t understand how SetForeign() works and/or you did not read relevant documentation to Foreign()/SetForeign().

Somehow reading the docs is completely lost art. How much time could be saved if people actually read the documentation?

SetForeign() and Foreign() synchronize data to currently selected symbol as described in the manual

Verbatim copy from manual:

Foreign function synchronizes the data file you are referencing with the currently selected symbol.

Synchronization makes sure that EACH bar of FOREIGN data matches exactly with each bar of currently selected symbol.

So if DateNum() function returns 990503 for given bar then Close array represents the CLOSE of currently selected symbol at May 3, 1999 and Foreign(“SYMBOL”, “C”) represents close of foreign symbol at May 3, 1999 TOO.

This is absolutely necessary because otherwise you won’t be able to do ANY meaningful operations involving both selected symbol and foreign symbol.

This also needed for the display so when you mark the quote with vertical line it will always match the date displayed regardless if you use Foreign or not.

Please note that if you have data holes in currently selected symbol then in order to synchronize bars Foreign function will remove bars that exist in Foreign symbol but do not exist in currently selected symbol.

Sorry Tomasz, I did read the docs and I thought I understood it.

Anyway I’ve found the source of the problem. It was because I was using an MA60 and there were holes in the data in the past which I did not notice.

Thanks again!!