Help with AddToComposite()


#21

Larry, the above statement is not needed in case of StaticVarAdd. In one of my previous posts, I provided a link to the information about how StaticVarAdd works internally. It converts all Nulls to zero by default.

Almost all stocks have their quotes updated. The only stock which has not been updated since 8/31/2017 is “DD” - look at the Date/Time column. This is the reason why you get different result for this particular stock.


Most problems with composites comes from data holes and different ways of treating them. Data holes might be present in the quotes of the stocks which are constituences of the composite, data holes might be present in the quotes of the symbol which was used to create a composite and data holes might be present in the quotes of the symbol which is used to display/chart a composite. All that should be taken into account (if not, it will or at least might alter the results). Everyone who wants to create a proper composite, should take a closer look to the fixup parameter in case of SetForeign() and KeepAll flag in case of StaticvarAdd()

  1. SetForeign( ticker, fixup = True, tradeprices = False )

A quote from: https://www.amibroker.com/guide/afl/setforeign.html

Fixup parameter controls if data holes are filled with previous bar data or not.

0 - the holes are not fixed
1 - default value - missing data bar OHLC fields are all filled using previous bar Close and volume is set to zero.
2 - (old pre-4.90 behaviour) - causes filling the holes in the data with previous O, H, L, C, V values 
  1. StaticVarAdd( "name", value, keepAll = True, persistent = False )

A quote from: https://www.amibroker.com/guide/afl/staticvaradd.html

KeepAll flag when it is set to true emulates the behavior of AddToComposite. It keeps all values that are already present, so if data holes exists in current symbol,the bars that are present in static variable but not present in current symbol remain untouched. When KeepAll is set to false then only bars that are present in current symbol are kept. Any other bars that were present in static variable but not present in currently processed symbols are removed. That is what normally happens with StaticVarSet().

Regards