highcharts
Version:
JavaScript charting framework
12 lines • 2.47 kB
JavaScript
/**
* Highstock JS v12.6.0 (2026-04-13)
* @module highcharts/indicators/cmf
* @requires highcharts
* @requires highcharts/modules/stock
*
* (c) 2010-2026 Highsoft AS
* Author: Sebastian Domas
*
* A commercial license may be required depending on use.
* See www.highcharts.com/license
*/import*as e from"../highcharts.js";var t={};t.n=e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},t.d=(e,r)=>{for(var o in r)t.o(r,o)&&!t.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:r[o]})},t.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);let r=e.default;var o=t.n(r);let n=e.default.SeriesRegistry;var l=t.n(n);let{doc:a,win:s}=o();function u(e){return i(e)&&"number"==typeof e.nodeType}function i(e,t){let r;return!!e&&"object"==typeof e&&(!t||"[object Array]"!==(r=Object.prototype.toString.call(e))&&"[object Array Iterator]"!==r)}Array.prototype.find;let{sma:p}=l().seriesTypes;class c extends p{constructor(){super(...arguments),this.nameBase="Chaikin Money Flow"}isValid(){let e=this.chart,t=this.options,r=this.linkedParent,o=this.volumeSeries||(this.volumeSeries=e.get(t.params.volumeSeriesID)),n=r?.pointArrayMap?.length===4;function l(e){return e.dataTable.rowCount>=t.params.period}return!!(r&&o&&l(r)&&l(o)&&n)}getValues(e,t){if(this.isValid())return this.getMoneyFlow(e.xData,e.yData,this.volumeSeries.getColumn("y"),t.period)}getMoneyFlow(e,t,r,o){let n=t.length,l=[],a=[],s=[],u=[],i,p,c=-1,f=0,h=0;function y(e,t){let r=e[1],o=e[2],n=e[3];return null!==t&&null!==r&&null!==o&&null!==n&&r!==o?(n-o-(r-n))/(r-o)*t:(c=i,null)}if(o>0&&o<=n){for(i=0;i<o;i++)l[i]=y(t[i],r[i]),f+=r[i],h+=l[i];for(a.push(e[i-1]),s.push(i-c>=o&&0!==f?h/f:null),u.push([a[0],s[0]]);i<n;i++)l[i]=y(t[i],r[i]),f-=r[i-o],f+=r[i],h-=l[i-o],h+=l[i],p=[e[i],i-c>=o?h/f:null],a.push(p[0]),s.push(p[1]),u.push([p[0],p[1]])}return{values:u,xData:a,yData:s}}}c.defaultOptions=function(e,...t){let r,o=[e,...t],n={},l=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 n;!i(r,!0)||(n=r?.constructor,i(r,!0)&&!u(r)&&n?.name&&"Object"!==n.name)||u(r)?e[o]=t[o]:e[o]=l(e[o]||{},r)}}),e};!0===e&&(n=o[1],o=Array.prototype.slice.call(o,2));let a=o.length;for(r=0;r<a;r++)n=l(n,o[r]);return n}(p.defaultOptions,{params:{index:void 0,volumeSeriesID:"volume"}}),l().registerSeriesType("cmf",c);let f=o();export{f as default};