UNPKG

highcharts

Version:
14 lines 6.34 kB
!/** * Highstock JS v12.6.0 (2026-04-13) * @module highcharts/indicators/supertrend * @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/supertrend",["highcharts/highcharts"],function(e){return t(e,e.SeriesRegistry)}):"object"==typeof exports?exports["highcharts/indicators/supertrend"]=t(e._Highcharts,e._Highcharts.SeriesRegistry):e.Highcharts=t(e.Highcharts,e.Highcharts.SeriesRegistry)}("u"<typeof window?this:window,(e,t)=>(()=>{"use strict";var o={512:e=>{e.exports=t},944:t=>{t.exports=e}},r={};function n(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={exports:{}};return o[e](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);var i={};n.d(i,{default:()=>S});var l=n(944),s=n.n(l),p=n(512),c=n.n(p);let{doc:a,win:u}=s();function h(e,t){return e>1e14?e:parseFloat(e.toPrecision(t||14))}function d(e){return g(e)&&"number"==typeof e.nodeType}function f(e){return"number"==typeof e&&!isNaN(e)&&e<1/0&&e>-1/0}function y(e){let t=Object.prototype.toString.call(e);return"[object Array]"===t||"[object Array Iterator]"===t}function g(e,t){return!!e&&"object"==typeof e&&(!t||!y(e))}function x(e,...t){let o,r=[e,...t],n={},i=function(e,t){return"object"!=typeof e&&(e={}),m(t,function(o,r){if("__proto__"!==r&&"constructor"!==r){let n;!g(o,!0)||(n=o?.constructor,g(o,!0)&&!d(o)&&n?.name&&"Object"!==n.name)||d(o)?e[r]=t[r]:e[r]=i(e[r]||{},o)}}),e};!0===e&&(n=r[1],r=Array.prototype.slice.call(r,2));let l=r.length;for(o=0;o<l;o++)n=i(n,r[o]);return n}function m(e,t,o){for(let r in e)Object.hasOwnProperty.call(e,r)&&t.call(o||e[r],e[r],r,e)}Array.prototype.find;let{atr:b,sma:v}=c().seriesTypes;function C(e,t){return{index:t,close:e.getColumn("close")[t],x:e.getColumn("x")[t]}}class T extends v{init(){let e=this;super.init.apply(e,arguments);let t=function(e,t,o,r={}){let n="function"==typeof e&&e.prototype||e;Object.hasOwnProperty.call(n,"hcEvents")||(n.hcEvents={});let i=n.hcEvents;s().Point&&e instanceof s().Point&&e.series&&e.series.chart&&(e.series.chart.runTrackerClick=!0);let l=e.addEventListener;l&&l.call(e,t,o,!!s().supportsPassiveEvents&&{passive:void 0===r.passive?-1!==t.indexOf("touch"):r.passive,capture:!1}),i[t]||(i[t]=[]);let p={fn:o,order:"number"==typeof r.order?r.order:1/0};return i[t].push(p),i[t].sort((e,t)=>e.order-t.order),function(){!function(e,t,o){function r(t,o){let r=e.removeEventListener;r&&r.call(e,t,o,!1)}function n(o){let n,i;e.nodeName&&(t?(n={})[t]=!0:n=o,m(n,function(e,t){if(o[t])for(i=o[t].length;i--;)r(t,o[t][i].fn)}))}let i="function"==typeof e&&e.prototype||e;if(Object.hasOwnProperty.call(i,"hcEvents")){let e=i.hcEvents;if(t){let i=e[t]||[];o?(e[t]=i.filter(function(e){return o!==e.fn}),r(t,o)):(n(e),e[t]=[])}else n(e),delete i.hcEvents}}(e,t,o)}}(this.chart.constructor,"afterLinkSeries",()=>{if(e.options){let t=e.options;t.cropThreshold=e.linkedParent.options.cropThreshold-(t.params.period-1)}t()},{order:1})}drawGraph(){let e=this,t=e.options,o=e.linkedParent,r=o.getColumn("x"),n=o?o.points:[],i=e.points,l=e.graph,s=n.length-i.length,p=s>0?s:0,c={options:{gapSize:t.gapSize}},a={top:[],bottom:[],intersect:[]},u={top:{styles:{lineWidth:t.lineWidth,lineColor:t.fallingTrendColor||t.color,dashStyle:t.dashStyle}},bottom:{styles:{lineWidth:t.lineWidth,lineColor:t.risingTrendColor||t.color,dashStyle:t.dashStyle}},intersect:t.changeTrendLine},h,d,y,g,b,T,S,j,O,P=i.length;for(;P--;)h=i[P],d=i[P-1],y=n[P-1+p],g=n[P-2+p],b=n[P+p],T=n[P+p+1],S=h.options.color,j={x:h.x,plotX:h.plotX,plotY:h.plotY,isNull:!1},!g&&y&&f(r[y.index-1])&&(g=C(o,y.index-1)),!T&&b&&f(r[b.index+1])&&(T=C(o,b.index+1)),!y&&g&&f(r[g.index+1])?y=C(o,g.index+1):!y&&b&&f(r[b.index-1])&&(y=C(o,b.index-1)),h&&y&&b&&g&&h.x!==y.x&&(h.x===b.x?(g=y,y=b):h.x===g.x?(y=g,g={close:o.getColumn("close")[y.index-1],x:r[y.index-1]}):T&&h.x===T.x&&(y=T,g=b)),d&&g&&y?(O={x:d.x,plotX:d.plotX,plotY:d.plotY,isNull:!1},h.y>=y.close&&d.y>=g.close?(h.color=S||t.fallingTrendColor||t.color,a.top.push(j)):h.y<y.close&&d.y<g.close?(h.color=S||t.risingTrendColor||t.color,a.bottom.push(j)):(a.intersect.push(j),a.intersect.push(O),a.intersect.push(x(O,{isNull:!0})),h.y>=y.close&&d.y<g.close?(h.color=S||t.fallingTrendColor||t.color,d.color=S||t.risingTrendColor||t.color,a.top.push(j),a.top.push(x(O,{isNull:!0}))):h.y<y.close&&d.y>=g.close&&(h.color=S||t.risingTrendColor||t.color,d.color=S||t.fallingTrendColor||t.color,a.bottom.push(j),a.bottom.push(x(O,{isNull:!0}))))):y&&(h.y>=y.close?(h.color=S||t.fallingTrendColor||t.color,a.top.push(j)):(h.color=S||t.risingTrendColor||t.color,a.bottom.push(j)));m(a,function(t,o){e.points=t,e.options=x(u[o].styles,c),e.graph=e["graph"+o+"Line"],v.prototype.drawGraph.call(e),e["graph"+o+"Line"]=e.graph}),e.points=i,e.options=t,e.graph=l}getValues(e,t){let o=t.period,r=t.multiplier,n=e.xData,i=e.yData,l=[],s=[],p=[],c=0===o?0:o-1,a=[],u=[],d=[],f,g,x,m,v,C,T,S,j;if(!(n.length<=o)&&y(i[0])&&4===i[0].length&&!(o<0)){for(j=0,d=b.prototype.getValues.call(this,e,{period:o}).yData;j<d.length;j++)S=i[c+j],T=i[c+j-1]||[],m=a[j-1],v=u[j-1],C=p[j-1],0===j&&(m=v=C=0),f=h((S[1]+S[2])/2+r*d[j]),g=h((S[1]+S[2])/2-r*d[j]),f<m||T[3]>m?a[j]=f:a[j]=m,g>v||T[3]<v?u[j]=g:u[j]=v,C===m&&S[3]<a[j]||C===v&&S[3]<u[j]?x=a[j]:(C===m&&S[3]>a[j]||C===v&&S[3]>u[j])&&(x=u[j]),l.push([n[c+j],x]),s.push(n[c+j]),p.push(x);return{values:l,xData:s,yData:p}}}}T.defaultOptions=x(v.defaultOptions,{params:{index:void 0,multiplier:3,period:10},risingTrendColor:"#06b535",fallingTrendColor:"#f21313",changeTrendLine:{styles:{lineWidth:1,lineColor:"#333333",dashStyle:"LongDash"}}}),function(e,t){let o;for(o in e||(e={}),t)e[o]=t[o]}(T.prototype,{nameBase:"Supertrend",nameComponents:["multiplier","period"]}),c().registerSeriesType("supertrend",T);let S=s();return i.default})());