ichimoku-kinko-hyo.src.js 33 KB

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