UNPKG

highcharts

Version:
14 lines 8.59 kB
!/** * Highstock JS v12.6.0 (2026-04-13) * @module highcharts/indicators/ichimoku-kinko-hyo * @requires highcharts * @requires highcharts/modules/stock * * Indicator series type for Highcharts Stock * * (c) 2010-2026 Highsoft AS * Author: Sebastian Bochan * * A commercial license may be required depending on use. * See www.highcharts.com/license */function(o,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(o._Highcharts,o._Highcharts.dataGrouping.approximations,o._Highcharts.Color,o._Highcharts.SeriesRegistry):"function"==typeof define&&define.amd?define("highcharts/indicators/ichimoku-kinko-hyo",["highcharts/highcharts"],function(o){return t(o,o.dataGrouping,["approximations"],o.Color,o.SeriesRegistry)}):"object"==typeof exports?exports["highcharts/indicators/ichimoku-kinko-hyo"]=t(o._Highcharts,o._Highcharts.dataGrouping.approximations,o._Highcharts.Color,o._Highcharts.SeriesRegistry):o.Highcharts=t(o.Highcharts,o.Highcharts.dataGrouping.approximations,o.Highcharts.Color,o.Highcharts.SeriesRegistry)}("u"<typeof window?this:window,(o,t,e,n)=>(()=>{"use strict";var i={512:o=>{o.exports=n},620:o=>{o.exports=e},944:t=>{t.exports=o},956:o=>{o.exports=t}},r={};function p(o){var t=r[o];if(void 0!==t)return t.exports;var e=r[o]={exports:{}};return i[o](e,e.exports,p),e.exports}p.n=o=>{var t=o&&o.__esModule?()=>o.default:()=>o;return p.d(t,{a:t}),t},p.d=(o,t)=>{for(var e in t)p.o(t,e)&&!p.o(o,e)&&Object.defineProperty(o,e,{enumerable:!0,get:t[e]})},p.o=(o,t)=>Object.prototype.hasOwnProperty.call(o,t);var s={};p.d(s,{default:()=>B});var a=p(944),l=p.n(a),h=p(956),u=p.n(h),c=p(620),g=p.n(c),f=p(512),d=p.n(f);let{doc:y,win:k}=l();function S(o){return x(o)&&"number"==typeof o.nodeType}function m(o){let t=Object.prototype.toString.call(o);return"[object Array]"===t||"[object Array Iterator]"===t}function x(o,t){return!!o&&"object"==typeof o&&(!t||!m(o))}function v(o,...t){let e,n=[o,...t],i={},r=function(o,t){return"object"!=typeof o&&(o={}),A(t,function(e,n){if("__proto__"!==n&&"constructor"!==n){let i;!x(e,!0)||(i=e?.constructor,x(e,!0)&&!S(e)&&i?.name&&"Object"!==i.name)||S(e)?o[n]=t[n]:o[n]=r(o[n]||{},e)}}),o};!0===o&&(i=n[1],n=Array.prototype.slice.call(n,2));let p=n.length;for(e=0;e<p;e++)i=r(i,n[e]);return i}function A(o,t,e){for(let n in o)Object.hasOwnProperty.call(o,n)&&t.call(e||o[n],o[n],n,o)}Array.prototype.find;let{parse:b}=g(),{sma:C}=d().seriesTypes;function Y(o){return{high:o.reduce(function(o,t){return Math.max(o,t[1])},-1/0),low:o.reduce(function(o,t){return Math.min(o,t[2])},1/0)}}function P(o){let t=o.indicator;t.points=o.points,t.nextPoints=o.nextPoints,t.color=o.color,t.options=v(o.options.senkouSpan.styles,o.gap),t.graph=o.graph,t.fillGraph=!0,d().seriesTypes.sma.prototype.drawGraph.call(t)}class j extends C{constructor(){super(...arguments),this.data=[],this.options={},this.points=[],this.graphCollection=[]}init(){super.init.apply(this,arguments),this.options=v({tenkanLine:{styles:{lineColor:this.color}},kijunLine:{styles:{lineColor:this.color}},chikouLine:{styles:{lineColor:this.color}},senkouSpanA:{styles:{lineColor:this.color,fill:b(this.color).setOpacity(.5).get()}},senkouSpanB:{styles:{lineColor:this.color,fill:b(this.color).setOpacity(.5).get()}},senkouSpan:{styles:{fill:b(this.color).setOpacity(.2).get()}}},this.options)}toYData(o){return[o.tenkanSen,o.kijunSen,o.chikouSpan,o.senkouSpanA,o.senkouSpanB]}translate(){for(let o of(d().seriesTypes.sma.prototype.translate.apply(this),this.points))for(let t of this.pointArrayMap){let e=o[t];"number"==typeof e&&!isNaN(e)&&e<1/0&&e>-1/0&&(o["plot"+t]=this.yAxis.toPixels(e,!0),o.plotY=o["plot"+t],o.tooltipPos=[o.plotX,o["plot"+t]],o.isNull=!1)}}drawGraph(){let o=this,t=o.points,e=o.options,n=o.graph,i=o.color,r={options:{gapSize:e.gapSize}},p=o.pointArrayMap.length,s=[[],[],[],[],[],[]],a={tenkanLine:s[0],kijunLine:s[1],chikouLine:s[2],senkouSpanA:s[3],senkouSpanB:s[4],senkouSpan:s[5]},l=[],h=o.options.senkouSpan,u=h.color||h.styles.fill,c=h.negativeColor,g=[[],[]],f=[[],[]],y=t.length,k=0,S,m,x,b,C,Y,j,B,G,N,O,H,_;for(o.ikhMap=a;y--;){for(x=0,m=t[y];x<p;x++)null!=m[S=o.pointArrayMap[x]]&&s[x].push({plotX:m.plotX,plotY:m["plot"+S],isNull:!1});if(c&&y!==t.length-1){let o=a.senkouSpanB.length-1,t=function(o,t,e,n){if(o&&t&&e&&n){let i=t.plotX-o.plotX,r=t.plotY-o.plotY,p=n.plotX-e.plotX,s=n.plotY-e.plotY,a=o.plotX-e.plotX,l=o.plotY-e.plotY,h=(-r*a+i*l)/(-p*r+i*s),u=(p*l-s*a)/(-p*r+i*s);if(h>=0&&h<=1&&u>=0&&u<=1)return{plotX:o.plotX+u*i,plotY:o.plotY+u*r}}}(a.senkouSpanA[o-1],a.senkouSpanA[o],a.senkouSpanB[o-1],a.senkouSpanB[o]);if(t){let e={plotX:t.plotX,plotY:t.plotY,isNull:!1,intersectPoint:!0};a.senkouSpanA.splice(o,0,e),a.senkouSpanB.splice(o,0,e),l.push(o)}}}if(A(a,(t,n)=>{e[n]&&"senkouSpan"!==n&&(o.points=s[k],o.options=v(e[n].styles,r),o.graph=o["graph"+n],o.fillGraph=!1,o.color=i,d().seriesTypes.sma.prototype.drawGraph.call(o),o["graph"+n]=o.graph),k++}),o.graphCollection)for(let t of o.graphCollection)o[t].destroy(),delete o[t];if(o.graphCollection=[],c&&a.senkouSpanA[0]&&a.senkouSpanB[0]){for(l.unshift(0),l.push(a.senkouSpanA.length-1),H=0;H<l.length-1;H++)if(b=l[H],C=l[H+1],Y=a.senkouSpanB.slice(b,C+1),j=a.senkouSpanA.slice(b,C+1),Math.floor(Y.length/2)>=1){let o=Math.floor(Y.length/2);if(Y[o].plotY===j[o].plotY){for(_=0,B=0,G=0;_<Y.length;_++)B+=Y[_].plotY,G+=j[_].plotY;g[O=B>G?0:1]=g[O].concat(Y),f[O]=f[O].concat(j)}else g[O=Y[o].plotY>j[o].plotY?0:1]=g[O].concat(Y),f[O]=f[O].concat(j)}else g[O=Y[0].plotY>j[0].plotY?0:1]=g[O].concat(Y),f[O]=f[O].concat(j);["graphsenkouSpanColor","graphsenkouSpanNegativeColor"].forEach(function(t,n){g[n].length&&f[n].length&&(N=0===n?u:c,P({indicator:o,points:g[n],nextPoints:f[n],color:N,options:e,gap:r,graph:o[t]}),o[t]=o.graph,o.graphCollection.push(t))})}else P({indicator:o,points:a.senkouSpanB,nextPoints:a.senkouSpanA,color:u,options:e,gap:r,graph:o.graphsenkouSpan}),o.graphsenkouSpan=o.graph;delete o.nextPoints,delete o.fillGraph,o.points=t,o.options=e,o.graph=n,o.color=i}getGraphPath(o){let t=[],e,n=[];if(o=o||this.points,this.fillGraph&&this.nextPoints){if((e=d().seriesTypes.sma.prototype.getGraphPath.call(this,this.nextPoints))&&e.length){e[0][0]="L",t=d().seriesTypes.sma.prototype.getGraphPath.call(this,o),n=e.slice(0,t.length);for(let o=n.length-1;o>=0;o--)t.push(n[o])}}else t=d().seriesTypes.sma.prototype.getGraphPath.apply(this,arguments);return t}getValues(o,t){var e,n;let i,r,p,s,a,l,h,u,c,g,f,d,y,k,S,x=t.period,v=t.periodTenkan,A=t.periodSenkouSpanB,b=o.xData,C=o.yData,P=o.xAxis,j=C&&C.length||0,B=(e=P.series.map(o=>o.getColumn("x")),S=!n,e.forEach(o=>{if(o.length>1)for(k=d=o.length-1;k>0;k--)(y=o[k]-o[k-1])<0&&!S?(n?.(),n=void 0):y&&(void 0===f||y<f)&&(f=y)}),f),G=[],N=[];if(b.length<=x||!m(C[0])||4!==C[0].length)return;let O=b[0]-x*B;for(a=0;a<x;a++)N.push(O+a*B);for(a=0;a<j;a++)a>=v&&(l=((r=Y(C.slice(a-v,a))).high+r.low)/2),a>=x&&(c=(l+(h=((p=Y(C.slice(a-x,a))).high+p.low)/2))/2),a>=A&&(g=((s=Y(C.slice(a-A,a))).high+s.low)/2),u=C[a][3],i=b[a],void 0===G[a]&&(G[a]=[]),void 0===G[a+x-1]&&(G[a+x-1]=[]),G[a+x-1][0]=l,G[a+x-1][1]=h,G[a+x-1][2]=void 0,void 0===G[a+1]&&(G[a+1]=[]),G[a+1][2]=u,a<=x&&(G[a+x-1][3]=void 0,G[a+x-1][4]=void 0),void 0===G[a+2*x-2]&&(G[a+2*x-2]=[]),G[a+2*x-2][3]=c,G[a+2*x-2][4]=g,N.push(i);for(a=1;a<=x;a++)N.push(i+a*B);return{values:G,xData:N,yData:G}}}j.defaultOptions=v(C.defaultOptions,{params:{index:void 0,period:26,periodTenkan:9,periodSenkouSpanB:52},marker:{enabled:!1},tooltip:{pointFormat:'<span style="color:{point.color}">●</span> <b> {series.name}</b><br/>TENKAN SEN: {point.tenkanSen:.3f}<br/>KIJUN SEN: {point.kijunSen:.3f}<br/>CHIKOU SPAN: {point.chikouSpan:.3f}<br/>SENKOU SPAN A: {point.senkouSpanA:.3f}<br/>SENKOU SPAN B: {point.senkouSpanB:.3f}<br/>'},tenkanLine:{styles:{lineWidth:1,lineColor:void 0}},kijunLine:{styles:{lineWidth:1,lineColor:void 0}},chikouLine:{styles:{lineWidth:1,lineColor:void 0}},senkouSpanA:{styles:{lineWidth:1,lineColor:void 0}},senkouSpanB:{styles:{lineWidth:1,lineColor:void 0}},senkouSpan:{styles:{fill:"rgba(255, 0, 0, 0.5)"}},dataGrouping:{approximation:"ichimoku-averages"}}),function(o,t){let e;for(e in o||(o={}),t)o[e]=t[e]}(j.prototype,{pointArrayMap:["tenkanSen","kijunSen","chikouSpan","senkouSpanA","senkouSpanB"],pointValKey:"tenkanSen",nameComponents:["periodSenkouSpanB","period","periodTenkan"]}),u()["ichimoku-averages"]=function(){let o,t=[];return[].forEach.call(arguments,function(e,n){t.push(u().average(e)),o=!o&&void 0===t[n]}),o?void 0:t},d().registerSeriesType("ikh",j);let B=l();return s.default})());