TRIXIndicator.js 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /* *
  2. *
  3. * License: www.highcharts.com/license
  4. *
  5. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  6. *
  7. * */
  8. 'use strict';
  9. import H from '../../Core/Globals.js';
  10. import U from '../../Core/Utilities.js';
  11. var correctFloat = U.correctFloat, seriesType = U.seriesType;
  12. import requiredIndicator from '../../Mixins/IndicatorRequired.js';
  13. var TEMA = H.seriesTypes.tema;
  14. /**
  15. * The TRIX series type.
  16. *
  17. * @private
  18. * @class
  19. * @name Highcharts.seriesTypes.trix
  20. *
  21. * @augments Highcharts.Series
  22. */
  23. seriesType('trix', 'tema',
  24. /**
  25. * Triple exponential average (TRIX) oscillator. This series requires
  26. * `linkedTo` option to be set.
  27. *
  28. * Requires https://code.highcharts.com/stock/indicators/ema.js
  29. * and https://code.highcharts.com/stock/indicators/tema.js.
  30. *
  31. * @sample {highstock} stock/indicators/trix
  32. * TRIX indicator
  33. *
  34. * @extends plotOptions.tema
  35. * @since 7.0.0
  36. * @product highstock
  37. * @excluding allAreas, colorAxis, compare, compareBase, joinBy, keys,
  38. * navigatorOptions, pointInterval, pointIntervalUnit,
  39. * pointPlacement, pointRange, pointStart, showInNavigator,
  40. * stacking
  41. * @optionparent plotOptions.trix
  42. */
  43. {},
  44. /**
  45. * @lends Highcharts.Series#
  46. */
  47. {
  48. init: function () {
  49. var args = arguments, ctx = this;
  50. requiredIndicator.isParentLoaded(TEMA, 'tema', ctx.type, function (indicator) {
  51. indicator.prototype.init.apply(ctx, args);
  52. return;
  53. });
  54. },
  55. // TRIX is calculated using TEMA so we just extend getTemaPoint method.
  56. getTemaPoint: function (xVal, tripledPeriod, EMAlevels, i) {
  57. if (i > tripledPeriod) {
  58. var TRIXPoint = [
  59. xVal[i - 3],
  60. EMAlevels.prevLevel3 !== 0 ?
  61. correctFloat(EMAlevels.level3 - EMAlevels.prevLevel3) /
  62. EMAlevels.prevLevel3 * 100 : null
  63. ];
  64. }
  65. return TRIXPoint;
  66. }
  67. });
  68. /**
  69. * A `TRIX` series. If the [type](#series.tema.type) option is not specified, it
  70. * is inherited from [chart.type](#chart.type).
  71. *
  72. * @extends series,plotOptions.tema
  73. * @since 7.0.0
  74. * @product highstock
  75. * @excluding allAreas, colorAxis, compare, compareBase, dataParser, dataURL,
  76. * joinBy, keys, navigatorOptions, pointInterval, pointIntervalUnit,
  77. * pointPlacement, pointRange, pointStart, showInNavigator, stacking
  78. * @apioption series.trix
  79. */
  80. ''; // to include the above in the js output