static public property instance.source
Brief
The source of the indicator instance.
Declaration | ||
|
Details
The property returns the instance of either bar_stream
or
tick_stream
tables representing the source specified
for the instance of your indicator. Use isBar()
method of the table to determine what kind
of the stream is specified as a source.
The type of the source depends on the value specified in
indicator:requireSource()
method of your indicator.
Please note that there is no guarantee that the source is filled with actual prices when used in
the Prepare()
method of the indicator.
Example: Accessing source (tick indicator) [hide]
function Init() ... indicator:requiredSource(core.Tick); ... end local first; function Prepare() ... first = instance.source:first() + 7; ... end function Update(period, mode) ... if period >= first then avg = mathex.avg(instance.source, period - 7 + 1, period); end ... end
Example: Accessing source (bar indicator) [hide]
function Init() ... indicator:requiredSource(core.Bar); ... end local first; function Prepare() ... first = instance.source:first() + 7; ... end function Update(period, mode) ... if period >= first then avgHigh = mathex.avg(instance.source.high, period - 7 + 1, period); avgLow = mathex.avg(instance.source.low, period - 7 + 1, period); end ... end