ichimoku-kinko-hyo.src.js 33 KB

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