Class: Iterator

STX.Market. Iterator


new Iterator()

Builds an iterator instance and returns it to the requesting market when STX.Market#newIterator is called. Do not call this constructor directly.

Since:
  • 04-2016-08
Example
var market24=new STX.Market();
var iter_parms = {
    'begin': stxx.chart.dataSet[stxx.chart.dataSet.length-1],	// last item on the dataset
    'interval': stxx.layout.interval,
    'periodicity': stxx.layout.periodicity,
    'timeUnit': stxx.layout.timeUnit,
    'inZone': stxx.dataZone,
    'outZone': stxx.dataZone
};
var iter = market24.newIterator(iter_parms);
var next = iter.next();

Methods


<static> next( [skip])

Move the iterator one interval forward

Parameters:
Name Type Argument Description
skip Integer <optional>

Default 1. Jump forward skip * periodicity at once.

Since:
  • 04-2016-08
Returns:

Next date in iterator outZone.

Type
Date
Example
now = iter.next();

<static> previous(skip)

Move the iterator one interval backward

Parameters:
Name Type Description
skip Integer

Default is one. Move this many multiples of interval.

Since:
  • 04-2016-08
Returns:

Previous date in iterator outZone.

Type
Date
Example
now = iter.previous();

date()

Returns the current date of the iterator without moving forwards or backwards. Takes into account display zone settings.

Since:
  • 04-2016-08
Returns:

The current date of the iterator.

Type
Date
Example
iteratorDate = iter.date();

futureTick()

Calculate the number of ticks from begin date to end date taking into account market open, close, and holidays. If the end date is older than the begin date,it will work backward into the past. If the end date is newer than the begin date,it will work forward into the future. Note that the begin date is set when this instance of the iterator is created and one should NOT call previous or next before calling this function, or the 'begin' pointer will change.

Parameters:
Name Type Argument Description
parms.end Date

An end date. Will be assumed to be inZone if one set.

parms.sample_size Integer <optional>

Default is 25. Maximum amount of time (in milliseconds) taken to count ticks. If sample size is reached before the number of ticks is found the number of ticks will be estimated mathematically. The bigger the sample size couple with the distance between begin date and end date affect how precise the return value is.

parms.sample_rate Integer <optional>

Default is 1000. Maximum number of ticks to evaluate before checking parms.sample_size.

Since:
  • 04-2016-08
Returns:

The number of ticks between begin and end.

Type
Integer
Example
// find out how many ticks in the past a date is from the beginning of the dataSet 
// (assumes the target date is older than the first dataSet item)
	var iter = this.standardMarketIterator(chart.dataSet[0].DT);
	var ticks=iter.futureTick({someRandomDate});

isHourAligned()

As a convenience exposed on an instance of an iterator.

Since:
  • 04-2016-08
Returns:

true if this market is hour aligned.

Type
Boolean

isOpen()

Check and see if this Market is open now.

Since:
  • 04-2016-08
Returns:

true or false

Type
Boolean