UNPKG

highcharts

Version:
9 lines 5.31 kB
/** * Highstock JS v11.3.0 (2024-01-10) * * Indicator series type for Highcharts Stock * * (c) 2010-2024 Rafal Sebestjanski * * License: www.highcharts.com/license */!function(t){"object"==typeof module&&module.exports?(t.default=t,module.exports=t):"function"==typeof define&&define.amd?define("highcharts/indicators/dmi",["highcharts","highcharts/modules/stock"],function(e){return t(e),t.Highcharts=e,t}):t("undefined"!=typeof Highcharts?Highcharts:void 0)}(function(t){"use strict";var e=t?t._modules:{};function i(t,e,i,s){t.hasOwnProperty(e)||(t[e]=s.apply(null,i),"function"==typeof CustomEvent&&window.dispatchEvent(new CustomEvent("HighchartsModuleLoaded",{detail:{path:e,module:t[e]}})))}i(e,"Stock/Indicators/MultipleLinesComposition.js",[e["Core/Series/SeriesRegistry.js"],e["Core/Utilities.js"]],function(t,e){var i;let{sma:{prototype:s}}=t.seriesTypes,{defined:a,error:o,merge:n}=e;return function(t){let e=["bottomLine"],i=["top","bottom"],l=["top"];function r(t){return"plot"+t.charAt(0).toUpperCase()+t.slice(1)}function p(t,e){let i=[];return(t.pointArrayMap||[]).forEach(t=>{t!==e&&i.push(r(t))}),i}function h(){let t=this,e=t.pointValKey,i=t.linesApiNames,l=t.areaLinesNames,h=t.points,u=t.options,c=t.graph,d={options:{gapSize:u.gapSize}},m=[],f=p(t,e),y=h.length,g;if(f.forEach((t,e)=>{for(m[e]=[];y--;)g=h[y],m[e].push({x:g.x,plotX:g.plotX,plotY:g[t],isNull:!a(g[t])});y=h.length}),t.userOptions.fillColor&&l.length){let e=f.indexOf(r(l[0])),i=m[e],a=1===l.length?h:m[f.indexOf(r(l[1]))],o=t.color;t.points=a,t.nextPoints=i,t.color=t.userOptions.fillColor,t.options=n(h,d),t.graph=t.area,t.fillGraph=!0,s.drawGraph.call(t),t.area=t.graph,delete t.nextPoints,delete t.fillGraph,t.color=o}i.forEach((e,i)=>{m[i]?(t.points=m[i],u[e]?t.options=n(u[e].styles,d):o('Error: "There is no '+e+' in DOCS options declared. Check if linesApiNames are consistent with your DOCS line names."'),t.graph=t["graph"+e],s.drawGraph.call(t),t["graph"+e]=t.graph):o('Error: "'+e+" doesn't have equivalent in pointArrayMap. To many elements in linesApiNames relative to pointArrayMap.\"")}),t.points=h,t.options=u,t.graph=c,s.drawGraph.call(t)}function u(t){let e,i=[],a=[];if(t=t||this.points,this.fillGraph&&this.nextPoints){if((e=s.getGraphPath.call(this,this.nextPoints))&&e.length){e[0][0]="L",i=s.getGraphPath.call(this,t),a=e.slice(0,i.length);for(let t=a.length-1;t>=0;t--)i.push(a[t])}}else i=s.getGraphPath.apply(this,arguments);return i}function c(t){let e=[];return(this.pointArrayMap||[]).forEach(i=>{e.push(t[i])}),e}function d(){let t=this.pointArrayMap,e=[],i;e=p(this),s.translate.apply(this,arguments),this.points.forEach(s=>{t.forEach((t,a)=>{i=s[t],this.dataModify&&(i=this.dataModify.modifyValue(i)),null!==i&&(s[e[a]]=this.yAxis.toPixels(i,!0))})})}t.compose=function(t){let s=t.prototype;return s.linesApiNames=s.linesApiNames||e.slice(),s.pointArrayMap=s.pointArrayMap||i.slice(),s.pointValKey=s.pointValKey||"top",s.areaLinesNames=s.areaLinesNames||l.slice(),s.drawGraph=h,s.getGraphPath=u,s.toYData=c,s.translate=d,t}}(i||(i={})),i}),i(e,"Stock/Indicators/DMI/DMIIndicator.js",[e["Stock/Indicators/MultipleLinesComposition.js"],e["Core/Series/SeriesRegistry.js"],e["Core/Utilities.js"]],function(t,e,i){let{sma:s}=e.seriesTypes,{correctFloat:a,extend:o,isArray:n,merge:l}=i;class r extends s{calculateDM(t,e,i){let s=t[e][1],o=t[e][2],n=t[e-1][1],l=t[e-1][2];return a(s-n>l-o?i?Math.max(s-n,0):0:i?0:Math.max(l-o,0))}calculateDI(t,e){return t/e*100}calculateDX(t,e){return a(Math.abs(t-e)/Math.abs(t+e)*100)}smoothValues(t,e,i){return a(t-t/i+e)}getTR(t,e){return a(Math.max(t[1]-t[2],e?Math.abs(t[1]-e[3]):0,e?Math.abs(t[2]-e[3]):0))}getValues(t,e){let i=e.period,s=t.xData,a=t.yData,o=a?a.length:0,l=[],r=[],p=[];if(s.length<=i||!n(a[0])||4!==a[0].length)return;let h=0,u=0,c=0,d;for(d=1;d<o;d++){let t,e,o,n,m,f,y,g,D;d<=i?(n=this.calculateDM(a,d,!0),m=this.calculateDM(a,d),f=this.getTR(a[d],a[d-1]),h+=n,u+=m,c+=f,d===i&&(y=this.calculateDI(h,c),g=this.calculateDI(u,c),D=this.calculateDX(h,u),l.push([s[d],D,y,g]),r.push(s[d]),p.push([D,y,g]))):(n=this.calculateDM(a,d,!0),m=this.calculateDM(a,d),f=this.getTR(a[d],a[d-1]),t=this.smoothValues(h,n,i),e=this.smoothValues(u,m,i),o=this.smoothValues(c,f,i),h=t,u=e,c=o,y=this.calculateDI(h,c),g=this.calculateDI(u,c),D=this.calculateDX(h,u),l.push([s[d],D,y,g]),r.push(s[d]),p.push([D,y,g]))}return{values:l,xData:r,yData:p}}}return r.defaultOptions=l(s.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:"#06b535"}},minusDILine:{styles:{lineWidth:1,lineColor:"#f21313"}},dataGrouping:{approximation:"averages"}}),o(r.prototype,{areaLinesNames:[],nameBase:"DMI",linesApiNames:["plusDILine","minusDILine"],pointArrayMap:["y","plusDI","minusDI"],parallelArrays:["x","y","plusDI","minusDI"],pointValKey:"y"}),t.compose(r),e.registerSeriesType("dmi",r),r}),i(e,"masters/indicators/dmi.src.js",[],function(){})});