IKHIndicator.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640
  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. /* eslint-enable @typescript-eslint/interface-name-prefix */
  11. import Color from '../../Core/Color.js';
  12. var color = Color.parse;
  13. import U from '../../Core/Utilities.js';
  14. var defined = U.defined, isArray = U.isArray, merge = U.merge, objectEach = U.objectEach, seriesType = U.seriesType;
  15. var UNDEFINED, SMA = H.seriesTypes.sma;
  16. /* eslint-disable require-jsdoc */
  17. // Utils:
  18. function maxHigh(arr) {
  19. return arr.reduce(function (max, res) {
  20. return Math.max(max, res[1]);
  21. }, -Infinity);
  22. }
  23. function minLow(arr) {
  24. return arr.reduce(function (min, res) {
  25. return Math.min(min, res[2]);
  26. }, Infinity);
  27. }
  28. function highlowLevel(arr) {
  29. return {
  30. high: maxHigh(arr),
  31. low: minLow(arr)
  32. };
  33. }
  34. function getClosestPointRange(axis) {
  35. var closestDataRange, loopLength, distance, xData, i;
  36. axis.series.forEach(function (series) {
  37. if (series.xData) {
  38. xData = series.xData;
  39. loopLength = series.xIncrement ? 1 : xData.length - 1;
  40. for (i = loopLength; i > 0; i--) {
  41. distance = xData[i] - xData[i - 1];
  42. if (closestDataRange === UNDEFINED ||
  43. distance < closestDataRange) {
  44. closestDataRange = distance;
  45. }
  46. }
  47. }
  48. });
  49. return closestDataRange;
  50. }
  51. // Check two lines intersection (line a1-a2 and b1-b2)
  52. // Source: https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
  53. function checkLineIntersection(a1, a2, b1, b2) {
  54. if (a1 && a2 && b1 && b2) {
  55. var saX = a2.plotX - a1.plotX, // Auxiliary section a2-a1 X
  56. saY = a2.plotY - a1.plotY, // Auxiliary section a2-a1 Y
  57. sbX = b2.plotX - b1.plotX, // Auxiliary section b2-b1 X
  58. sbY = b2.plotY - b1.plotY, // Auxiliary section b2-b1 Y
  59. sabX = a1.plotX - b1.plotX, // Auxiliary section a1-b1 X
  60. sabY = a1.plotY - b1.plotY, // Auxiliary section a1-b1 Y
  61. // First degree Bézier parameters
  62. u, t;
  63. u = (-saY * sabX + saX * sabY) / (-sbX * saY + saX * sbY);
  64. t = (sbX * sabY - sbY * sabX) / (-sbX * saY + saX * sbY);
  65. if (u >= 0 && u <= 1 && t >= 0 && t <= 1) {
  66. return {
  67. plotX: a1.plotX + (t * saX),
  68. plotY: a1.plotY + (t * saY)
  69. };
  70. }
  71. }
  72. return false;
  73. }
  74. // Parameter opt (indicator options object) include indicator, points,
  75. // nextPoints, color, options, gappedExtend and graph properties
  76. function drawSenkouSpan(opt) {
  77. var indicator = opt.indicator;
  78. indicator.points = opt.points;
  79. indicator.nextPoints = opt.nextPoints;
  80. indicator.color = opt.color;
  81. indicator.options = merge(opt.options.senkouSpan.styles, opt.gap);
  82. indicator.graph = opt.graph;
  83. indicator.fillGraph = true;
  84. SMA.prototype.drawGraph.call(indicator);
  85. }
  86. // Data integrity in Ichimoku is different than default "averages":
  87. // Point: [undefined, value, value, ...] is correct
  88. // Point: [undefined, undefined, undefined, ...] is incorrect
  89. H.approximations['ichimoku-averages'] = function () {
  90. var ret = [], isEmptyRange;
  91. [].forEach.call(arguments, function (arr, i) {
  92. ret.push(H.approximations.average(arr));
  93. isEmptyRange = !isEmptyRange && typeof ret[i] === 'undefined';
  94. });
  95. // Return undefined when first elem. is undefined and let
  96. // sum method handle null (#7377)
  97. return isEmptyRange ? void 0 : ret;
  98. };
  99. /* eslint-enable require-jsdoc */
  100. /**
  101. * The IKH series type.
  102. *
  103. * @private
  104. * @class
  105. * @name Highcharts.seriesTypes.ikh
  106. *
  107. * @augments Highcharts.Series
  108. */
  109. seriesType('ikh', 'sma',
  110. /**
  111. * Ichimoku Kinko Hyo (IKH). This series requires `linkedTo` option to be
  112. * set.
  113. *
  114. * @sample stock/indicators/ichimoku-kinko-hyo
  115. * Ichimoku Kinko Hyo indicator
  116. *
  117. * @extends plotOptions.sma
  118. * @since 6.0.0
  119. * @excluding allAreas, colorAxis, compare, compareBase, joinBy, keys,
  120. * navigatorOptions, pointInterval, pointIntervalUnit,
  121. * pointPlacement, pointRange, pointStart, showInNavigator,
  122. * stacking
  123. * @product highstock
  124. * @requires stock/indicators/indicators
  125. * @requires stock/indicators/ichimoku-kinko-hyo
  126. * @optionparent plotOptions.ikh
  127. */
  128. {
  129. params: {
  130. period: 26,
  131. /**
  132. * The base period for Tenkan calculations.
  133. */
  134. periodTenkan: 9,
  135. /**
  136. * The base period for Senkou Span B calculations
  137. */
  138. periodSenkouSpanB: 52
  139. },
  140. marker: {
  141. enabled: false
  142. },
  143. tooltip: {
  144. pointFormat: '<span style="color:{point.color}">\u25CF</span> <b> {series.name}</b><br/>' +
  145. 'TENKAN SEN: {point.tenkanSen:.3f}<br/>' +
  146. 'KIJUN SEN: {point.kijunSen:.3f}<br/>' +
  147. 'CHIKOU SPAN: {point.chikouSpan:.3f}<br/>' +
  148. 'SENKOU SPAN A: {point.senkouSpanA:.3f}<br/>' +
  149. 'SENKOU SPAN B: {point.senkouSpanB:.3f}<br/>'
  150. },
  151. /**
  152. * The styles for Tenkan line
  153. */
  154. tenkanLine: {
  155. styles: {
  156. /**
  157. * Pixel width of the line.
  158. */
  159. lineWidth: 1,
  160. /**
  161. * Color of the line.
  162. *
  163. * @type {Highcharts.ColorString}
  164. */
  165. lineColor: void 0
  166. }
  167. },
  168. /**
  169. * The styles for Kijun line
  170. */
  171. kijunLine: {
  172. styles: {
  173. /**
  174. * Pixel width of the line.
  175. */
  176. lineWidth: 1,
  177. /**
  178. * Color of the line.
  179. *
  180. * @type {Highcharts.ColorString}
  181. */
  182. lineColor: void 0
  183. }
  184. },
  185. /**
  186. * The styles for Chikou line
  187. */
  188. chikouLine: {
  189. styles: {
  190. /**
  191. * Pixel width of the line.
  192. */
  193. lineWidth: 1,
  194. /**
  195. * Color of the line.
  196. *
  197. * @type {Highcharts.ColorString}
  198. */
  199. lineColor: void 0
  200. }
  201. },
  202. /**
  203. * The styles for Senkou Span A line
  204. */
  205. senkouSpanA: {
  206. styles: {
  207. /**
  208. * Pixel width of the line.
  209. */
  210. lineWidth: 1,
  211. /**
  212. * Color of the line.
  213. *
  214. * @type {Highcharts.ColorString}
  215. */
  216. lineColor: void 0
  217. }
  218. },
  219. /**
  220. * The styles for Senkou Span B line
  221. */
  222. senkouSpanB: {
  223. styles: {
  224. /**
  225. * Pixel width of the line.
  226. */
  227. lineWidth: 1,
  228. /**
  229. * Color of the line.
  230. *
  231. * @type {Highcharts.ColorString}
  232. */
  233. lineColor: void 0
  234. }
  235. },
  236. /**
  237. * The styles for area between Senkou Span A and B.
  238. */
  239. senkouSpan: {
  240. /**
  241. * Color of the area between Senkou Span A and B,
  242. * when Senkou Span A is above Senkou Span B. Note that if
  243. * a `style.fill` is defined, the `color` takes precedence and
  244. * the `style.fill` is ignored.
  245. *
  246. * @see [senkouSpan.styles.fill](#series.ikh.senkouSpan.styles.fill)
  247. *
  248. * @sample stock/indicators/ichimoku-kinko-hyo
  249. * Ichimoku Kinko Hyo color
  250. *
  251. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  252. * @since 7.0.0
  253. * @apioption plotOptions.ikh.senkouSpan.color
  254. */
  255. /**
  256. * Color of the area between Senkou Span A and B,
  257. * when Senkou Span A is under Senkou Span B.
  258. *
  259. * @sample stock/indicators/ikh-negative-color
  260. * Ichimoku Kinko Hyo negativeColor
  261. *
  262. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  263. * @since 7.0.0
  264. * @apioption plotOptions.ikh.senkouSpan.negativeColor
  265. */
  266. styles: {
  267. /**
  268. * Color of the area between Senkou Span A and B.
  269. *
  270. * @deprecated
  271. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  272. */
  273. fill: 'rgba(255, 0, 0, 0.5)'
  274. }
  275. },
  276. dataGrouping: {
  277. approximation: 'ichimoku-averages'
  278. }
  279. },
  280. /**
  281. * @lends Highcharts.Series#
  282. */
  283. {
  284. pointArrayMap: [
  285. 'tenkanSen',
  286. 'kijunSen',
  287. 'chikouSpan',
  288. 'senkouSpanA',
  289. 'senkouSpanB'
  290. ],
  291. pointValKey: 'tenkanSen',
  292. nameComponents: ['periodSenkouSpanB', 'period', 'periodTenkan'],
  293. init: function () {
  294. SMA.prototype.init.apply(this, arguments);
  295. // Set default color for lines:
  296. this.options = merge({
  297. tenkanLine: {
  298. styles: {
  299. lineColor: this.color
  300. }
  301. },
  302. kijunLine: {
  303. styles: {
  304. lineColor: this.color
  305. }
  306. },
  307. chikouLine: {
  308. styles: {
  309. lineColor: this.color
  310. }
  311. },
  312. senkouSpanA: {
  313. styles: {
  314. lineColor: this.color,
  315. fill: color(this.color).setOpacity(0.5).get()
  316. }
  317. },
  318. senkouSpanB: {
  319. styles: {
  320. lineColor: this.color,
  321. fill: color(this.color).setOpacity(0.5).get()
  322. }
  323. },
  324. senkouSpan: {
  325. styles: {
  326. fill: color(this.color).setOpacity(0.2).get()
  327. }
  328. }
  329. }, this.options);
  330. },
  331. toYData: function (point) {
  332. return [
  333. point.tenkanSen,
  334. point.kijunSen,
  335. point.chikouSpan,
  336. point.senkouSpanA,
  337. point.senkouSpanB
  338. ];
  339. },
  340. translate: function () {
  341. var indicator = this;
  342. SMA.prototype.translate.apply(indicator);
  343. indicator.points.forEach(function (point) {
  344. indicator.pointArrayMap.forEach(function (value) {
  345. if (defined(point[value])) {
  346. point['plot' + value] =
  347. indicator.yAxis.toPixels(point[value], true);
  348. // Add extra parameters for support tooltip in moved
  349. // lines
  350. point.plotY = point['plot' + value];
  351. point.tooltipPos = [
  352. point.plotX,
  353. point['plot' + value]
  354. ];
  355. point.isNull = false;
  356. }
  357. });
  358. });
  359. },
  360. // One does not simply
  361. // Render five linesZ
  362. // And an arearange
  363. // In just one series..
  364. drawGraph: function () {
  365. var indicator = this, mainLinePoints = (indicator.points), pointsLength = mainLinePoints.length, mainLineOptions = (indicator.options), mainLinePath = (indicator.graph), mainColor = indicator.color, gappedExtend = {
  366. options: {
  367. gapSize: mainLineOptions.gapSize
  368. }
  369. }, pointArrayMapLength = indicator.pointArrayMap.length, allIchimokuPoints = [[], [], [], [], [], []], ikhMap = {
  370. tenkanLine: allIchimokuPoints[0],
  371. kijunLine: allIchimokuPoints[1],
  372. chikouLine: allIchimokuPoints[2],
  373. senkouSpanA: allIchimokuPoints[3],
  374. senkouSpanB: allIchimokuPoints[4],
  375. senkouSpan: allIchimokuPoints[5]
  376. }, intersectIndexColl = [], senkouSpanOptions = indicator.options.senkouSpan, color = (senkouSpanOptions.color ||
  377. senkouSpanOptions.styles.fill), negativeColor = (senkouSpanOptions.negativeColor),
  378. // Points to create color and negativeColor senkouSpan
  379. points = [
  380. [],
  381. [] // Points negative color
  382. ],
  383. // For span, we need an access to the next points, used in
  384. // getGraphPath()
  385. nextPoints = [
  386. [],
  387. [] // NextPoints negative color
  388. ], lineIndex = 0, position, point, i, startIntersect, endIntersect, sectionPoints, sectionNextPoints, pointsPlotYSum, nextPointsPlotYSum, senkouSpanTempColor, concatArrIndex, j, k;
  389. indicator.ikhMap = ikhMap;
  390. // Generate points for all lines and spans lines:
  391. while (pointsLength--) {
  392. point = mainLinePoints[pointsLength];
  393. for (i = 0; i < pointArrayMapLength; i++) {
  394. position = indicator.pointArrayMap[i];
  395. if (defined(point[position])) {
  396. allIchimokuPoints[i].push({
  397. plotX: point.plotX,
  398. plotY: point['plot' + position],
  399. isNull: false
  400. });
  401. }
  402. }
  403. if (negativeColor &&
  404. pointsLength !== mainLinePoints.length - 1) {
  405. // Check if lines intersect
  406. var index = ikhMap.senkouSpanB.length - 1, intersect = checkLineIntersection(ikhMap.senkouSpanA[index - 1], ikhMap.senkouSpanA[index], ikhMap.senkouSpanB[index - 1], ikhMap.senkouSpanB[index]), intersectPointObj = {
  407. plotX: intersect.plotX,
  408. plotY: intersect.plotY,
  409. isNull: false,
  410. intersectPoint: true
  411. };
  412. if (intersect) {
  413. // Add intersect point to ichimoku points collection
  414. // Create senkouSpan sections
  415. ikhMap.senkouSpanA.splice(index, 0, intersectPointObj);
  416. ikhMap.senkouSpanB.splice(index, 0, intersectPointObj);
  417. intersectIndexColl.push(index);
  418. }
  419. }
  420. }
  421. // Modify options and generate lines:
  422. objectEach(ikhMap, function (values, lineName) {
  423. if (mainLineOptions[lineName] &&
  424. lineName !== 'senkouSpan') {
  425. // First line is rendered by default option
  426. indicator.points = allIchimokuPoints[lineIndex];
  427. indicator.options = merge(mainLineOptions[lineName].styles, gappedExtend);
  428. indicator.graph = indicator['graph' + lineName];
  429. indicator.fillGraph = false;
  430. indicator.color = mainColor;
  431. SMA.prototype.drawGraph.call(indicator);
  432. // Now save line
  433. indicator['graph' + lineName] = indicator.graph;
  434. }
  435. lineIndex++;
  436. });
  437. // Generate senkouSpan area:
  438. // If graphColection exist then remove svg
  439. // element and indicator property
  440. if (indicator.graphCollection) {
  441. indicator.graphCollection.forEach(function (graphName) {
  442. indicator[graphName].destroy();
  443. delete indicator[graphName];
  444. });
  445. }
  446. // Clean grapCollection or initialize it
  447. indicator.graphCollection = [];
  448. // When user set negativeColor property
  449. if (negativeColor &&
  450. ikhMap.senkouSpanA[0] &&
  451. ikhMap.senkouSpanB[0]) {
  452. // Add first and last point to senkouSpan area sections
  453. intersectIndexColl.unshift(0);
  454. intersectIndexColl.push(ikhMap.senkouSpanA.length - 1);
  455. // Populate points and nextPoints arrays
  456. for (j = 0; j < intersectIndexColl.length - 1; j++) {
  457. startIntersect = intersectIndexColl[j];
  458. endIntersect = intersectIndexColl[j + 1];
  459. sectionPoints = ikhMap.senkouSpanB.slice(startIntersect, endIntersect + 1);
  460. sectionNextPoints = ikhMap.senkouSpanA.slice(startIntersect, endIntersect + 1);
  461. // Add points to color or negativeColor arrays
  462. // Check the middle point (if exist)
  463. if (Math.floor(sectionPoints.length / 2) >= 1) {
  464. var x = Math.floor(sectionPoints.length / 2);
  465. // When middle points has equal values
  466. // Compare all ponints plotY value sum
  467. if (sectionPoints[x].plotY ===
  468. sectionNextPoints[x].plotY) {
  469. pointsPlotYSum = 0;
  470. nextPointsPlotYSum = 0;
  471. for (k = 0; k < sectionPoints.length; k++) {
  472. pointsPlotYSum +=
  473. sectionPoints[k].plotY;
  474. nextPointsPlotYSum +=
  475. sectionNextPoints[k].plotY;
  476. }
  477. concatArrIndex = (pointsPlotYSum > nextPointsPlotYSum ? 0 : 1);
  478. points[concatArrIndex] = (points[concatArrIndex].concat(sectionPoints));
  479. nextPoints[concatArrIndex] = (nextPoints[concatArrIndex].concat(sectionNextPoints));
  480. }
  481. else {
  482. // Compare middle point of the section
  483. concatArrIndex = (sectionPoints[x].plotY >
  484. sectionNextPoints[x].plotY ?
  485. 0 : 1);
  486. points[concatArrIndex] = (points[concatArrIndex].concat(sectionPoints));
  487. nextPoints[concatArrIndex] = (nextPoints[concatArrIndex].concat(sectionNextPoints));
  488. }
  489. }
  490. else {
  491. // Compare first point of the section
  492. concatArrIndex = (sectionPoints[0].plotY >
  493. sectionNextPoints[0].plotY ?
  494. 0 : 1);
  495. points[concatArrIndex] = (points[concatArrIndex].concat(sectionPoints));
  496. nextPoints[concatArrIndex] = (nextPoints[concatArrIndex].concat(sectionNextPoints));
  497. }
  498. }
  499. // Render color and negativeColor paths
  500. [
  501. 'graphsenkouSpanColor', 'graphsenkouSpanNegativeColor'
  502. ].forEach(function (areaName, i) {
  503. if (points[i].length && nextPoints[i].length) {
  504. senkouSpanTempColor = (i === 0) ?
  505. color : negativeColor;
  506. drawSenkouSpan({
  507. indicator: indicator,
  508. points: points[i],
  509. nextPoints: nextPoints[i],
  510. color: senkouSpanTempColor,
  511. options: mainLineOptions,
  512. gap: gappedExtend,
  513. graph: indicator[areaName]
  514. });
  515. // Now save line
  516. indicator[areaName] = indicator.graph;
  517. indicator.graphCollection.push(areaName);
  518. }
  519. });
  520. }
  521. else {
  522. // When user set only senkouSpan style.fill property
  523. drawSenkouSpan({
  524. indicator: indicator,
  525. points: ikhMap.senkouSpanB,
  526. nextPoints: ikhMap.senkouSpanA,
  527. color: color,
  528. options: mainLineOptions,
  529. gap: gappedExtend,
  530. graph: indicator.graphsenkouSpan
  531. });
  532. // Now save line
  533. indicator.graphsenkouSpan = indicator.graph;
  534. }
  535. // Clean temporary properties:
  536. delete indicator.nextPoints;
  537. delete indicator.fillGraph;
  538. // Restore options and draw the Tenkan line:
  539. indicator.points = mainLinePoints;
  540. indicator.options = mainLineOptions;
  541. indicator.graph = mainLinePath;
  542. },
  543. getGraphPath: function (points) {
  544. var indicator = this, path = [], spanA, spanAarr = [];
  545. points = points || this.points;
  546. // Render Senkou Span
  547. if (indicator.fillGraph && indicator.nextPoints) {
  548. spanA = SMA.prototype.getGraphPath.call(indicator,
  549. // Reverse points, so Senkou Span A will start from the end:
  550. indicator.nextPoints);
  551. spanA[0][0] = 'L';
  552. path = SMA.prototype.getGraphPath.call(indicator, points);
  553. spanAarr = spanA.slice(0, path.length);
  554. for (var i = spanAarr.length - 1; i >= 0; i--) {
  555. path.push(spanAarr[i]);
  556. }
  557. }
  558. else {
  559. path = SMA.prototype.getGraphPath.apply(indicator, arguments);
  560. }
  561. return path;
  562. },
  563. getValues: function (series, params) {
  564. var period = params.period, periodTenkan = params.periodTenkan, periodSenkouSpanB = params.periodSenkouSpanB, xVal = series.xData, yVal = series.yData, xAxis = series.xAxis, yValLen = (yVal && yVal.length) || 0, closestPointRange = getClosestPointRange(xAxis), IKH = [], xData = [], dateStart, date, slicedTSY, slicedKSY, slicedSSBY, pointTS, pointKS, pointSSB, i, TS, KS, CS, SSA, SSB;
  565. // Ikh requires close value
  566. if (xVal.length <= period ||
  567. !isArray(yVal[0]) ||
  568. yVal[0].length !== 4) {
  569. return;
  570. }
  571. // Add timestamps at the beginning
  572. dateStart = xVal[0] - (period * closestPointRange);
  573. for (i = 0; i < period; i++) {
  574. xData.push(dateStart + i * closestPointRange);
  575. }
  576. for (i = 0; i < yValLen; i++) {
  577. // Tenkan Sen
  578. if (i >= periodTenkan) {
  579. slicedTSY = yVal.slice(i - periodTenkan, i);
  580. pointTS = highlowLevel(slicedTSY);
  581. TS = (pointTS.high + pointTS.low) / 2;
  582. }
  583. if (i >= period) {
  584. slicedKSY = yVal.slice(i - period, i);
  585. pointKS = highlowLevel(slicedKSY);
  586. KS = (pointKS.high + pointKS.low) / 2;
  587. SSA = (TS + KS) / 2;
  588. }
  589. if (i >= periodSenkouSpanB) {
  590. slicedSSBY = yVal.slice(i - periodSenkouSpanB, i);
  591. pointSSB = highlowLevel(slicedSSBY);
  592. SSB = (pointSSB.high + pointSSB.low) / 2;
  593. }
  594. CS = yVal[i][3];
  595. date = xVal[i];
  596. if (IKH[i] === UNDEFINED) {
  597. IKH[i] = [];
  598. }
  599. if (IKH[i + period] === UNDEFINED) {
  600. IKH[i + period] = [];
  601. }
  602. IKH[i + period][0] = TS;
  603. IKH[i + period][1] = KS;
  604. IKH[i + period][2] = UNDEFINED;
  605. IKH[i][2] = CS;
  606. if (i <= period) {
  607. IKH[i + period][3] = UNDEFINED;
  608. IKH[i + period][4] = UNDEFINED;
  609. }
  610. if (IKH[i + 2 * period] === UNDEFINED) {
  611. IKH[i + 2 * period] = [];
  612. }
  613. IKH[i + 2 * period][3] = SSA;
  614. IKH[i + 2 * period][4] = SSB;
  615. xData.push(date);
  616. }
  617. // Add timestamps for further points
  618. for (i = 1; i <= period; i++) {
  619. xData.push(date + i * closestPointRange);
  620. }
  621. return {
  622. values: IKH,
  623. xData: xData,
  624. yData: IKH
  625. };
  626. }
  627. });
  628. /**
  629. * A `IKH` series. If the [type](#series.ikh.type) option is not
  630. * specified, it is inherited from [chart.type](#chart.type).
  631. *
  632. * @extends series,plotOptions.ikh
  633. * @since 6.0.0
  634. * @product highstock
  635. * @excluding dataParser, dataURL
  636. * @requires stock/indicators/indicators
  637. * @requires stock/indicators/ichimoku-kinko-hyo
  638. * @apioption series.ikh
  639. */
  640. ''; // add doclet above to transpiled file