UNPKG

highcharts

Version:
18 lines (15 loc) 3.81 kB
/* Highstock JS v8.0.0 (2019-12-10) Indicator series type for Highstock (c) 2010-2019 Wojciech Chmiel License: www.highcharts.com/license */ (function(a){"object"===typeof module&&module.exports?(a["default"]=a,module.exports=a):"function"===typeof define&&define.amd?define("highcharts/indicators/supertrend",["highcharts","highcharts/modules/stock"],function(h){a(h);a.Highcharts=h;return a}):a("undefined"!==typeof Highcharts?Highcharts:void 0)})(function(a){function h(a,v,t,h){a.hasOwnProperty(v)||(a[v]=h.apply(null,t))}a=a?a._modules:{};h(a,"indicators/supertrend.src.js",[a["parts/Globals.js"],a["parts/Utilities.js"]],function(a,h){function t(d, c,a){return{index:c,close:d.yData[c][a],x:d.xData[c]}}var v=h.correctFloat,A=h.isArray,B=h.objectEach,C=a.seriesTypes.atr,z=a.seriesTypes.sma,y=a.merge;a.seriesType("supertrend","sma",{params:{multiplier:3,period:10},risingTrendColor:"#06B535",fallingTrendColor:"#F21313",changeTrendLine:{styles:{lineWidth:1,lineColor:"#333333",dashStyle:"LongDash"}}},{nameBase:"Supertrend",nameComponents:["multiplier","period"],requiredIndicators:["atr"],init:function(){z.prototype.init.apply(this,arguments);var d= this.options;d.cropThreshold=this.linkedParent.options.cropThreshold-(d.params.period-1)},drawGraph:function(){var d=this,c=d.options,a=d.linkedParent,h=a?a.points:[],u=d.points,v=d.graph,q=u.length,r=h.length-q;r=0<r?r:0;for(var x={options:{gapSize:c.gapSize}},l={top:[],bottom:[],intersect:[]},w={top:{styles:{lineWidth:c.lineWidth,lineColor:c.fallingTrendColor||c.color,dashStyle:c.dashStyle}},bottom:{styles:{lineWidth:c.lineWidth,lineColor:c.risingTrendColor||c.color,dashStyle:c.dashStyle}},intersect:c.changeTrendLine}, b,k,e,f,g,m,n,p;q--;)b=u[q],k=u[q-1],e=h[q-1+r],f=h[q-2+r],g=h[q+r],m=h[q+r+1],n=b.options.color,p={x:b.x,plotX:b.plotX,plotY:b.plotY,isNull:!1},!f&&e&&a.yData[e.index-1]&&(f=t(a,e.index-1,3)),!m&&g&&a.yData[g.index+1]&&(m=t(a,g.index+1,3)),!e&&f&&a.yData[f.index+1]?e=t(a,f.index+1,3):!e&&g&&a.yData[g.index-1]&&(e=t(a,g.index-1,3)),b&&e&&g&&f&&b.x!==e.x&&(b.x===g.x?(f=e,e=g):b.x===f.x?(e=f,f={close:a.yData[e.index-1][3],x:a.xData[e.index-1]}):m&&b.x===m.x&&(e=m,f=g)),k&&f&&e?(g={x:k.x,plotX:k.plotX, plotY:k.plotY,isNull:!1},b.y>=e.close&&k.y>=f.close?(b.color=n||c.fallingTrendColor||c.color,l.top.push(p)):b.y<e.close&&k.y<f.close?(b.color=n||c.risingTrendColor||c.color,l.bottom.push(p)):(l.intersect.push(p),l.intersect.push(g),l.intersect.push(y(g,{isNull:!0})),b.y>=e.close&&k.y<f.close?(b.color=n||c.fallingTrendColor||c.color,k.color=n||c.risingTrendColor||c.color,l.top.push(p),l.top.push(y(g,{isNull:!0}))):b.y<e.close&&k.y>=f.close&&(b.color=n||c.risingTrendColor||c.color,k.color=n||c.fallingTrendColor|| c.color,l.bottom.push(p),l.bottom.push(y(g,{isNull:!0}))))):e&&(b.y>=e.close?(b.color=n||c.fallingTrendColor||c.color,l.top.push(p)):(b.color=n||c.risingTrendColor||c.color,l.bottom.push(p)));B(l,function(b,a){d.points=b;d.options=y(w[a].styles,x);d.graph=d["graph"+a+"Line"];z.prototype.drawGraph.call(d);d["graph"+a+"Line"]=d.graph});d.points=u;d.options=c;d.graph=v},getValues:function(a,c){var d=c.period;c=c.multiplier;var h=a.xData,u=a.yData,t=[],q=[],r=[],x=0===d?0:d-1,l=[],w=[],b;if(!(h.length<= d||!A(u[0])||4!==u[0].length||0>d)){a=C.prototype.getValues.call(this,a,{period:d}).yData;for(b=0;b<a.length;b++){var k=u[x+b];var e=u[x+b-1]||[];var f=l[b-1];var g=w[b-1];var m=r[b-1];0===b&&(f=g=m=0);d=v((k[1]+k[2])/2+c*a[b]);var n=v((k[1]+k[2])/2-c*a[b]);l[b]=d<f||e[3]>f?d:f;w[b]=n>g||e[3]<g?n:g;if(m===f&&k[3]<l[b]||m===g&&k[3]<w[b])var p=l[b];else if(m===f&&k[3]>l[b]||m===g&&k[3]>w[b])p=w[b];t.push([h[x+b],p]);q.push(h[x+b]);r.push(p)}return{values:t,xData:q,yData:r}}}});""});h(a,"masters/indicators/supertrend.src.js", [],function(){})}); //# sourceMappingURL=supertrend.js.map