UNPKG

highcharts

Version:
14 lines 5.29 kB
/** * Highstock JS v13.0.1 (2026-08-17) * @module highcharts/indicators/dmi * @requires highcharts * @requires highcharts/modules/stock * * Indicator series type for Highcharts Stock * * (c) 2010-2026 Highsoft AS * Author: Rafał Sebestjański * * A commercial license may be required depending on use, * see www.highcharts.com/license */import*as e from"../highcharts.js";let t={};t.n=e=>{let a=e&&e.__esModule?()=>e.default:()=>e;return t.d(a,{a:a}),a},t.d=(e,a)=>{if(Array.isArray(a))for(var r=0;r<a.length;){var s=a[r++],i=a[r++];t.o(e,s)?0===i&&r++:0===i?Object.defineProperty(e,s,{enumerable:!0,value:a[r++]}):Object.defineProperty(e,s,{enumerable:!0,get:i})}else for(var s in a)t.o(a,s)&&!t.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:a[s]})},t.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let a=e.default;var r,s=t.n(a);let i=e.default.SeriesRegistry;var l=t.n(i);let{sma:{prototype:o}}=l().seriesTypes;!function(e){let t=["bottomLine"],r=["top","bottom"],s=["top"];function i(e){return"plot"+e.charAt(0).toUpperCase()+e.slice(1)}function l(e,t){let a=[];return(e.pointArrayMap||[]).forEach(e=>{e!==t&&a.push(i(e))}),a}function n(){let e=this,t=e.pointValKey,r=e.linesApiNames,s=e.areaLinesNames,n=e.points,p=e.options,h=e.graph,c={options:{gapSize:p.gapSize}},u=[],y=l(e,t),m=n.length,f;if(y.forEach((e,t)=>{for(u[t]=[];m--;)f=n[m],u[t].push({x:f.x,plotX:f.plotX,plotY:f[e],isNull:!(0,a.defined)(f[e])});m=n.length}),e.userOptions.fillColor&&s.length){let t=u[y.indexOf(i(s[0]))],r=1===s.length?n:u[y.indexOf(i(s[1]))],l=e.color;e.points=r,e.nextPoints=t,e.color=e.userOptions.fillColor,e.options=(0,a.merge)(n,c),e.graph=e.area,e.fillGraph=!0,o.drawGraph.call(e),e.area=e.graph,delete e.nextPoints,delete e.fillGraph,e.color=l}r.forEach((t,r)=>{u[r]?(e.points=u[r],p[t]?e.options=(0,a.merge)(p[t].styles,c):(0,a.error)('Error: "There is no '+t+' in DOCS options declared. Check if linesApiNames are consistent with your DOCS line names."'),e.graph=e["graph"+t],o.drawGraph.call(e),e["graph"+t]=e.graph):(0,a.error)('Error: "'+t+" doesn't have equivalent in pointArrayMap. To many elements in linesApiNames relative to pointArrayMap.\"")}),e.points=n,e.options=p,e.graph=h,o.drawGraph.call(e)}function p(e){let t,a=[],r=[];if(e=e||this.points,this.fillGraph&&this.nextPoints){if((t=o.getGraphPath.call(this,this.nextPoints))&&t.length){t[0][0]="L",a=o.getGraphPath.call(this,e),r=t.slice(0,a.length);for(let e=r.length-1;e>=0;e--)a.push(r[e])}}else a=o.getGraphPath.apply(this,arguments);return a}function h(e){let t=[];return(this.pointArrayMap||[]).forEach(a=>{t.push(e[a])}),t}function c(){let e=this.pointArrayMap,t=[],a;t=l(this),o.translate.apply(this,arguments),this.points.forEach(r=>{e.forEach((e,s)=>{a=r[e],this.dataModify&&(a=this.dataModify.modifyValue(a)),null!==a&&(r[t[s]]=this.yAxis.toPixels(a,!0))})})}e.compose=function(e){let a=e.prototype;return a.linesApiNames=a.linesApiNames||t.slice(),a.pointArrayMap=a.pointArrayMap||r.slice(),a.pointValKey=a.pointValKey||"top",a.areaLinesNames=a.areaLinesNames||s.slice(),a.drawGraph=n,a.getGraphPath=p,a.toYData=h,a.translate=c,e}}(r||(r={}));let n=r,{sma:p}=l().seriesTypes;class h extends p{calculateDM(e,t,r){let s,i=e[t][1],l=e[t][2],o=e[t-1][1],n=e[t-1][2];return s=i-o>n-l?r?Math.max(i-o,0):0:r?0:Math.max(n-l,0),(0,a.correctFloat)(s)}calculateDI(e,t){return e/t*100}calculateDX(e,t){return(0,a.correctFloat)(Math.abs(e-t)/Math.abs(e+t)*100)}smoothValues(e,t,r){return(0,a.correctFloat)(e-e/r+t)}getTR(e,t){return(0,a.correctFloat)(Math.max(e[1]-e[2],t?Math.abs(e[1]-t[3]):0,t?Math.abs(e[2]-t[3]):0))}getValues(e,t){let r=t.period,s=e.xData,i=e.yData,l=i?i.length:0,o=[],n=[],p=[];if(s.length<=r||!(0,a.isArray)(i[0])||4!==i[0].length)return;let h=0,c=0,u=0,y;for(y=1;y<l;y++){let e,t,a,l,m,f,g,d,D;y<=r?(l=this.calculateDM(i,y,!0),m=this.calculateDM(i,y),f=this.getTR(i[y],i[y-1]),h+=l,c+=m,u+=f,y===r&&(g=this.calculateDI(h,u),d=this.calculateDI(c,u),D=this.calculateDX(h,c),o.push([s[y],D,g,d]),n.push(s[y]),p.push([D,g,d]))):(l=this.calculateDM(i,y,!0),m=this.calculateDM(i,y),f=this.getTR(i[y],i[y-1]),e=this.smoothValues(h,l,r),t=this.smoothValues(c,m,r),a=this.smoothValues(u,f,r),h=e,c=t,u=a,g=this.calculateDI(h,u),d=this.calculateDI(c,u),D=this.calculateDX(h,c),o.push([s[y],D,g,d]),n.push(s[y]),p.push([D,g,d]))}return{values:o,xData:n,yData:p}}}h.defaultOptions=(0,a.merge)(p.defaultOptions,{params:{index:void 0},marker:{enabled:!1},tooltip:{pointFormat:'<span style="color: {point.color}">●</span><b> {series.name}</b><br/><span style="color: {point.color}">DX</span>: {point.y}<br/><span style="color: {point.series.options.plusDILine.styles.lineColor}">+DI</span>: {point.plusDI}<br/><span style="color: {point.series.options.minusDILine.styles.lineColor}">-DI</span>: {point.minusDI}<br/>'},plusDILine:{styles:{lineWidth:1,lineColor:"var(--highcharts-positive-color)"}},minusDILine:{styles:{lineWidth:1,lineColor:"var(--highcharts-negative-color)"}},dataGrouping:{approximation:"averages"}}),(0,a.extend)(h.prototype,{areaLinesNames:[],nameBase:"DMI",linesApiNames:["plusDILine","minusDILine"],pointArrayMap:["y","plusDI","minusDI"],parallelArrays:["x","y","plusDI","minusDI"],pointValKey:"y"}),n.compose(h),l().registerSeriesType("dmi",h);let c=s();export{c as default};