Class Indicator<T>
java.lang.Object
trade.invision.indicators.indicators.Indicator<T>
- Type Parameters:
T- the immutable type
- Direct Known Subclasses:
AbstractDrawupDrawdown,AccelerationDeceleration,AverageTrueRange,BarDuration,BinaryOperation,BollingerBands,CachelessIndicator,CachingIndicator,ChaikinMoneyFlow,ChaikinOscillator,ChandeMomentumOscillator,CloseLocationValue,CommodityChannelIndex,ComplexConvergenceDivergence,ContainsInstant,CorrelationCoefficient,Covariance,Crossed,CrossedUp,CumulativeProduct,CumulativeSum,DateTimeField,DirectionalMoneyFlow,DoubleExponentialMovingAverage,DurationBetween,EpochOffset,GrowthRate,Hl2,Hlc3,HullMovingAverage,IntradayIntensityIndex,LeastSquaresMovingAverage,LinearlyWeightedMovingAverage,LinearRegression,LocalBearishPercentage,LocalBullishPercentage,LocalFallingPercentage,LocalMaximum,LocalMinimum,LocalRisingPercentage,MeanDeviation,MoneyFlow,MoneyFlowIndex,MovingAverageConvergenceDivergence,MovingAverageDistanceDifference,MovingAverageDistancePercentage,MovingVolumeWeightedAveragePrice,OffsetBy,Ohlc4,Overlaps,PercentagePriceOscillator,PredictiveLeastSquaresMovingAverage,PreviousDifference,PreviousRatio,RealBody,RelativeStrengthIndex,RelativeVolume,RelativeVolumeStandardDeviation,RootMeanSquare,SimpleConvergenceDivergence,SimpleMovingAverage,StandardDeviation,StandardError,StandardScore,StochasticRelativeStrengthIndex,TernaryOperation,TimeSegmentedVolume,TradeAmount,TradeSize,TripleExponentialMovingAverage,TrueRange,TruncateTo,UlcerIndex,UnaryOperation,Variance,VolumeWeightedAveragePrice,WeightedMovingAverage,WilliamsPercentRange,WithDateTimeField
Indicator is an abstract class for performing calculations on a Series or another Indicator,
with optional result caching (disabled by default). An Indicator will implement some formula/algorithm and
provide the result of the calculation at a given index. Calculated values should be of an immutable
type. This class is not thread-safe.- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncaching()Permanently enables caching of thisIndicator's calculated values in order to optimizegetValue(long)for non-ending indices.protected abstract Tcalculate(long index) Performs the calculation of thisIndicatorat the givenindex.intThe minimumindex(inclusive) that thisIndicatorwill start to perform calculations correctly at.Series<?> getValue(long index) Computes the value of thisIndicatorat the givenindex.booleanprotected Numprotected Numprotected NumnumOf(BigDecimal bigDecimal) protected Numprotected Numprotected Numprotected Numprotected Numprotected Numprotected Numprotected Numprotected Numprotected NumnumOfOne()protected Numprotected NumnumOfSix()protected NumnumOfTen()protected Numprotected Numprotected Numprotected Numprotected NumnumOfTwo()protected Numprotected void
-
Field Details
-
series
-
minimumStableIndex
protected final int minimumStableIndexThe minimumindex(inclusive) that thisIndicatorwill start to perform calculations correctly at. -
cacheSeries
-
cachedIndex
protected long cachedIndex -
cachedValue
-
cachedAddCallCount
protected long cachedAddCallCount
-
-
Constructor Details
-
Indicator
Instantiates a newIndicator.- Parameters:
series- thegetSeries()minimumStableIndex- thegetMinimumStableIndex()
-
-
Method Details
-
calculate
Performs the calculation of thisIndicatorat the givenindex.- Parameters:
index- the index- Returns:
- the result (never
null)
-
getValue
Computes the value of thisIndicatorat the givenindex. Regardless ofisCaching(), ifgetSeries()has not been modified since the previous method call was invoked with the sameindexas the current method call, then thisIndicatordoes not recalculate the value forindexand a cached value is returned. IfisCaching()istrue, then the cached value forindexis returned if it has been previously calculated, except ifindexis equal togetSeries()Series.getEndIndex()andgetSeries()has changed, then the value is recalculated and the cache is updated. Ifindexis greater thangetSeries()Series.getEndIndex(), then the calculation is attempted, but may throw anIndexOutOfBoundsException. Ifindexis less thangetSeries()Series.getStartIndex(), then0is used to avoid calculating on a value that has already been removed fromgetSeries()and to use thisIndicator's default first value so that aStackOverflowErroris avoided in recursive calculations.- Parameters:
index- the index- Returns:
- the result (never
null) - See Also:
-
caching
Permanently enables caching of thisIndicator's calculated values in order to optimizegetValue(long)for non-ending indices. The cache should be enabled when consumers of thisIndicatoruse the calculated values of non-ending indices, as opposed to only using the calculated value of the end index (e.g.Series.getEndIndex()). The cache size is equal togetSeries()Series.getMaximumLength().- Returns:
- this
Indicator, for method chaining - See Also:
-
purgeCache
protected void purgeCache()- See Also:
-
isCaching
public boolean isCaching()- Returns:
trueif thisIndicatorhas caching enabled,falseotherwise- See Also:
-
numOf
-
numOf
-
numOf
-
numOf
-
numOfNegativeOne
-
numOfZero
-
numOfOne
-
numOfTwo
-
numOfThree
-
numOfFour
-
numOfFive
-
numOfSix
-
numOfSeven
-
numOfEight
-
numOfNine
-
numOfTen
-
numOfHundred
-
numOfThousand
-
numOfTenth
-
numOfHundredth
-
numOfThousandth
-
numOfHalf
-
getSeries
-
getMinimumStableIndex
public int getMinimumStableIndex()The minimumindex(inclusive) that thisIndicatorwill start to perform calculations correctly at.
-