highcharts
Version:
JavaScript charting framework
205 lines (194 loc) • 6.72 kB
JavaScript
// SPDX-License-Identifier: LicenseRef-Highcharts
/**
* @license Highstock JS v13.0.1 (2026-08-17)
* @module highcharts/indicators/momentum
* @requires highcharts
* @requires highcharts/modules/stock
*
* Indicator series type for Highcharts Stock
*
* (c) 2010-2026 Highsoft AS
* Author: Sebastian Bochan
*
* A commercial license may be required depending on use,
* see www.highcharts.com/license
*/
import * as __WEBPACK_EXTERNAL_MODULE__highcharts_src_js_8202131d__ from "../highcharts.src.js";
/******/ // The require scope
/******/ const __webpack_require__ = {};
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = (module) => {
/******/ const getter = module && module.__esModule ?
/******/ () => (module['default']) :
/******/ () => (module);
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter/value functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ if(Array.isArray(definition)) {
/******/ var i = 0;
/******/ while(i < definition.length) {
/******/ var key = definition[i++];
/******/ var binding = definition[i++];
/******/ if(!__webpack_require__.o(exports, key)) {
/******/ if(binding === 0) {
/******/ Object.defineProperty(exports, key, { enumerable: true, value: definition[i++] });
/******/ } else {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: binding });
/******/ }
/******/ } else if(binding === 0) { i++; }
/******/ }
/******/ } else {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/************************************************************************/
;// external ["../highcharts.src.js","default"]
const external_highcharts_src_js_default_namespaceObject = __WEBPACK_EXTERNAL_MODULE__highcharts_src_js_8202131d__["default"];
var external_highcharts_src_js_default_default = /*#__PURE__*/__webpack_require__.n(external_highcharts_src_js_default_namespaceObject);
;// external ["../highcharts.src.js","default","SeriesRegistry"]
const external_highcharts_src_js_default_SeriesRegistry_namespaceObject = __WEBPACK_EXTERNAL_MODULE__highcharts_src_js_8202131d__["default"].SeriesRegistry;
var external_highcharts_src_js_default_SeriesRegistry_default = /*#__PURE__*/__webpack_require__.n(external_highcharts_src_js_default_SeriesRegistry_namespaceObject);
;// ./code/es-modules/Stock/Indicators/Momentum/MomentumIndicator.js
/* *
*
* Integration of this software requires a license.
* - For commercial use, see www.highcharts.com/license
* - For non-commercial, see www.highcharts.com/license-eula
*
*
* */
const { sma: SMAIndicator } = (external_highcharts_src_js_default_SeriesRegistry_default()).seriesTypes;
/* *
*
* Functions
*
* */
/** @internal */
function populateAverage(xVal, yVal, i, period, index) {
const mmY = yVal[i - 1][index] - yVal[i - period - 1][index], mmX = xVal[i - 1];
return [mmX, mmY];
}
/* *
*
* Class
*
* */
/**
* The Momentum series type.
*
* @internal
* @class
* @name Highcharts.seriesTypes.momentum
*
* @augments Highcharts.Series
*/
class MomentumIndicator extends SMAIndicator {
/* *
*
* Functions
*
* */
getValues(series, params) {
const period = params.period, index = params.index, xVal = series.xData, yVal = series.yData, yValLen = yVal ? yVal.length : 0, MM = [], xData = [], yData = [];
let i, MMPoint;
if (xVal.length <= period) {
return;
}
// Switch index for OHLC / Candlestick / Arearange
if (!(0,external_highcharts_src_js_default_namespaceObject.isArray)(yVal[0])) {
return;
}
// Calculate value one-by-one for each period in visible data
for (i = (period + 1); i < yValLen; i++) {
MMPoint = populateAverage(xVal, yVal, i, period, index);
MM.push(MMPoint);
xData.push(MMPoint[0]);
yData.push(MMPoint[1]);
}
MMPoint = populateAverage(xVal, yVal, i, period, index);
MM.push(MMPoint);
xData.push(MMPoint[0]);
yData.push(MMPoint[1]);
return {
values: MM,
xData: xData,
yData: yData
};
}
}
/* *
*
* Static Properties
*
* */
/**
* Momentum. This series requires `linkedTo` option to be set.
*
* @sample {highstock} stock/indicators/momentum
* Momentum indicator
*
* @extends plotOptions.sma
* @since 6.0.0
* @product highstock
* @requires stock/indicators/indicators
* @requires stock/indicators/momentum
* @optionparent plotOptions.momentum
*/
MomentumIndicator.defaultOptions = (0,external_highcharts_src_js_default_namespaceObject.merge)(SMAIndicator.defaultOptions, {
params: {
index: 3
}
});
(0,external_highcharts_src_js_default_namespaceObject.extend)(MomentumIndicator.prototype, {
nameBase: 'Momentum'
});
external_highcharts_src_js_default_SeriesRegistry_default().registerSeriesType('momentum', MomentumIndicator);
/* *
*
* Default Export
*
* */
/** @internal */
/* harmony default export */ const Momentum_MomentumIndicator = ((/* unused pure expression or super */ null && (MomentumIndicator)));
/* *
*
* API Options
*
* */
/**
* A `Momentum` series. If the [type](#series.momentum.type) option is not
* specified, it is inherited from [chart.type](#chart.type).
*
* @extends series,plotOptions.momentum
* @since 6.0.0
* @excluding dataParser, dataURL
* @product highstock
* @requires stock/indicators/indicators
* @requires stock/indicators/momentum
* @apioption series.momentum
*/
''; // To include the above in the js output
;// ./code/es-modules/masters/indicators/momentum.src.js
/* harmony default export */ const momentum_src = ((external_highcharts_src_js_default_default()));
export { momentum_src as default };