UNPKG

highcharts

Version:
14 lines 4.68 kB
/** * Highstock JS v13.0.1 (2026-08-17) * @module highcharts/indicators/keltner-channels * @requires highcharts * @requires highcharts/modules/stock * * Indicator series type for Highcharts Stock * * (c) 2010-2026 Highsoft AS * Author: Daniel Studencki * * 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 o=e&&e.__esModule?()=>e.default:()=>e;return t.d(o,{a:o}),o},t.d=(e,o)=>{if(Array.isArray(o))for(var r=0;r<o.length;){var i=o[r++],a=o[r++];t.o(e,i)?0===a&&r++:0===a?Object.defineProperty(e,i,{enumerable:!0,value:o[r++]}):Object.defineProperty(e,i,{enumerable:!0,get:a})}else for(var i in o)t.o(o,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:o[i]})},t.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let o=e.default;var r,i=t.n(o);let a=e.default.SeriesRegistry;var n=t.n(a);let{sma:{prototype:s}}=n().seriesTypes;!function(e){let t=["bottomLine"],r=["top","bottom"],i=["top"];function a(e){return"plot"+e.charAt(0).toUpperCase()+e.slice(1)}function n(e,t){let o=[];return(e.pointArrayMap||[]).forEach(e=>{e!==t&&o.push(a(e))}),o}function l(){let e=this,t=e.pointValKey,r=e.linesApiNames,i=e.areaLinesNames,l=e.points,p=e.options,h=e.graph,d={options:{gapSize:p.gapSize}},c=[],m=n(e,t),u=l.length,y;if(m.forEach((e,t)=>{for(c[t]=[];u--;)y=l[u],c[t].push({x:y.x,plotX:y.plotX,plotY:y[e],isNull:!(0,o.defined)(y[e])});u=l.length}),e.userOptions.fillColor&&i.length){let t=c[m.indexOf(a(i[0]))],r=1===i.length?l:c[m.indexOf(a(i[1]))],n=e.color;e.points=r,e.nextPoints=t,e.color=e.userOptions.fillColor,e.options=(0,o.merge)(l,d),e.graph=e.area,e.fillGraph=!0,s.drawGraph.call(e),e.area=e.graph,delete e.nextPoints,delete e.fillGraph,e.color=n}r.forEach((t,r)=>{c[r]?(e.points=c[r],p[t]?e.options=(0,o.merge)(p[t].styles,d):(0,o.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],s.drawGraph.call(e),e["graph"+t]=e.graph):(0,o.error)('Error: "'+t+" doesn't have equivalent in pointArrayMap. To many elements in linesApiNames relative to pointArrayMap.\"")}),e.points=l,e.options=p,e.graph=h,s.drawGraph.call(e)}function p(e){let t,o=[],r=[];if(e=e||this.points,this.fillGraph&&this.nextPoints){if((t=s.getGraphPath.call(this,this.nextPoints))&&t.length){t[0][0]="L",o=s.getGraphPath.call(this,e),r=t.slice(0,o.length);for(let e=r.length-1;e>=0;e--)o.push(r[e])}}else o=s.getGraphPath.apply(this,arguments);return o}function h(e){let t=[];return(this.pointArrayMap||[]).forEach(o=>{t.push(e[o])}),t}function d(){let e=this.pointArrayMap,t=[],o;t=n(this),s.translate.apply(this,arguments),this.points.forEach(r=>{e.forEach((e,i)=>{o=r[e],this.dataModify&&(o=this.dataModify.modifyValue(o)),null!==o&&(r[t[i]]=this.yAxis.toPixels(o,!0))})})}e.compose=function(e){let o=e.prototype;return o.linesApiNames=o.linesApiNames||t.slice(),o.pointArrayMap=o.pointArrayMap||r.slice(),o.pointValKey=o.pointValKey||"top",o.areaLinesNames=o.areaLinesNames||i.slice(),o.drawGraph=l,o.getGraphPath=p,o.toYData=h,o.translate=d,e}}(r||(r={}));let l=r,{sma:p}=n().seriesTypes;class h extends p{init(){n().seriesTypes.sma.prototype.init.apply(this,arguments),this.options=(0,o.merge)({topLine:{styles:{lineColor:this.color}},bottomLine:{styles:{lineColor:this.color}}},this.options)}getValues(e,t){let r,i,a,s,l,p,h,d=t.period,c=t.periodATR,m=t.multiplierATR,u=t.index,y=e.yData,f=y?y.length:0,g=[],A=n().seriesTypes.ema.prototype.getValues(e,{period:d,index:u}),b=n().seriesTypes.atr.prototype.getValues(e,{period:c}),x=[],v=[];if(!(f<d)){for(h=d;h<=f;h++)l=A.values[h-d],p=b.values[h-c],s=l[0],i=(0,o.correctFloat)(l[1]+m*p[1]),a=(0,o.correctFloat)(l[1]-m*p[1]),r=l[1],g.push([s,i,r,a]),x.push(s),v.push([i,r,a]);return{values:g,xData:x,yData:v}}}}h.defaultOptions=(0,o.merge)(p.defaultOptions,{params:{index:0,period:20,periodATR:10,multiplierATR:2},bottomLine:{styles:{lineWidth:1,lineColor:void 0}},topLine:{styles:{lineWidth:1,lineColor:void 0}},tooltip:{pointFormat:'<span style="color:{point.color}">●</span><b> {series.name}</b><br/>Upper Channel: {point.top}<br/>EMA({series.options.params.period}): {point.middle}<br/>Lower Channel: {point.bottom}<br/>'},marker:{enabled:!1},dataGrouping:{approximation:"averages"},lineWidth:1}),(0,o.extend)(h.prototype,{nameBase:"Keltner Channels",areaLinesNames:["top","bottom"],nameComponents:["period","periodATR","multiplierATR"],linesApiNames:["topLine","bottomLine"],pointArrayMap:["top","middle","bottom"],pointValKey:"middle"}),l.compose(h),n().registerSeriesType("keltnerchannels",h);let d=i();export{d as default};