UNPKG

highcharts

Version:
14 lines 3.79 kB
!/** * Highstock JS v12.6.0 (2026-04-13) * @module highcharts/indicators/chaikin * @requires highcharts * @requires highcharts/modules/stock * * Indicator series type for Highcharts Stock * * (c) 2010-2026 Highsoft AS * Author: Wojciech Chmiel * * A commercial license may be required depending on use. * See www.highcharts.com/license */function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(e._Highcharts,e._Highcharts.SeriesRegistry):"function"==typeof define&&define.amd?define("highcharts/indicators/chaikin",["highcharts/highcharts"],function(e){return t(e,e.SeriesRegistry)}):"object"==typeof exports?exports["highcharts/indicators/chaikin"]=t(e._Highcharts,e._Highcharts.SeriesRegistry):e.Highcharts=t(e.Highcharts,e.Highcharts.SeriesRegistry)}("u"<typeof window?this:window,(e,t)=>(()=>{"use strict";var r={512:e=>{e.exports=t},944:t=>{t.exports=e}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;var a=o[e]={exports:{}};return r[e](a,a.exports,i),a.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var r in t)i.o(t,r)&&!i.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var a={};i.d(a,{default:()=>D});var s=i(944),n=i.n(s),u=i(512),l=i.n(u);let{doc:p,win:c}=n();function h(e,t){let r;for(r in e||(e={}),t)e[r]=t[r];return e}function d(e){return f(e)&&"number"==typeof e.nodeType}function f(e,t){let r;return!!e&&"object"==typeof e&&(!t||"[object Array]"!==(r=Object.prototype.toString.call(e))&&"[object Array Iterator]"!==r)}function y(e,...t){let r,o=[e,...t],i={},a=function(e,t){return"object"!=typeof e&&(e={}),function(e,t,r){for(let r in e)Object.hasOwnProperty.call(e,r)&&t.call((0,e[r]),e[r],r,e)}(t,function(r,o){if("__proto__"!==o&&"constructor"!==o){let i;!f(r,!0)||(i=r?.constructor,f(r,!0)&&!d(r)&&i?.name&&"Object"!==i.name)||d(r)?e[o]=t[o]:e[o]=a(e[o]||{},r)}}),e};!0===e&&(i=o[1],o=Array.prototype.slice.call(o,2));let s=o.length;for(r=0;r<s;r++)i=a(i,o[r]);return i}Array.prototype.find;let{sma:g}=l().seriesTypes;class m extends g{static populateAverage(e,t,r,o,i){let a=t[o][1],s=t[o][2],n=t[o][3],u=r[o],l=n===a&&n===s||a===s?0:(2*n-s-a)/(a-s)*u;return[e[o],l]}getValues(e,t){let r,o,i,a=t.period,n=e.xData,u=e.yData,l=t.volumeSeriesID,p=e.chart.get(l),c=p?.getColumn("y"),h=u?u.length:0,d=[],f=[],y=[];if(!(n.length<=a)||!h||4===u[0].length){if(!p)return void(0,s.error)("Series "+l+" not found! Check `volumeSeriesID`.",!0,e.chart);for(o=a;o<h;o++)r=d.length,i=m.populateAverage(n,u,c,o,a),r>0&&(i[1]+=d[r-1][1]),d.push(i),f.push(i[0]),y.push(i[1]);return{values:d,xData:f,yData:y}}}}m.defaultOptions=y(g.defaultOptions,{params:{index:void 0,volumeSeriesID:"volume"}}),h(m.prototype,{nameComponents:!1,nameBase:"Accumulation/Distribution"}),l().registerSeriesType("ad",m);let{ema:v}=l().seriesTypes;class x extends v{getValues(e,t){let r,o,i=t.periods,a=t.period,n=[],u=[],l=[];if(2!==i.length||i[1]<=i[0])return void(0,s.error)('Error: "Chaikin requires two periods. Notice, first period should be lower than the second one."');let p=m.prototype.getValues.call(this,e,{volumeSeriesID:t.volumeSeriesID,period:a});if(!p)return;let c=super.getValues.call(this,p,{period:i[0]}),h=super.getValues.call(this,p,{period:i[1]});if(!c||!h)return;let d=i[1]-i[0];for(o=0;o<h.yData.length;o++){var f;r=(f=c.yData[o+d]-h.yData[o])>1e14?f:parseFloat(f.toPrecision(14)),n.push([h.xData[o],r]),u.push(h.xData[o]),l.push(r)}return{values:n,xData:u,yData:l}}}x.defaultOptions=y(v.defaultOptions,{params:{index:void 0,volumeSeriesID:"volume",period:9,periods:[3,10]}}),h(x.prototype,{nameBase:"Chaikin Osc",nameComponents:["periods"]}),l().registerSeriesType("chaikin",x);let D=n();return a.default})());