public method profile:createInstance

Brief

Creates a new instance of the indicator.

Declaration
Lua
indicator_instance profile:createInstance (source, parameters)

Parameters
source

The stream of prices or the output stream of other (not this) indicator. You must pass either an instance of the bar_stream table in case the indicator requires the core.Bar source (see the profile:requiredSource() method) or an instance of the tick_stream table in the other case.

parameters

The instance of the parameters table. The table must be previously returned by the profile:parameters() method and must be filled by the proper parameter's value. Please note that each set of the parameters may be used for creating only one instance of the indicator.

Returns

The instance of the indicator_instance table.

Please, note that all output streams of the indicator instance aren't synchronized or filled until you call indicator_instance:update() method.

Details

Example: How to create an instance of the indicator [hide]

   local alligator, jaws, teeth, lips;
 
   function Prepare()
       ...
       local aprof = core.indicators:findIndicator("ALLIGATOR2");
       local aparams = aprof:parameters();
 
       aparams:setInteger("JawN", instance.parameters.JawN);
       aparams:setInteger("JawS", instance.parameters.JawS);
       aparams:setInteger("TeethN", instance.parameters.TeethN);
       aparams:setInteger("TeethS", instance.parameters.TeethS);
       aparams:setInteger("LipsN", instance.parameters.LipsN);
       aparams:setInteger("LipsS", instance.parameters.LipsS);
       aparams:setString("MTH", instance.parameters.MTH);
       alligator = aprof:createInstance(source, aparams);
       jaws = alligator:getStream(0);
       teeth = alligator:getStream(1);
       lips = alligator:getStream(2);
       ...
   end
 
   function Update(period, mode)
       ...
       alligator:update(mode);
       ...
       if period >= jaws:first() and period <= jaws:size() - 1 then
           jaws_value = jaws[period];
       end
   end

back