I have discovered what causes an error - selecting the ~composite you are creating as the current symbol. Unfortunately, when you are developing and testing a new formula the last symbol you usually look at is the new ~composite, so it remains selected.
It is actually possible to use any other symbol (except the ~composite being created), but unfortunately the newly created ~composite mirrors the dates of the bars in the selected current symbol, so if it has missing bars, is not up to date, or is a recent issue then the ~composite will be missing similar bars. This is why, as Thomasz says, one of the source symbols should be selected.
Another problem that sometimes occurs after running the scan is when I look at the chart of the newly-created ~composite, it is blank and the x axis shows no dates. Tapping the End key fixes it and everything displays correctly.
Here is my code to create a new composite silver/gold ratio from the silver and gold symbols XAGFIX and XAUFIX:
SilverO = Foreign( "XAGFIX", "O" );
SilverH = Foreign( "XAGFIX", "H" );
SilverL = Foreign( "XAGFIX", "L" );
SilverC = Foreign( "XAGFIX", "C" );
SilverV = Foreign( "XAGFIX", "V" );
GoldO = Foreign( "XAUFIX", "O" );
GoldH = Foreign( "XAUFIX", "H" );
GoldL = Foreign( "XAUFIX", "L" );
GoldC = Foreign( "XAUFIX", "C" );
GoldV = Foreign( "XAUFIX", "V" );
ADDTOCOMPOSITE(SilverO/GoldO, "~AG_AU", "O");
ADDTOCOMPOSITE(SilverH/GoldH, "~AG_AU", "H");
ADDTOCOMPOSITE(SilverL/GoldL, "~AG_AU", "L");
ADDTOCOMPOSITE(SilverC/GoldC, "~AG_AU", "C");
ADDTOCOMPOSITE(SilverV/GoldV, "~AG_AU", "V");