UNPKG

highcharts

Version:
12 lines 4.39 kB
/** * Highstock JS v12.3.0 (2025-06-21) * @module highcharts/indicators/keltner-channels * @requires highcharts * @requires highcharts/modules/stock * * Indicator series type for Highcharts Stock * * (c) 2010-2025 Daniel Studencki * * License: www.highcharts.com/license */import*as e from"../highcharts.js";import"../modules/stock.js";var t,o={};o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let i=e.default;var r=o.n(i);o.d({},{});let a=e.default.SeriesRegistry;var s=o.n(a);let{sma:{prototype:n}}=s().seriesTypes,{defined:p,error:l,merge:h}=r();!function(e){let t=["bottomLine"],o=["top","bottom"],i=["top"];function r(e){return"plot"+e.charAt(0).toUpperCase()+e.slice(1)}function a(e,t){let o=[];return(e.pointArrayMap||[]).forEach(e=>{e!==t&&o.push(r(e))}),o}function s(){let e=this,t=e.pointValKey,o=e.linesApiNames,i=e.areaLinesNames,s=e.points,d=e.options,m=e.graph,c={options:{gapSize:d.gapSize}},u=[],y=a(e,t),f=s.length,g;if(y.forEach((e,t)=>{for(u[t]=[];f--;)g=s[f],u[t].push({x:g.x,plotX:g.plotX,plotY:g[e],isNull:!p(g[e])});f=s.length}),e.userOptions.fillColor&&i.length){let t=u[y.indexOf(r(i[0]))],o=1===i.length?s:u[y.indexOf(r(i[1]))],a=e.color;e.points=o,e.nextPoints=t,e.color=e.userOptions.fillColor,e.options=h(s,c),e.graph=e.area,e.fillGraph=!0,n.drawGraph.call(e),e.area=e.graph,delete e.nextPoints,delete e.fillGraph,e.color=a}o.forEach((t,o)=>{u[o]?(e.points=u[o],d[t]?e.options=h(d[t].styles,c):l('Error: "There is no '+t+' in DOCS options declared. Check if linesApiNames are consistent with your DOCS line names."'),e.graph=e["graph"+t],n.drawGraph.call(e),e["graph"+t]=e.graph):l('Error: "'+t+" doesn't have equivalent in pointArrayMap. To many elements in linesApiNames relative to pointArrayMap.\"")}),e.points=s,e.options=d,e.graph=m,n.drawGraph.call(e)}function d(e){let t,o=[],i=[];if(e=e||this.points,this.fillGraph&&this.nextPoints){if((t=n.getGraphPath.call(this,this.nextPoints))&&t.length){t[0][0]="L",o=n.getGraphPath.call(this,e),i=t.slice(0,o.length);for(let e=i.length-1;e>=0;e--)o.push(i[e])}}else o=n.getGraphPath.apply(this,arguments);return o}function m(e){let t=[];return(this.pointArrayMap||[]).forEach(o=>{t.push(e[o])}),t}function c(){let e=this.pointArrayMap,t=[],o;t=a(this),n.translate.apply(this,arguments),this.points.forEach(i=>{e.forEach((e,r)=>{o=i[e],this.dataModify&&(o=this.dataModify.modifyValue(o)),null!==o&&(i[t[r]]=this.yAxis.toPixels(o,!0))})})}e.compose=function(e){let r=e.prototype;return r.linesApiNames=r.linesApiNames||t.slice(),r.pointArrayMap=r.pointArrayMap||o.slice(),r.pointValKey=r.pointValKey||"top",r.areaLinesNames=r.areaLinesNames||i.slice(),r.drawGraph=s,r.getGraphPath=d,r.toYData=m,r.translate=c,e}}(t||(t={}));let d=t,{sma:m}=s().seriesTypes,{correctFloat:c,extend:u,merge:y}=r();class f extends m{init(){s().seriesTypes.sma.prototype.init.apply(this,arguments),this.options=y({topLine:{styles:{lineColor:this.color}},bottomLine:{styles:{lineColor:this.color}}},this.options)}getValues(e,t){let o,i,r,a,n,p,l,h=t.period,d=t.periodATR,m=t.multiplierATR,u=t.index,y=e.yData,f=y?y.length:0,g=[],A=s().seriesTypes.ema.prototype.getValues(e,{period:h,index:u}),b=s().seriesTypes.atr.prototype.getValues(e,{period:d}),x=[],v=[];if(!(f<h)){for(l=h;l<=f;l++)n=A.values[l-h],p=b.values[l-d],a=n[0],i=c(n[1]+m*p[1]),r=c(n[1]-m*p[1]),o=n[1],g.push([a,i,o,r]),x.push(a),v.push([i,o,r]);return{values:g,xData:x,yData:v}}}}f.defaultOptions=y(m.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}),u(f.prototype,{nameBase:"Keltner Channels",areaLinesNames:["top","bottom"],nameComponents:["period","periodATR","multiplierATR"],linesApiNames:["topLine","bottomLine"],pointArrayMap:["top","middle","bottom"],pointValKey:"middle"}),d.compose(f),s().registerSeriesType("keltnerchannels",f);let g=r();export{g as default};