natr.src.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /**
  2. * @license Highstock JS v8.2.0 (2020-08-20)
  3. *
  4. * Indicator series type for Highstock
  5. *
  6. * (c) 2010-2019 Paweł Dalek
  7. *
  8. * License: www.highcharts.com/license
  9. */
  10. 'use strict';
  11. (function (factory) {
  12. if (typeof module === 'object' && module.exports) {
  13. factory['default'] = factory;
  14. module.exports = factory;
  15. } else if (typeof define === 'function' && define.amd) {
  16. define('highcharts/indicators/natr', ['highcharts', 'highcharts/modules/stock'], function (Highcharts) {
  17. factory(Highcharts);
  18. factory.Highcharts = Highcharts;
  19. return factory;
  20. });
  21. } else {
  22. factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
  23. }
  24. }(function (Highcharts) {
  25. var _modules = Highcharts ? Highcharts._modules : {};
  26. function _registerModule(obj, path, args, fn) {
  27. if (!obj.hasOwnProperty(path)) {
  28. obj[path] = fn.apply(null, args);
  29. }
  30. }
  31. _registerModule(_modules, 'Stock/Indicators/NATRIndicator.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  32. /* *
  33. *
  34. * License: www.highcharts.com/license
  35. *
  36. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  37. *
  38. * */
  39. var seriesType = U.seriesType;
  40. var ATR = H.seriesTypes.atr;
  41. /**
  42. * The NATR series type.
  43. *
  44. * @private
  45. * @class
  46. * @name Highcharts.seriesTypes.natr
  47. *
  48. * @augments Highcharts.Series
  49. */
  50. seriesType('natr', 'sma',
  51. /**
  52. * Normalized average true range indicator (NATR). This series requires
  53. * `linkedTo` option to be set and should be loaded after the
  54. * `stock/indicators/indicators.js` and `stock/indicators/atr.js`.
  55. *
  56. * @sample {highstock} stock/indicators/natr
  57. * NATR indicator
  58. *
  59. * @extends plotOptions.atr
  60. * @since 7.0.0
  61. * @product highstock
  62. * @requires stock/indicators/indicators
  63. * @requires stock/indicators/natr
  64. * @optionparent plotOptions.natr
  65. */
  66. {
  67. tooltip: {
  68. valueSuffix: '%'
  69. }
  70. },
  71. /**
  72. * @lends Highcharts.Series#
  73. */
  74. {
  75. requiredIndicators: ['atr'],
  76. getValues: function (series, params) {
  77. var atrData = (ATR.prototype.getValues.apply(this,
  78. arguments)),
  79. atrLength = atrData.values.length,
  80. period = params.period - 1,
  81. yVal = series.yData,
  82. i = 0;
  83. if (!atrData) {
  84. return;
  85. }
  86. for (; i < atrLength; i++) {
  87. atrData.yData[i] = (atrData.values[i][1] / yVal[period][3] * 100);
  88. atrData.values[i][1] = atrData.yData[i];
  89. period++;
  90. }
  91. return atrData;
  92. }
  93. });
  94. /**
  95. * A `NATR` series. If the [type](#series.natr.type) option is not specified, it
  96. * is inherited from [chart.type](#chart.type).
  97. *
  98. * @extends series,plotOptions.natr
  99. * @since 7.0.0
  100. * @product highstock
  101. * @excluding dataParser, dataURL
  102. * @requires stock/indicators/indicators
  103. * @requires stock/indicators/natr
  104. * @apioption series.natr
  105. */
  106. ''; // to include the above in the js output'
  107. });
  108. _registerModule(_modules, 'masters/indicators/natr.src.js', [], function () {
  109. });
  110. }));