/*
    *
    * Wijmo Library 5.20182.500
    * http://wijmo.com/
    *
    * Copyright(c) GrapeCity, Inc.  All rights reserved.
    *
    * Licensed under the GrapeCity Commercial License.
    * sales@wijmo.com
    * wijmo.com/products/wijmo-5/license/
    *
    */
function isValid(t){return isFinite(t)&&!isNaN(t)&&wjcCore.isNumber(t)}import*as wjcCore from"wijmo/wijmo";import*as wjcChart from"wijmo/wijmo.chart";import*as wjcChartFinance from"wijmo/wijmo.chart.finance";import*as wjcSelfRef from"wijmo/wijmo.chart.finance.analytics";var wjcSelf=wjcSelfRef||exports;window.wijmo=window.wijmo||{},window.wijmo.chart=window.wijmo.chart||{},window.wijmo.chart.finance=window.wijmo.chart.finance||{},window.wijmo.chart.finance.analytics=wjcSelf;export class Fibonacci extends wjcChart.SeriesBase{constructor(t){super(),this._levels=[0,23.6,38.2,50,61.8,100],this._uptrend=!0,this._labelPosition=wjcChart.LabelPosition.Left,this.rendering.addHandler(this._render),this.initialize(t)}get low(){return this._low}set low(t){t!=this._low&&(this._low=wjcCore.asNumber(t,!0),this._invalidate())}get high(){return this._high}set high(t){t!=this._high&&(this._high=wjcCore.asNumber(t,!0),this._invalidate())}get labelPosition(){return this._labelPosition}set labelPosition(t){(t=wjcCore.asEnum(t,wjcChart.LabelPosition,!0))!=this._labelPosition&&(this._labelPosition=t,this._invalidate())}get uptrend(){return this._uptrend}set uptrend(t){t!=this._uptrend&&(this._uptrend=wjcCore.asBoolean(t,!0),this._invalidate())}get levels(){return this._levels}set levels(t){t!=this._levels&&(this._levels=wjcCore.asArray(t,!0),this._invalidate())}get minX(){return this._minX}set minX(t){t!=this._minX&&(this._minX=t,this._invalidate())}get maxX(){return this._maxX}set maxX(t){t!=this._maxX&&(this._maxX=t,this._invalidate())}_getMinX(){return wjcCore.isNumber(this._minX)?this._minX:wjcCore.isDate(this._minX)?wjcCore.asDate(this._minX).valueOf():this._getAxisX().actualMin}_getMaxX(){return wjcCore.isNumber(this._maxX)?this._maxX:wjcCore.isDate(this._maxX)?wjcCore.asDate(this._maxX).valueOf():this._getAxisX().actualMax}_updateLevels(){var t=void 0,e=void 0;if(void 0===this._low||void 0===this._high){var s=super.getValues(0),i=super.getValues(1);if(s)for(var a=s.length,r=this._getMinX(),l=this._getMaxX(),h=0;h<a;h++){var n=s[h],o=i?i[h]:h;o<r||o>l||(isNaN(n)||((void 0===t||t>n)&&(t=n),(void 0===e||e<n)&&(e=n)))}}void 0===this._low&&void 0!==t?this._actualLow=t:this._actualLow=this._low,void 0===this._high&&void 0!==e?this._actualHigh=e:this._actualHigh=this._high}_render(t,e){e.cancel=!0;var s=t;s._updateLevels();var i=s._getAxisX(),a=s._getAxisY(),r=e.engine,l=s._getSymbolStroke(s._chart.series.indexOf(s)),h=wjcChart._BasePlotter.cloneStyle(s.style,["fill"]),n=wjcChart._BasePlotter.cloneStyle(s.style,["stroke"]),o=s.chart._plotrectId;r.stroke=l,r.strokeWidth=2,r.textFill=l;var c=s._getMinX(),_=s._getMaxX();c<i.actualMin&&(c=i.actualMin),_>i.actualMax&&(_=i.actualMax),r.startGroup(null,o);for(var u=s._levels?s._levels.length:0,d=0;d<u;d++){var g=s._levels[d],w=i.convert(c),C=i.convert(_),p=s.uptrend?a.convert(s._actualLow+.01*g*(s._actualHigh-s._actualLow)):a.convert(s._actualHigh-.01*g*(s._actualHigh-s._actualLow));if(wjcChart._DataInfo.isValid(w)&&wjcChart._DataInfo.isValid(C)&&wjcChart._DataInfo.isValid(p)&&(r.drawLine(w,p,C,p,null,h),s.labelPosition!=wjcChart.LabelPosition.None)){var m=g.toFixed(1)+"%",j=0;switch((s.uptrend&&0==d||!s.uptrend&&d==u-1)&&(j=2),s.labelPosition){case wjcChart.LabelPosition.Left:wjcChart.FlexChartCore._renderText(r,m,new wjcCore.Point(w,p),0,j,null,null,n);break;case wjcChart.LabelPosition.Center:wjcChart.FlexChartCore._renderText(r,m,new wjcCore.Point(.5*(w+C),p),1,j,null,null,n);break;case wjcChart.LabelPosition.Right:wjcChart.FlexChartCore._renderText(r,m,new wjcCore.Point(C,p),2,j,null,null,n)}}}r.stroke=null,r.strokeWidth=null,r.textFill=null,r.endGroup()}_getChartType(){return wjcChart.ChartType.Line}};export class FibonacciArcs extends wjcChart.SeriesBase{constructor(t){super(),this._levels=[38.2,50,61.8],this._labelPosition=wjcChart.LabelPosition.Top,this.rendering.addHandler(this._render,this),this.initialize(t)}get start(){return this._start}set start(t){t!==this.start&&(this._start=wjcCore.asType(t,wjcChart.DataPoint),this._invalidate())}get end(){return this._end}set end(t){t!==this.end&&(this._end=wjcCore.asType(t,wjcChart.DataPoint),this._invalidate())}get levels(){return this._levels}set levels(t){t!==this._levels&&(this._levels=wjcCore.asArray(t,!1),this._invalidate())}get labelPosition(){return this._labelPosition}set labelPosition(t){(t=wjcCore.asEnum(t,wjcChart.LabelPosition))!==this.labelPosition&&(this._labelPosition=t,this._invalidate())}_render(t,e){e.cancel=!0;var s=this._getX(0),i=this._getY(0),a=this._getX(1),r=this._getY(1);if(!(super._getLength()<=1)&&isValid(s)&&isValid(i)&&isValid(a)&&isValid(r)){var l,h=this._getAxisX(),n=this._getAxisY(),o=e.engine,c=this.chart.series.indexOf(this),_=this._getSymbolStroke(c),u=wjcChart._BasePlotter.cloneStyle(this.style,["fill"]),d=wjcChart._BasePlotter.cloneStyle(this.style,["stroke"]);o.stroke=_,o.strokeWidth=2,o.textFill=_;var g,w,C,p,m,j,V,v,x,y=this.chart._plotrectId,f=r-i;l=o.startGroup(null,y),wjcCore.addClass(l,"fibonacci-arcs"),isValid(s)&&isValid(i)&&isValid(a)&&isValid(r)&&o.drawLines([h.convert(s),h.convert(a)],[n.convert(i),n.convert(r)],null,u),p=Math.sqrt(Math.pow(h.convert(a)-h.convert(s),2)+Math.pow(n.convert(r)-n.convert(i),2)),j=new wjcCore.Point(a,r);for(var P=0;P<this.levels.length;P++)if(V=.01*this.levels[P],m=Math.abs(p*V),isValid(j.x)&&isValid(j.y)&&isValid(m)&&(g=h.convert(j.x),w=n.convert(j.y),o.drawDonutSegment(g,w,m,m,f>0?0:Math.PI,Math.PI,null,u),this.labelPosition!==wjcChart.LabelPosition.None&&0!==V)){switch(x=wjcCore.Globalize.format(V,"p1"),v=o.measureString(x,null,null,d),C=f<=0?w-m:w+m,this.labelPosition){case wjcChart.LabelPosition.Center:C+=.5*v.height;break;case wjcChart.LabelPosition.Bottom:C+=f<=0?v.height:0;break;default:C+=f<=0?0:v.height}o.drawString(x,new wjcCore.Point(g-.5*v.width,C),null,d)}o.stroke=null,o.strokeWidth=null,o.textFill=null,o.endGroup()}}_getX(t){var e=null;return 0===t&&this.start?e=this.start.x:1===t&&this.end&&(e=this.end.x),wjcCore.isDate(e)&&(e=wjcCore.asDate(e).valueOf()),e}_getY(t){var e=null;return 0===t&&this.start?e=this.start.y:1===t&&this.end&&(e=this.end.y),e}_getChartType(){return wjcChart.ChartType.Line}};export class FibonacciFans extends wjcChart.SeriesBase{constructor(t){super(),this._levels=[0,23.6,38.2,50,61.8,100],this._labelPosition=wjcChart.LabelPosition.Top,this.rendering.addHandler(this._render,this),this.initialize(t)}get start(){return this._start}set start(t){t!==this.start&&(this._start=wjcCore.asType(t,wjcChart.DataPoint),this._invalidate())}get end(){return this._end}set end(t){t!==this.end&&(this._end=wjcCore.asType(t,wjcChart.DataPoint),this._invalidate())}get levels(){return this._levels}set levels(t){t!==this._levels&&(this._levels=wjcCore.asArray(t,!1),this._invalidate())}get labelPosition(){return this._labelPosition}set labelPosition(t){(t=wjcCore.asEnum(t,wjcChart.LabelPosition))!==this.labelPosition&&(this._labelPosition=t,this._invalidate())}_updateLevels(){if(!this.start||!this.end){var t,e,s,i,a=this.chart._getPlotter(this),r=this._getAxisX(),l=super.getValues(0),h=super.getValues(1)||a.dataInfo.getXVals();l&&l.length>0&&(s=wjcChartFinance._minimum(l),i=wjcChartFinance._maximum(l)),h&&h.length>0?(t=wjcChartFinance._minimum(h),e=wjcChartFinance._maximum(h)):(t=r.actualMin,e=r.actualMax),isValid(t)&&isValid(s)&&isValid(e)&&isValid(i)&&(this.start=new wjcChart.DataPoint(t,s),this.end=new wjcChart.DataPoint(e,i))}}_render(t,e){e.cancel=!0,this._updateLevels();var s=this._getX(0),i=this._getY(0),a=this._getX(1),r=this._getY(1);if(!(super._getLength()<=1)&&isValid(s)&&isValid(i)&&isValid(a)&&isValid(r)){var l=this._getAxisX(),h=this._getAxisY(),n=this.chart.series.indexOf(this),o=e.engine,c=this._getSymbolStroke(n),_=wjcChart._BasePlotter.cloneStyle(this.style,["fill"]),u=wjcChart._BasePlotter.cloneStyle(this.style,["stroke"]);o.stroke=c,o.strokeWidth=2,o.textFill=c;var d,g,w,C,p,m,j,V,v,x,y,f,P,k=r-i,b=a-s,L=this.chart._plotrectId;d=s,w=i,C=r;var X=g=a;o.startGroup(null,L);for(var M=0;M<this.levels.length;M++)if(g=b<0?l.actualMin:l.actualMax,x=.01*this.levels[M],C=w+x*k,V=(C-w)/(X-d),v=C-V*X,C=V*g+v,k>0&&C>h.actualMax?g=((C=h.actualMax)-v)/V:k<0&&C<h.actualMin&&(g=((C=h.actualMin)-v)/V),isValid(d)&&isValid(w)&&isValid(g)&&isValid(C)&&(p=new wjcCore.Point(l.convert(d),h.convert(w)),m=new wjcCore.Point(l.convert(g),h.convert(C)),o.drawLines([p.x,m.x],[p.y,m.y],null,_),this.labelPosition!=wjcChart.LabelPosition.None)){y=wjcCore.Globalize.format(x,"p1"),f=o.measureString(y,null,null,u),P=180*Math.atan((m.y-p.y)/(m.x-p.x))/Math.PI,j=m.clone(),m.x=b>0?m.x-f.width:m.x;var B,I=P*Math.PI/180,F=new wjcCore.Point,S=new wjcCore.Point,D=new wjcCore.Point,Y=new wjcCore.Point,A=h.convert(h.actualMin),T=h.convert(h.actualMax),W=l.convert(l.actualMin),O=l.convert(l.actualMax),N=j.clone();switch(this.labelPosition){case wjcChart.LabelPosition.Center:m.y+=.5*f.height,N.y+=.5*f.height;break;case wjcChart.LabelPosition.Bottom:m.y+=f.height}b>0?(this.labelPosition===wjcChart.LabelPosition.Top||this.labelPosition===wjcChart.LabelPosition.Center?(Y=N.clone(),D.x=Y.x+f.height*Math.sin(I),D.y=Y.y-f.height*Math.cos(I),F.x=Y.x-f.width*Math.cos(I)+f.height*Math.sin(I),F.y=Y.y-f.width*Math.sin(I)-f.height*Math.cos(I),S.x=Y.x-f.width*Math.cos(I),S.y=Y.y-f.width*Math.sin(I)):this.labelPosition===wjcChart.LabelPosition.Bottom&&(D=N.clone(),F.x=D.x-f.width*Math.cos(I),F.y=D.y-f.width*Math.sin(I),S.x=F.x-f.height*Math.sin(I),S.y=F.y+f.height*Math.cos(I),Y.x=F.x+f.width*Math.cos(I)-f.height*Math.sin(I),Y.y=F.y+f.width*Math.sin(I)+f.height*Math.cos(I)),k>0?(D.y<T&&(V=(h.convertBack(D.y)-h.convertBack(F.y))/(l.convertBack(D.x)-l.convertBack(F.x)),v=h.convertBack(D.y)-V*l.convertBack(D.x),B=l.convert((h.actualMax-v)/V),m.x-=Math.abs(D.x-B)),Y.x>O&&(m.x-=Math.abs(O-Y.x))):k<0&&(Y.y>A&&(V=(h.convertBack(S.y)-h.convertBack(Y.y))/(l.convertBack(S.x)-l.convertBack(Y.x)),v=h.convertBack(Y.y)-V*l.convertBack(Y.x),B=l.convert((h.actualMin-v)/V),m.x-=Math.max(Math.abs(B-Y.x),Math.abs(A-Y.y))),D.x>O&&(m.x-=Math.abs(O-D.x)))):b<0&&(this.labelPosition===wjcChart.LabelPosition.Top||this.labelPosition===wjcChart.LabelPosition.Center?(S=N.clone(),F.x=S.x+f.height*Math.sin(I),F.y=S.y-f.height*Math.cos(I),Y.x=S.x+f.width*Math.cos(I),Y.y=S.y+f.width*Math.sin(I),D.x=F.x+f.width*Math.cos(I),D.y=F.y+f.width*Math.sin(I)):this.labelPosition===wjcChart.LabelPosition.Bottom&&(F=N.clone(),D.x=F.x+f.width*Math.cos(I),D.y=F.y+f.width*Math.sin(I),S.x=F.x-f.height*Math.sin(I),S.y=F.y+f.height*Math.cos(I),Y.x=F.x+f.width*Math.cos(I)-f.height*Math.sin(I),Y.y=F.y+f.width*Math.sin(I)+f.height*Math.cos(I)),k>0?(F.y<T&&(V=(h.convertBack(F.y)-h.convertBack(D.y))/(l.convertBack(F.x)-l.convertBack(D.x)),v=h.convertBack(F.y)-V*l.convertBack(F.x),B=l.convert((h.actualMax-v)/V),m.x+=Math.abs(F.x-B)),S.x<W&&(m.x+=Math.abs(W-S.x))):k<0&&(S.y>A&&(V=(h.convertBack(Y.y)-h.convertBack(S.y))/(l.convertBack(Y.x)-l.convertBack(S.x)),v=h.convertBack(S.y)-V*l.convertBack(S.x),B=l.convert((h.actualMin-v)/V),m.x+=Math.max(Math.abs(B-S.x),Math.abs(A-S.y))),F.x<W&&(m.x+=Math.abs(W-F.x)))),0===P?o.drawString(y,m,null,u):o.drawStringRotated(y,m,j,P,null,u)}o.stroke=null,o.strokeWidth=null,o.textFill=null,o.endGroup()}}_getX(t){var e=null;return 0===t&&this.start?e=this.start.x:1===t&&this.end&&(e=this.end.x),wjcCore.isDate(e)&&(e=wjcCore.asDate(e).valueOf()),e}_getY(t){var e=null;return 0===t&&this.start?e=this.start.y:1===t&&this.end&&(e=this.end.y),e}_getChartType(){return wjcChart.ChartType.Line}};export class FibonacciTimeZones extends wjcChart.SeriesBase{constructor(t){super(),this._levels=[0,1,2,3,5,8,13,21,34],this._labelPosition=wjcChart.LabelPosition.Right,this.rendering.addHandler(this._render,this),this.initialize(t)}get startX(){return this._startX}set startX(t){t!==this.startX&&(wjcCore.isDate(t)?this._startX=wjcCore.asDate(t):this._startX=wjcCore.asNumber(t),this._invalidate())}get endX(){return this._endX}set endX(t){t!==this.endX&&(wjcCore.isDate(t)?this._endX=wjcCore.asDate(t):this._endX=wjcCore.asNumber(t),this._invalidate())}get levels(){return this._levels}set levels(t){t!==this._levels&&(this._levels=wjcCore.asArray(t,!1),this._invalidate())}get labelPosition(){return this._labelPosition}set labelPosition(t){(t=wjcCore.asEnum(t,wjcChart.LabelPosition))!==this.labelPosition&&(this._labelPosition=t,this._invalidate())}_render(t,e){e.cancel=!0,this._updateLevels();var s=this._getX(0),i=this._getX(1);if(!(super._getLength()<=1)&&isValid(s)&&isValid(i)){var a,r,l,h,n=i-s,o=this._getAxisX(),c=this._getAxisY(),_=this._chart.series.indexOf(this),u=e.engine,d=this._getSymbolStroke(_),g=wjcChart._BasePlotter.cloneStyle(this.style,["fill"]),w=wjcChart._BasePlotter.cloneStyle(this.style,["stroke"]),C=c.convert(c.actualMin),p=c.convert(c.actualMax),m=this.chart._plotrectId;if(u.stroke=d,u.strokeWidth=2,u.textFill=d,0!==n){u.startGroup(null,m);for(var j=0;j<this.levels.length;j++)if(a=this.levels[j],!((r=n*a+s)<o.actualMin||o.actualMax<r)&&isValid(r)&&(r=o.convert(r),u.drawLine(r,C,r,p,null,g),this.labelPosition!==wjcChart.LabelPosition.None)){switch(h=wjcCore.Globalize.format(a,"n0"),l=u.measureString(h,null,null,w),this.labelPosition){case wjcChart.LabelPosition.Left:r-=l.width+2;break;case wjcChart.LabelPosition.Center:r-=l.width/2;break;case wjcChart.LabelPosition.Right:r+=2;break;default:r=n<0?r-l.width-2:r+2}u.drawString(h,new wjcCore.Point(r,C),null,w)}u.stroke=null,u.strokeWidth=null,u.textFill=null,u.endGroup()}}}_updateLevels(){var t=this.chart._getPlotter(this),e=super.getValues(1)||t.dataInfo.getXVals();if(!(super._getLength()<=1)){var s=this._getX(0),i=this._getX(1),a=wjcCore.isNumber(s)&&wjcCore.isNumber(i);a||e?!a&&e&&(this._startX=e[0],this._endX=e[1]):(this._startX=0,this._endX=1)}}_getX(t){var e=null;return 0===t?e=this.startX:1===t&&(e=this.endX),wjcCore.isDate(e)&&(e=wjcCore.asDate(e).valueOf()),e}_getChartType(){return wjcChart.ChartType.Line}};export class OverlayIndicatorBase extends wjcChart.SeriesBase{constructor(t){super(t),this._seriesCount=1}get _hitTester(){return this._plotter&&!this.__hitTester&&(this.__hitTester=this._plotter.hitTester),this.__hitTester}_getChartType(){return wjcChart.ChartType.Line}_getXValues(){return super.getValues(1)||this._plotter.dataInfo.getXVals()}_getDataPoint(t,e,s,i,a,r){var l=new wjcChart._DataPoint(s,i,t,e);return l.y=e,l.yfmt=r._formatValue(e),l.x=t,l.xfmt=a._formatValue(t),l}_shouldCalculate(){return!0}_init(){}_calculate(){}_clearValues(){super._clearValues(),this.__hitTester=null}_getName(t){var e=void 0;if(this.name)if(this.name.indexOf(",")){var s=this.name.split(",");s&&s.length-1>=t&&(e=s[t].trim())}else e=this.name;return e}_getStyles(t){var e=null;if(t<0||null===this._styles)return e;var s=0;for(var i in this._styles){if(s===t&&this._styles.hasOwnProperty(i)){e=this._styles[i];break}s++}return e}legendItemLength(){return this._seriesCount}measureLegendItem(t,e){var s=this._getName(e),i=new wjcCore.Size(0,0);return s&&(i=this._measureLegendItem(t,this._getName(e))),i}drawLegendItem(t,e,s){var i=this._getStyles(s)||this.style;this._getName(s)&&this._drawLegendItem(t,e,this._getChartType(),this._getName(s),i,this.symbolStyle)}};export class SingleOverlayIndicatorBase extends OverlayIndicatorBase{constructor(t){super(t),this._period=14}get period(){return this._period}set period(t){t!==this._period&&(this._period=wjcCore.asInt(t,!1,!0),this._clearValues(),this._invalidate())}getValues(t){var e=null;return super._getLength()<=0?e:(this._shouldCalculate()&&(this._init(),this._calculate()),0===t?e=this._yvals:1===t&&(e=this._xvals),e)}getDataRect(t,e){if(e)return e;var s=null;if(super._getLength()<=0)return s;this._shouldCalculate()&&(this._init(),this._calculate());var i=wjcChartFinance._minimum(this._xvals),a=wjcChartFinance._maximum(this._xvals),r=wjcChartFinance._minimum(this._yvals),l=wjcChartFinance._maximum(this._yvals);return wjcChart._DataInfo.isValid(i)&&wjcChart._DataInfo.isValid(a)&&wjcChart._DataInfo.isValid(r)&&wjcChart._DataInfo.isValid(l)&&(s=new wjcCore.Rect(i,r,a-i,l-r)),s}_clearValues(){super._clearValues(),this._xvals=null,this._yvals=null}_shouldCalculate(){return!this._yvals||!this._xvals}_init(){super._init(),this._yvals=[],this._xvals=[]}_getItem(t){return super._getLength()<=0?super._getItem(t):(this._shouldCalculate()&&(this._init(),this._calculate()),t=super._getLength()-wjcChartFinance._minimum(this._yvals.length,this._xvals.length)+t,super._getItem(t))}};export class ATR extends SingleOverlayIndicatorBase{constructor(t){super(),this.period=14,this.initialize(t)}_calculate(){if(!(super._getLength()<=0)){var t=super._getBindingValues(0),e=super._getBindingValues(1),s=super._getBindingValues(3),i=this._getXValues();this._yvals=wjcChartFinance._avgTrueRng(t,e,s,this.period),this._xvals=i?i.slice(this.period-1):wjcChartFinance._range(this.period-1,t.length)}}};export class CCI extends SingleOverlayIndicatorBase{constructor(t){super(),this._constant=.015,this.period=20,this.initialize(t)}get constant(){return this._constant}set constant(t){t!==this._constant&&(this._constant=wjcCore.asNumber(t,!1),this._clearValues(),this._invalidate())}_calculate(){var t=super._getLength();if(!(t<=0)){var e=super._getBindingValues(0),s=super._getBindingValues(1),i=super._getBindingValues(3),a=this._getXValues();this._yvals=_cci(e,s,i,this.period,this.constant),this._xvals=a?a.slice(this.period-1):wjcChartFinance._range(this.period-1,t-1)}}};export function _cci(t,e,s,i,a){wjcCore.asArray(t,!1),wjcCore.asArray(e,!1),wjcCore.asArray(s,!1),wjcCore.asInt(i,!1,!0),wjcCore.asNumber(a,!1,!0);var r,l,h=wjcChartFinance._minimum(t.length,e.length,s.length),n=[],o=[],c=[];for(wjcCore.assert(h>i&&i>1,"CCI period must be an integer less than the length of the data and greater than one."),l=0;l<h;l++)n.push(wjcChartFinance._average(t[l],e[l],s[l]));r=wjcChartFinance._sma(n,i);var _;for(l=0;l<r.length;l++)_=n.slice(l,i+l).reduce((t,e)=>t+Math.abs(r[l]-e),0),o.push(_/i);for(n.splice(0,i-1),l=0;l<r.length;l++)c.push((n[l]-r[l])/(a*o[l]));return c};export class WilliamsR extends SingleOverlayIndicatorBase{constructor(t){super(),this.period=14,this.initialize(t)}_calculate(){var t=super._getLength();if(!(t<=0)){var e=super._getBindingValues(0),s=super._getBindingValues(1),i=super._getBindingValues(3),a=this._getXValues();this._yvals=_williamsR(e,s,i,this.period),this._xvals=a?a.slice(this.period-1):wjcChartFinance._range(this.period-1,t-1)}}};export function _williamsR(t,e,s,i){wjcCore.asArray(t,!1),wjcCore.asArray(e,!1),wjcCore.asArray(s,!1),wjcCore.asInt(i,!1,!0);var a,r=wjcChartFinance._minimum(t.length,e.length,s.length),l=[],h=[],n=[];for(wjcCore.assert(r>i&&i>1,"Williams %R period must be an integer less than the length of the data and greater than one."),a=i;a<=t.length;a++)l.push(wjcChartFinance._maximum(t.slice(a-i,a))),h.push(wjcChartFinance._minimum(e.slice(a-i,a)));for(s.splice(0,i-1),a=0;a<l.length;a++)n.push((l[a]-s[a])/(l[a]-h[a])*-100);return n};export var MovingAverageType;!function(t){t[t.Simple=0]="Simple",t[t.Exponential=1]="Exponential"}(MovingAverageType||(MovingAverageType={}));export class Envelopes extends OverlayIndicatorBase{constructor(t){super(),this._period=20,this._type=MovingAverageType.Simple,this._size=.025,this.rendering.addHandler(this._rendering,this),this.initialize(t)}get period(){return this._period}set period(t){t!==this._period&&(this._period=wjcCore.asInt(t,!1,!0),this._clearValues(),this._invalidate())}get type(){return this._type}set type(t){(t=wjcCore.asEnum(t,MovingAverageType,!1))!==this._type&&(this._type=t,this._clearValues(),this._invalidate())}get size(){return this._size}set size(t){t!==this._size&&(this._size=wjcCore.asNumber(t,!1,!0),this._clearValues(),this._invalidate())}getDataRect(t,e){if(e)return e;var s=null;if(super._getLength()<=0)return s;this._shouldCalculate()&&(this._init(),this._calculate());var i=this._upperYVals.concat(this._lowerYVals),a=wjcChartFinance._minimum(this._xVals),r=wjcChartFinance._maximum(this._xVals),l=wjcChartFinance._minimum(i),h=wjcChartFinance._maximum(i);return wjcChart._DataInfo.isValid(a)&&wjcChart._DataInfo.isValid(r)&&wjcChart._DataInfo.isValid(l)&&wjcChart._DataInfo.isValid(h)&&(s=new wjcCore.Rect(a,l,r-a,h-l)),s}_clearValues(){super._clearValues(),this._upperYVals=null,this._lowerYVals=null,this._xVals=null}_init(){super._init(),this._upperYVals=[],this._lowerYVals=[],this._xVals=[]}_shouldCalculate(){return!this._upperYVals||!this._lowerYVals||!this._xVals}_calculate(){if(!(super._getLength()<=0)){var t,e=super.getValues(0),s=this._getXValues();switch(this.type){case MovingAverageType.Exponential:t=wjcChartFinance._ema(e,this.period);break;case MovingAverageType.Simple:default:t=wjcChartFinance._sma(e,this.period)}this._xVals=s?s.slice(this.period-1):wjcChartFinance._range(this.period-1,super._getLength()-1),this._upperYVals=t.map(t=>t+t*this.size),this._lowerYVals=t.map(t=>t-t*this.size)}}_rendering(t,e){if(e.cancel=!0,!(super._getLength()<=0)){this._shouldCalculate()&&(this._init(),this._calculate());var s=this.chart.series.indexOf(this),i=e.engine,a=this._getAxisX(),r=this._getAxisY(),l=wjcChartFinance._minimum(this._upperYVals.length,this._lowerYVals.length,this._xVals.length),h=wjcChart._BasePlotter.cloneStyle(this.style,["fill"]),n=this._getSymbolStroke(s),o=this.chart._plotrectId;if(l&&!(l<=0)){i.stroke=n,i.strokeWidth=2;for(var c,_,u,d=[],g=[],w=[],C=this._getLength(),p=0;p<l;p++)u=C-l+p,d.push(a.convert(this._xVals[p])),g.push(r.convert(this._upperYVals[p])),c=this._getDataPoint(this._xVals[p],this._upperYVals[p],s,u,a,r),(_=new wjcChart._CircleArea(new wjcCore.Point(d[p],g[p]),.5*i.strokeWidth)).tag=c,this._hitTester.add(_,s),w.push(r.convert(this._lowerYVals[p])),c=this._getDataPoint(this._xVals[p],this._lowerYVals[p],s,u,a,r),(_=new wjcChart._CircleArea(new wjcCore.Point(d[p],w[p]),.5*i.strokeWidth)).tag=c,this._hitTester.add(_,s);this._hitTester.add(new wjcChart._LinesArea(d,g),s),this._hitTester.add(new wjcChart._LinesArea(d,w),s),i.drawLines(d,g,null,h,o),i.drawLines(d,w,null,h,o)}}}getCalculatedValues(t){t=wjcCore.asString(t,!1);var e=[],s=0;if(super._getLength()<=0)return e;switch(this._shouldCalculate()&&(this._init(),this._calculate()),t){case"upperEnvelope":for(;s<this._upperYVals.length;s++)e.push({x:this._xVals[s],y:this._upperYVals[s]});break;case"lowerEnvelope":for(;s<this._lowerYVals.length;s++)e.push({x:this._xVals[s],y:this._lowerYVals[s]})}return e}};export class BollingerBands extends OverlayIndicatorBase{constructor(t){super(),this._period=20,this._multiplier=2,this.rendering.addHandler(this._rendering,this),this.initialize(t)}get period(){return this._period}set period(t){t!==this._period&&(this._period=wjcCore.asInt(t,!1,!0),this._clearValues(),this._invalidate())}get multiplier(){return this._multiplier}set multiplier(t){t!==this._multiplier&&(this._multiplier=wjcCore.asNumber(t,!1,!0),this._clearValues(),this._invalidate())}getDataRect(t,e){if(e)return e;if(super._getLength()<=0)return null;this._shouldCalculate()&&(this._init(),this._calculate());var s=this._upperYVals.concat(this._lowerYVals),i=wjcChartFinance._minimum(this._xVals),a=wjcChartFinance._maximum(this._xVals),r=wjcChartFinance._minimum(s),l=wjcChartFinance._maximum(s);return wjcChart._DataInfo.isValid(i)&&wjcChart._DataInfo.isValid(a)&&wjcChart._DataInfo.isValid(r)&&wjcChart._DataInfo.isValid(l)?new wjcCore.Rect(i,r,a-i,l-r):null}_clearValues(){super._clearValues(),this._upperYVals=null,this._middleYVals=null,this._lowerYVals=null,this._xVals=null}_shouldCalculate(){return!(this._upperYVals&&this._middleYVals&&this._lowerYVals&&this._xVals)}_init(){super._init(),this._upperYVals=[],this._middleYVals=[],this._lowerYVals=[],this._xVals=[]}_calculate(){var t=super._getLength();if(!(t<=0)){var e=super.getValues(0),s=this._getXValues(),i=_bollingerBands(e,this.period,this.multiplier);this._upperYVals=i.uppers,this._middleYVals=i.middles,this._lowerYVals=i.lowers,this._xVals=s?s.slice(this.period-1):wjcChartFinance._range(this.period-1,t-1)}}_rendering(t,e){if(e.cancel=!0,!(super._getLength()<=0)){this._shouldCalculate()&&(this._init(),this._calculate());var s=this.chart.series.indexOf(this),i=e.engine,a=this._getAxisX(),r=this._getAxisY(),l=wjcChartFinance._minimum(this._upperYVals.length,this._middleYVals.length,this._lowerYVals.length,this._xVals.length),h=wjcChart._BasePlotter.cloneStyle(this.style,["fill"]),n=this._getSymbolStroke(s),o=this.chart._plotrectId;if(l&&!(l<=0)){i.stroke=n,i.strokeWidth=2;for(var c,_,u,d=[],g=[],w=[],C=[],p=this._getLength(),m=0;m<l;m++)u=p-l+m,d.push(a.convert(this._xVals[m])),g.push(r.convert(this._upperYVals[m])),c=this._getDataPoint(this._xVals[m],this._upperYVals[m],s,u,a,r),(_=new wjcChart._CircleArea(new wjcCore.Point(d[m],g[m]),.5*i.strokeWidth)).tag=c,this._hitTester.add(_,s),w.push(r.convert(this._middleYVals[m])),c=this._getDataPoint(this._xVals[m],this._middleYVals[m],s,u,a,r),(_=new wjcChart._CircleArea(new wjcCore.Point(d[m],w[m]),.5*i.strokeWidth)).tag=c,this._hitTester.add(_,s),C.push(r.convert(this._lowerYVals[m])),c=this._getDataPoint(this._xVals[m],this._lowerYVals[m],s,u,a,r),(_=new wjcChart._CircleArea(new wjcCore.Point(d[m],C[m]),.5*i.strokeWidth)).tag=c,this._hitTester.add(_,s);this._hitTester.add(new wjcChart._LinesArea(d,g),s),this._hitTester.add(new wjcChart._LinesArea(d,w),s),this._hitTester.add(new wjcChart._LinesArea(d,C),s),i.drawLines(d,g,null,h,o),i.drawLines(d,w,null,h,o),i.drawLines(d,C,null,h,o)}}}getCalculatedValues(t){t=wjcCore.asString(t,!1);var e=[],s=0;if(super._getLength()<=0)return e;switch(this._shouldCalculate()&&(this._init(),this._calculate()),t){case"upperBand":for(;s<this._upperYVals.length;s++)e.push({x:this._xVals[s],y:this._upperYVals[s]});break;case"middleBand":for(;s<this._middleYVals.length;s++)e.push({x:this._xVals[s],y:this._middleYVals[s]});break;case"lowerBand":for(;s<this._lowerYVals.length;s++)e.push({x:this._xVals[s],y:this._lowerYVals[s]})}return e}};export function _bollingerBands(t,e,s){wjcCore.asArray(t,!1),wjcCore.asInt(e,!1,!0),wjcCore.asNumber(s,!1,!0),wjcCore.assert(t.length>e&&e>1,"Bollinger Bands period must be an integer less than the length of the data and greater than one.");var i,a=wjcChartFinance._sma(t,e),r=[];for(i=e;i<=t.length;i++)r.push(wjcChartFinance._stdDeviation(t.slice(i-e,i)));var l=a,h=a.map((t,e)=>t+r[e]*s);return{lowers:a.map((t,e)=>t-r[e]*s),middles:l,uppers:h}};export class RSI extends SingleOverlayIndicatorBase{constructor(t){super(),this.period=14,this.initialize(t)}_calculate(){var t=super._getLength();if(!(t<=0)){var e=super._getBindingValues(0),s=this._getXValues();this._yvals=_rsi(e,this.period),this._xvals=s?s.slice(this.period):wjcChartFinance._range(this.period,t)}}};export function _rsi(t,e){wjcCore.asArray(t,!1),wjcCore.asInt(e,!0,!1),wjcCore.assert(t.length>e&&e>1,"RSI period must be an integer less than the length of the data and greater than one.");var s,i,a,r,l=[],h=[],n=[],o=[];for(r=1;r<t.length;r++)l.push(t[r]-t[r-1]);for(s=l.map(t=>t>0?t:0),i=l.map(t=>t<0?Math.abs(t):0),r=e;r<=l.length;r++)r===e?(h.push(wjcChartFinance._sum(s.slice(r-e,r))/e),n.push(wjcChartFinance._sum(i.slice(r-e,r))/e)):(h.push((s[r-1]+h[r-e-1]*(e-1))/e),n.push((i[r-1]+n[r-e-1]*(e-1))/e)),a=h[r-e]/n[r-e],a=isFinite(a)?a:0,o.push(100-100/(1+a));return o};export class MacdBase extends OverlayIndicatorBase{constructor(t){super(t),this._fastPeriod=12,this._slowPeriod=26,this._smoothingPeriod=9}get fastPeriod(){return this._fastPeriod}set fastPeriod(t){t!==this._fastPeriod&&(this._fastPeriod=wjcCore.asInt(t,!1,!0),this._clearValues(),this._invalidate())}get slowPeriod(){return this._slowPeriod}set slowPeriod(t){t!==this._slowPeriod&&(this._slowPeriod=wjcCore.asInt(t,!1,!0),this._clearValues(),this._invalidate())}get smoothingPeriod(){return this._smoothingPeriod}set smoothingPeriod(t){t!==this._smoothingPeriod&&(this._smoothingPeriod=wjcCore.asInt(t,!1,!0),this._clearValues(),this._invalidate())}_clearValues(){super._clearValues(),this._macdVals=null,this._macdXVals=null,this._signalVals=null,this._signalXVals=null,this._histogramVals=null,this._histogramXVals=null}_shouldCalculate(){return!(this._macdVals&&this._macdXVals&&this._signalVals&&this._signalXVals&&this._histogramVals&&this._histogramXVals)}_init(){super._init(),this._macdVals=[],this._macdXVals=[],this._signalVals=[],this._signalXVals=[],this._histogramVals=[],this._histogramXVals=[]}_calculate(){var t=super._getLength();if(!(t<=0)){var e=super.getValues(0),s=this._getXValues(),i=_macd(e,this.fastPeriod,this.slowPeriod,this.smoothingPeriod);this._macdVals=i.macds,this._signalVals=i.signals,this._histogramVals=i.histograms,this._macdXVals=s?s.slice(t-this._macdVals.length,t):wjcChartFinance._range(t-this._macdVals.length,t-1),this._signalXVals=s?s.slice(t-this._signalVals.length,t):wjcChartFinance._range(t-this._signalVals.length,t-1),this._histogramXVals=s?s.slice(t-this._histogramVals.length,t):wjcChartFinance._range(t-this._histogramVals.length,t-1)}}};export class Macd extends MacdBase{constructor(t){super(),this._seriesCount=2,this.rendering.addHandler(this._rendering,this),this.initialize(t)}get styles(){return this._styles}set styles(t){t!==this._styles&&(this._styles=t,this._invalidate())}getDataRect(t,e){if(e)return e;var s=null;if(super._getLength()<=0)return s;this._shouldCalculate()&&(this._init(),this._calculate());var i=[],a=[];a.push.apply(a,this._macdXVals),a.push.apply(a,this._signalXVals),i.push.apply(i,this._macdVals),i.push.apply(i,this._signalVals);var r=wjcChartFinance._minimum(a),l=wjcChartFinance._maximum(a),h=wjcChartFinance._minimum(i),n=wjcChartFinance._maximum(i);return wjcChart._DataInfo.isValid(r)&&wjcChart._DataInfo.isValid(l)&&wjcChart._DataInfo.isValid(h)&&wjcChart._DataInfo.isValid(n)&&(s=new wjcCore.Rect(r,h,l-r,n-h)),s}_rendering(t,e){if(e.cancel=!0,!(super._getLength()<=0)){this._shouldCalculate()&&(this._init(),this._calculate());var s=this.chart.series.indexOf(this),i=e.engine,a=this._getAxisX(),r=this._getAxisY(),l=wjcChart._BasePlotter.cloneStyle(this.style,["fill"]),h=this._getSymbolStroke(s),n=this.chart._plotrectId,o=null,c=h,_=2,u=null,d=h,g=2;this.styles&&wjcCore.isObject(this.styles)&&(this.styles.macdLine&&wjcCore.isObject(this.styles.macdLine)&&(c=(o=wjcChart._BasePlotter.cloneStyle(this.styles.macdLine,["fill"])).stroke?o.stroke:h,_=o.strokeWidth?o.strokeWidth:2),this.styles.signalLine&&wjcCore.isObject(this.styles.signalLine)&&(d=(u=wjcChart._BasePlotter.cloneStyle(this.styles.signalLine,["fill"])).stroke?u.stroke:h,g=u.strokeWidth?u.strokeWidth:2));var w,C,p,m,j=[],V=[],v=[],x=[],y=this._getLength();for(p=0;p<this._macdVals.length;p++)m=y-this._macdVals.length+p,V.push(a.convert(this._macdXVals[p])),j.push(r.convert(this._macdVals[p])),(w=this._getDataPoint(this._macdXVals[p],this._macdVals[p],s,m,a,r)).name=this._getName(0),(C=new wjcChart._CircleArea(new wjcCore.Point(V[p],j[p]),.5*i.strokeWidth)).tag=w,this._hitTester.add(C,s);for(this._hitTester.add(new wjcChart._LinesArea(V,j),s),i.stroke=c,i.strokeWidth=_,i.drawLines(V,j,null,l,n),p=0;p<this._signalVals.length;p++)m=y-this._signalVals.length+p,x.push(a.convert(this._signalXVals[p])),v.push(r.convert(this._signalVals[p])),(w=this._getDataPoint(this._signalXVals[p],this._signalVals[p],s,m,a,r)).name=this._getName(1),(C=new wjcChart._CircleArea(new wjcCore.Point(x[p],v[p]),.5*i.strokeWidth)).tag=w,this._hitTester.add(C,s);this._hitTester.add(new wjcChart._LinesArea(x,v),s),i.stroke=d,i.strokeWidth=g,i.drawLines(x,v,null,l,n)}}getCalculatedValues(t){t=wjcCore.asString(t,!1);var e=[],s=0;if(super._getLength()<=0)return e;switch(this._shouldCalculate()&&(this._init(),this._calculate()),t){case"macdLine":for(;s<this._macdVals.length;s++)e.push({x:this._macdXVals[s],y:this._macdVals[s]});break;case"signalLine":for(;s<this._signalVals.length;s++)e.push({x:this._signalXVals[s],y:this._signalVals[s]})}return e}};export class MacdHistogram extends MacdBase{constructor(t){super(t)}getValues(t){var e=null;return super._getLength()<=0?e:(this._shouldCalculate()&&(this._init(),this._calculate()),0===t?e=this._histogramVals:1===t&&(e=this._histogramXVals),e)}getDataRect(t,e){if(e)return e;var s=null;if(super._getLength()<=0)return s;this._shouldCalculate()&&(this._init(),this._calculate());var i=wjcChartFinance._minimum(this._histogramXVals),a=wjcChartFinance._maximum(this._histogramXVals),r=wjcChartFinance._minimum(this._histogramVals),l=wjcChartFinance._maximum(this._histogramVals);return wjcChart._DataInfo.isValid(i)&&wjcChart._DataInfo.isValid(a)&&wjcChart._DataInfo.isValid(r)&&wjcChart._DataInfo.isValid(l)&&(s=new wjcCore.Rect(i,r,a-i,l-r)),s}_getChartType(){return wjcChart.ChartType.Column}_getItem(t){return t=super._getLength()-wjcChartFinance._minimum(this._histogramVals.length,this._histogramXVals.length)+t,super._getItem(t)}};export function _macd(t,e,s,i){wjcCore.asArray(t,!1),wjcCore.asInt(e,!1,!0),wjcCore.asInt(s,!1,!0),wjcCore.asInt(i,!1,!0);var a,r=e>s;r&&(a=s,s=e,e=a);var l,h,n=wjcChartFinance._ema(t,e),o=wjcChartFinance._ema(t,s),c=[],_=[];for(n.splice(0,s-e),h=0;h<n.length;h++)a=n[h]-o[h],r&&(a*=-1),c.push(a);l=wjcChartFinance._ema(c,i);var u=c.slice(c.length-l.length,c.length);for(h=0;h<u.length;h++)_.push(u[h]-l[h]);return{macds:c,signals:l,histograms:_}};export class Stochastic extends OverlayIndicatorBase{constructor(t){super(),this._kPeriod=14,this._dPeriod=3,this._smoothingPeriod=1,this._seriesCount=2,this.rendering.addHandler(this._rendering,this),this.initialize(t)}get kPeriod(){return this._kPeriod}set kPeriod(t){t!==this._kPeriod&&(this._kPeriod=wjcCore.asInt(t,!1,!0),this._clearValues(),this._invalidate())}get dPeriod(){return this._dPeriod}set dPeriod(t){t!==this._dPeriod&&(this._dPeriod=wjcCore.asInt(t,!1,!0),this._clearValues(),this._invalidate())}get smoothingPeriod(){return this._smoothingPeriod}set smoothingPeriod(t){t!==this._smoothingPeriod&&(this._smoothingPeriod=wjcCore.asInt(t,!1,!0),this._clearValues(),this._invalidate())}get styles(){return this._styles}set styles(t){t!==this._styles&&(this._styles=t,this._invalidate())}getDataRect(t,e){if(e)return e;var s=null;if(super._getLength()<=0)return s;this._shouldCalculate()&&(this._init(),this._calculate());var i=this._kVals.concat(this._dVals),a=this._kXVals.concat(this._dXVals),r=wjcChartFinance._minimum(a),l=wjcChartFinance._maximum(a),h=wjcChartFinance._minimum(i),n=wjcChartFinance._maximum(i);return wjcChart._DataInfo.isValid(r)&&wjcChart._DataInfo.isValid(l)&&wjcChart._DataInfo.isValid(h)&&wjcChart._DataInfo.isValid(n)&&(s=new wjcCore.Rect(r,h,l-r,n-h)),s}_clearValues(){super._clearValues(),this._kVals=null,this._kXVals=null,this._dVals=null,this._dXVals=null}_shouldCalculate(){return!(this._kVals&&this._kXVals&&this._dVals&&this._dXVals)}_init(){super._init(),this._kVals=[],this._kXVals=[],this._dVals=[],this._dXVals=[]}_calculate(){var t=super._getLength();if(!(super._getLength()<=0)){var e=super._getBindingValues(0),s=super._getBindingValues(1),i=super._getBindingValues(3),a=this._getXValues(),r=_stochastic(e,s,i,this.kPeriod,this.dPeriod,this.smoothingPeriod);this._kVals=r.ks,this._dVals=r.ds,this._kXVals=a?a.slice(this.kPeriod-1):wjcChartFinance._range(this.kPeriod-1,t-1),this.smoothingPeriod&&this.smoothingPeriod>1&&(this._kXVals=this._kXVals.slice(this._kXVals.length-this._kVals.length,this._kXVals.length)),this._dXVals=this._kXVals.slice(this._kXVals.length-this._dVals.length,this._kXVals.length)}}_rendering(t,e){if(e.cancel=!0,!(super._getLength()<=0)){this._shouldCalculate()&&(this._init(),this._calculate());var s=this.chart.series.indexOf(this),i=e.engine,a=this._getAxisX(),r=this._getAxisY(),l=wjcChart._BasePlotter.cloneStyle(this.style,["fill"]),h=this._getSymbolStroke(s),n=this.chart._plotrectId,o=null,c=h,_=2,u=null,d=h,g=2;this.styles&&wjcCore.isObject(this.styles)&&(this.styles.kLine&&wjcCore.isObject(this.styles.kLine)&&(c=(o=wjcChart._BasePlotter.cloneStyle(this.styles.kLine,["fill"])).stroke?o.stroke:h,_=o.strokeWidth?o.strokeWidth:2),this.styles.dLine&&wjcCore.isObject(this.styles.dLine)&&(d=(u=wjcChart._BasePlotter.cloneStyle(this.styles.dLine,["fill"])).stroke?u.stroke:h,g=u.strokeWidth?u.strokeWidth:2));var w,C,p,m,j=[],V=[],v=[],x=[],y=this._getLength();for(p=0;p<this._kVals.length;p++)m=y-this._kVals.length+p,V.push(a.convert(this._kXVals[p])),j.push(r.convert(this._kVals[p])),(w=this._getDataPoint(this._kXVals[p],this._kVals[p],s,m,a,r)).name=this._getName(0),(C=new wjcChart._CircleArea(new wjcCore.Point(V[p],j[p]),.5*i.strokeWidth)).tag=w,this._hitTester.add(C,s);for(this._hitTester.add(new wjcChart._LinesArea(V,j),s),i.stroke=c,i.strokeWidth=_,i.drawLines(V,j,null,l,n),p=0;p<this._dVals.length;p++)m=y-this._dVals.length+p,x.push(a.convert(this._dXVals[p])),v.push(r.convert(this._dVals[p])),(w=this._getDataPoint(this._dXVals[p],this._dVals[p],s,m,a,r)).name=this._getName(1),(C=new wjcChart._CircleArea(new wjcCore.Point(x[p],v[p]),.5*i.strokeWidth)).tag=w,this._hitTester.add(C,s);this._hitTester.add(new wjcChart._LinesArea(x,v),s),i.stroke=d,i.strokeWidth=g,i.drawLines(x,v,null,l,n)}}getCalculatedValues(t){t=wjcCore.asString(t,!1);var e=[],s=0;if(super._getLength()<=0)return e;switch(this._shouldCalculate()&&(this._init(),this._calculate()),t){case"kLine":for(;s<this._kVals.length;s++)e.push({x:this._kXVals[s],y:this._kVals[s]});break;case"dLine":for(;s<this._dVals.length;s++)e.push({x:this._dXVals[s],y:this._dVals[s]})}return e}};export function _stochastic(t,e,s,i,a,r){wjcCore.asArray(t,!1),wjcCore.asArray(e,!1),wjcCore.asArray(s,!1),wjcCore.asInt(i,!1,!0),wjcCore.asInt(a,!1,!0),wjcCore.asInt(r,!0,!0);var l,h,n=[],o=[],c=[];for(h=i;h<=t.length;h++)n.push(wjcChartFinance._maximum(t.slice(h-i,h))),o.push(wjcChartFinance._minimum(e.slice(h-i,h)));for(s=s.slice(i-1),h=0;h<s.length;h++)c.push((s[h]-o[h])/(n[h]-o[h])*100);return r&&r>1&&(c=wjcChartFinance._sma(c,r)),l=wjcChartFinance._sma(c,a),{ks:c,ds:l}};