Regarding the execution context, please note this statement from the Help file entry for AddToComposite():
AddToComposite function also detects the context in which it is run
(it works ONLY in scan mode, unless atcFlagEnableInBacktest or atcFlagEnableInExplore flags are specified) and does NOT affect composite ticker when run in Indicator or Commentary mode, so it is now allowed to join scan and indicator into single formula.
Incorrect composite name: composite name SHOULD begin with tilde (it is required so it is added at the END of symbol list)
Foreign used right after composite in the very same formula that attempts to create it- wrong. Foreign/Plot should be in CHART formula.
You can't read composite right after AddToComposite because it is created/updated asynchronously. Foreign calls done during scan that creates composites would result in "partially updated" data. If you want synchronous stuff you need to use StaticVarAdd.
No, you didn't. You wrote "sumgreen" . There is no tilde. You should have written "~sumgreen"
Read (or re-read) the manual http://www.amibroker.com/guide/a_addtocomposite.html
Composites require two separate steps: a) creating composite b) reading composite. First step is usually done in Analysis/Scan, second can be done in any place but typically you display composite charts. Therefore the best is to have two formulas each doing its thing.
That is not the point. Filter is a command for exploration, not scan. Having Filter = 0; does not have any sense because it works only for Exploration, it has no effect on Scan and Filter=0 in Exploration it says "don't display ANY results" http://www.amibroker.com/guide/h_exploration.html If you want to display exploration and "not filter anything" as you wrote, you should have written Filter=1; because that means don't filter (i.e. display ALL results).