AddToComposite
- add value to composite ticker

Composites
(AmiBroker 40)


SYNTAX AddToComposite( array, ''ticker'', ''field'', flags = atcFlagDefaults )
RETURNS NOTHING
FUNCTION Allows you to create composite indicators with ease. More info...
Parameters:
array - the array of values to be added to "field" in "ticker" composite symbol
"ticker" - the ticker of composite symbol. It is advised to use ~comp (tilde at the beginning)
newly added composites are assigned to group 253 by default and
have "use only local database" feature switched on for proper operation with external sources possible field codes: "C" - close , "O" - open, "H" - high, "L" - low, "V" - volume, "I" - open interest, "1" - Aux1 field, "2" - Aux2 field, "X" - updates all OHLC fields at once

flags - contains the sum of following values
  • atcFlagDeleteValues = 1 - deletes all previous data from composite symbol at the beginning of scan (recommended)
  • atcFlagCompositeGroup = 2 - put composite ticker into group 253 and EXCLUDE all other tickers from group 253 (avoids adding composite to composite)
  • atcFlagTimeStamp = 4 - put last scan date/time stamp into FullName field
  • atcFlagEnableInBacktest = 8 - allow running AddToComposite in backtest/optimization mode
  • atcFlagEnableInExplore = 16 - allow running AddToComposite in exploration mode
  • atcFlagResetValues = 32 - reset values at the beginning of scan (not required if you use atcFlagDeleteValues)
  • atcFlagDefaults = 7
    (this is a composition of atcFlagResetValues | atcFlagCompositeGroup | atcFlagTimeStamp flags)

  • atcFlagEnableInPortfolio = 64 - allow running AddToComposite in custom portfolio backtester phase
  • atcFlagEnableInIndicator = 128 - allow running AddToComposite in indicator mode
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.
EXAMPLE AddToComposite( MACD() > 0, "~BullMACD", "V");
Graph0 = Foreign("~BullMACD", "V");
// Now you can use the same formula in scan AND indicator
SEE ALSO

References:

The AddToComposite function is used in the following formulas in AFL on-line library:

More information:

See updated/extended version on-line.