Release v23.041 (from 1c4a7b40)
Fixes tradingview/charting_library#6864
This commit is contained in:
@@ -12,38 +12,38 @@ this._availableAreas=["left","tradingpanel","right","top","bottom","center","top
|
||||
89356:(e,t,i)=>{"use strict";i.d(t,{Root:()=>d});i(28353);var s=i(52714),r=i.n(s),n=i(31940);class o{constructor(e){this._document=e,this.isFullscreen=new(r());const t=()=>{const e=["fullscreenElement","webkitFullscreenElement","mozFullscreenElement","mozFullScreenElement","msFullscreenElement"];for(let t=0;t<e.length;t++){const i=e[t];if(i in this._document){this.isFullscreen.setValue(!!this._document[i]);break}}};t();for(const i of["fullscreenchange","webkitfullscreenchange","mozfullscreenchange","MSFullscreenChange"])e.addEventListener(i,t,!1)}enter(){const e=this._document.documentElement;for(const t of["requestFullscreen","mozRequestFullScreen","webkitRequestFullscreen","msRequestFullscreen"])if("function"==typeof e[t]){e[t]();break}this.isFullscreen.setValue(!0)}exit(){const e=this._document;for(const t of["exitFullscreen","mozCancelFullScreen","mozExitFullscreen","webkitExitFullscreen","msExitFullscreen"])if("function"==typeof e[t]){e[t]();break}this.isFullscreen.setValue(!1)}}class a{constructor(e){let t;this.isVisible=new(r())(!0);let i=null;for(const s of["","moz","ms","webkit"]){const r=s?s+"Hidden":"hidden";if(r in e){t=s+"visibilitychange",i=()=>{this.isVisible.setValue(!e[r])},i(),e.addEventListener(t,i,!1);break}}this.destroy=()=>{i&&(e.removeEventListener(t,i,!1),i=null)}}}var l=i(84015),c=i(88537),h=i(49483);class d{constructor(e){this._updateDocumentHeight=e=>{"visual"===this._viewportType&&this._window.document.documentElement.style.setProperty("height",e+"px","important")},this._window=e,this._fullscreenApi=new o(e.document),this._viewportType=h.CheckMobile.iOS()&&!(0,l.isOnMobileAppPage)("any")&&this._window.visualViewport?"visual":"quirks","visual"===this._viewportType?this._viewport=(0,c.ensureDefined)(this._window.visualViewport):this._viewport=this._window;const t=this._layoutSizeSensor=this._window.document.createElement("div");t.id="layout-size-sensor",t.style.position="fixed",t.style.top="0",t.style.left="0",t.style.right="0",t.style.bottom="0",t.style.pointerEvents="none",t.style.visibility="hidden",this._initFullscreen()}allocate(){this.free();const e=this._window.document,t=e.createElement("div");t.classList.add("js-rootresizer__contents"),t.style.position="relative",t.style.width="100%",t.style.height="100%",e.body.insertAdjacentElement("afterbegin",t),e.body.insertAdjacentElement("afterbegin",this._layoutSizeSensor),this._visibilityApi=new a(this._window.document);const i={alive:new(r())(!0),fullscreenable:new(r())(!0),container:new(r())(t),width:new(r()),height:new(r()),availWidth:new(r()),availHeight:new(r()),visible:this._visibilityApi.isVisible,fullscreen:this._fullscreenApi.isFullscreen,remove:()=>{i.alive.setValue(!1)},attach:()=>{i.alive.setValue(!1),this._window.close()},requestFullscreen:()=>{this._requestFullscreen()},exitFullscreen:()=>{this._exitFullscreen()}};return i.alive.subscribe(e=>{e||i!==this._area||this.free()}),this._area=i,this._resizeHandler=()=>{const e=this._width(i)||800,t=this._height(i)||600;i.availHeight.setValue(t),i.availWidth.setValue(e),
|
||||
i.height.setValue(t),i.width.setValue(e)},this._area.height.subscribe(this._updateDocumentHeight,{callWithLast:!0}),this._resizeHandler(),this._viewport.addEventListener("resize",this._resizeHandler),new n.ResizerDetacherState(i).bridge()}free(){if(this._resizeHandler&&(this._viewport.removeEventListener("resize",this._resizeHandler),this._resizeHandler=void 0),this._visibilityApi&&(this._visibilityApi.destroy(),this._visibilityApi=void 0),this._area){const e=this._area;this._area=void 0,e.height.unsubscribe(this._updateDocumentHeight),e.alive.setValue(!1);const t=e.container.value(),i=null==t?void 0:t.parentElement;i&&(i.removeChild(t),i.removeChild(this._layoutSizeSensor))}}_height(e){if("visual"===this._viewportType)return this._layoutSizeSensor.clientHeight;return e.container.value().clientHeight}_width(e){return e.container.value().clientWidth}_requestFullscreen(){this._fullscreenApi.enter()}_exitFullscreen(){this._fullscreenApi.exit()}_initFullscreen(){this._fullscreenApi.isFullscreen.subscribe(e=>{this._resizeHandler&&this._resizeHandler()})}}},33134:(e,t,i)=>{"use strict";i.d(t,{DEFAULT_SIZE:()=>s,spinnerSizeMap:()=>r});const s="large",r={mini:"xsmall",xsmall:"xsmall",small:"small",medium:"medium",large:"large"}},4185:(e,t,i)=>{"use strict";i.d(t,{Spinner:()=>o});i(24780);var s=i(62046),r=i(33134);const n=(0,s.parseHtmlElement)(function(e=""){return`<div class="tv-spinner ${e}" role="progressbar"></div>`}());class o{constructor(e){this._shown=!1,this._el=n.cloneNode(!0),this.setSize(r.spinnerSizeMap[e||r.DEFAULT_SIZE])}spin(e){return this._el.classList.add("tv-spinner--shown"),void 0===this._container&&(this._container=e,void 0!==e&&e.appendChild(this._el)),this._shown=!0,this}stop(e){return e&&void 0!==this._container&&this._container.removeChild(this._el),this._el.classList.remove("tv-spinner--shown"),this._shown=!1,this}setStyle(e){return Object.keys(e).forEach(t=>{const i=e[t];void 0!==i&&this._el.style.setProperty(t,i)}),this}style(){return this._el.style}setSize(e){const t=void 0!==e?"tv-spinner--size_"+e:"";return this._el.className=`tv-spinner ${t} ${this._shown?"tv-spinner--shown":""}`,this}getEl(){return this._el}destroy(){this.stop(),delete this._el,delete this._container}}},5683:(e,t,i)=>{"use strict";i.d(t,{createStubElem:()=>r});var s=i(65592);function r(e=[],t=[]){const i=document.createElement("div"),r=document.createElement("div");return i.appendChild(r),i.classList.add(s.container),r.classList.add(s.inner),e.forEach(e=>{i.classList.add(s[e])}),t.forEach(e=>{i.classList.add(s[e])}),i}},45973:(e,t,i)=>{"use strict";i.r(t),i.d(t,{lineToolEntityInfo:()=>o,studyEntityInfo:()=>a,seriesEntityInfo:()=>l,entityForDataSource:()=>c});var s=i(81851),r=i(16906),n=i(14291);function o(e){return{id:e.id(),name:(t=e.toolname,Object.keys(r.supportedLineTools).find(e=>r.supportedLineTools[e].name===t)||null)};var t}function a(e){return{id:e.id(),name:e.metaInfo().description}}function l(e){return{id:e.id(),name:"Main Series"}}function c(e,t){return t===e.mainSeries()?l(e.mainSeries()):(0,s.isStudy)(t)?a(t):(0,
|
||||
n.isLineTool)(t)?o(t):null}},68582:(e,t,i)=>{"use strict";i.r(t),i.d(t,{isLineToolRiskReward:()=>a,LineDataSourceApi:()=>c});var s=i(88537),r=i(80643);const n=new Map([["LineToolRiskRewardLong",2],["LineToolRiskRewardShort",2],["LineToolBezierQuadro",3],["LineToolBezierCubic",4]]);function o(e){const t=n.get(e.toolname);if(void 0!==t)return t;const i=e.pointsCount();return-1===i?e.points().length:i}function a(e){return"LineToolRiskRewardLong"===e||"LineToolRiskRewardShort"===e}const l=["alwaysShowStats","entryPrice","inputs.first bar time","inputs.last bar time","interval","linesWidths","points","snapTo45Degrees","stopPrice","symbol","symbolStateVersion","currencyId","unitId","targetPrice","zOrderVersion"];class c{constructor(e,t,i){this._source=e,this._undoModel=t,this._model=t.model(),this._pointsConverter=i}isSelectionEnabled(){return this._source.isSelectionEnabled()}setSelectionEnabled(e){this._source.setSelectionEnabled(e)}isSavingEnabled(){return this._source.isSavedInChart()}setSavingEnabled(e){this._source.setSavingInChartEnabled(e)}isShowInObjectsTreeEnabled(){return this._source.showInObjectTree()}setShowInObjectsTreeEnabled(e){this._source.setShowInObjectsTreeEnabled(e)}isUserEditEnabled(){return this._source.userEditEnabled()}setUserEditEnabled(e){this._source.setUserEditEnabled(e)}bringToFront(){this._model.bringToFront([this._source])}sendToBack(){this._model.sendToBack([this._source])}getProperties(){return this._source.properties().state(l,!0)}setProperties(e){this._setProps(this._source.properties(),e,"")}getPoints(){let e=this._source.points();const t=o(this._source);return e.length>t&&((0,s.assert)(a(this._source.toolname)),e=e.slice(0,t)),this._pointsConverter.dataSourcePointsToPriced(e)}setPoints(e){if(this._source.isFixed())return;const t=o(this._source);if(t!==e.length)throw new Error(`Wrong points count. Required: ${t}, provided: ${e.length}`);const i=this._pointsConverter.apiPointsToDataSource(e);this._model.startChangingLinetool(this._source),this._model.changeLinePoints(this._source,i),this._model.endChangingLinetool(!0),this._source.createServerPoints()}ownerSourceId(){return(0,s.ensureNotNull)(this._source.ownerSource()).id()}changePoint(e,t){if(this._source.isFixed())return;const i=this._pointsConverter.apiPointsToDataSource([e])[0];this._model.startChangingLinetool(this._source,{...i},t),this._model.changeLinePoint({...i}),this._model.endChangingLinetool(!1),this._source.createServerPoints()}isHidden(){return this._source.isSourceHidden()}getRawPoints(){return this._source.points()}setRawPoint(e,t){this._model.startChangingLinetool(this._source,{...t},e),this._model.changeLinePoint({...t}),this._model.endChangingLinetool(!1)}move(e,t){this._model.startMovingSources([this._source],{logical:e},null,new Map),this._model.moveSources({logical:t},new Map),this._model.endMovingSources(!1)}dataAndViewsReady(){return this._source.dataAndViewsReady()}zorder(){return this._source.zorder()}symbol(){return this._source.properties().symbol.value()}currency(){
|
||||
return this._source.properties().currencyId.value()}unit(){return this._source.properties().unitId.value()}share(e){this._undoModel.shareLineTools([this._source],e)}sharingMode(){return this._source.sharingMode().value()}_setProps(e,t,i){for(const s in t){if(!t.hasOwnProperty(s))continue;const n=0===i.length?s:`${i}.${s}`;if(e.hasOwnProperty(s)){const i=t[s];(0,r.isHashObject)(i)?this._setProps(e[s],i,n):e[s].setValue(i)}else console.warn(`Unknown property "${n}"`)}}}},56233:(e,t,i)=>{"use strict";i.d(t,{PaneApi:()=>u});var s=i(88537),r=i(42534),n=i(45973),o=i(80643),a=i(28353),l=i(24980),c=i(35762);const h=new l.TranslatedString("change pane height",(0,a.t)("change pane height"));class d extends c.UndoCommand{constructor(e,t,i){super(h),this._model=e,this._paneIndex=t,this._paneHeight=i,this._prevStretchFactors=this._model.panes().map(e=>e.stretchFactor())}redo(){this._model.changePanesHeight(this._paneIndex,this._paneHeight)}undo(){const e=this._model.panes();for(let t=0;t<e.length;++t)e[t].setStretchFactor((0,s.ensureDefined)(this._prevStretchFactors[t]));this._model.fullUpdate()}}class u{constructor(e,t){this._priceScales=new WeakMap,this._pane=e,this._chartWidget=t}hasMainSeries(){return this._pane.containsMainSeries()}getLeftPriceScales(){return this._pane.leftPriceScales().map(this._getPriceScaleApi,this)}getRightPriceScales(){return this._pane.rightPriceScales().map(this._getPriceScaleApi,this)}getMainSourcePriceScale(){const e=this._pane.mainDataSource();if(null===e)return null;const t=e.priceScale();return null===t||this._pane.isOverlay(e)?null:this._getPriceScaleApi(t)}setMaximized(e){if(this._pane.maximized().value()!==e)for(const e of this._chartWidget.paneWidgets())if(e.state()===this._pane){this._chartWidget.toggleMaximizePane(e);break}}legendLoaded(){const e=this._chartWidget.paneByState(this._pane);return Boolean(e&&e.statusWidget())}getAllEntities(){const e=this._pane.model();return this._pane.sourcesByGroup().allIncludingHidden().map(t=>(0,n.entityForDataSource)(e,t)).filter(o.notNull).filter(e=>null!==e.name)}getHeight(){return this._pane.height()}setHeight(e){const t=this._chartWidget.model().model(),i=t.panes();(0,s.assert)(i.length>1,"Unable to change pane's height if there is only one pane");const r=i.indexOf(this._pane);(0,s.assert)(-1!==r,"Invalid pane index");const n=new d(t,r,e);this._chartWidget.model().undoHistory().pushUndoCommand(n)}moveTo(e){const t=this.paneIndex();t!==e&&((0,s.assert)(e>=0&&e<this._chartWidget.paneWidgets().length,"Invalid pane index"),this._chartWidget.model().movePane(t,e))}paneIndex(){return this._chartWidget.model().model().panes().indexOf(this._pane)}_getPriceScaleApi(e){let t=this._priceScales.get(e);return void 0===t&&(t=new r.PriceScaleApi(this._chartWidget.model(),e),this._priceScales.set(e,t)),t}}},42534:(e,t,i)=>{"use strict";i.d(t,{PriceScaleApi:()=>s});class s{constructor(e,t){this._chartUndoModel=e,this._chartModel=e.model(),this._priceScale=t}getMode(){const e=this._priceScale.properties().childs()
|
||||
;return e.percentage.value()?2:e.indexedTo100.value()?3:e.log.value()?1:0}setMode(e){this._priceScale.setMode({percentage:2===e,log:1===e,indexedTo100:3===e})}isInverted(){return this._priceScale.isInverted()}setInverted(e){this._priceScale.properties().childs().isInverted.setValue(e)}isLocked(){return this._priceScale.isLockScale()}setLocked(e){this._priceScale.setMode({lockScale:e})}isAutoScale(){return this._priceScale.isAutoScale()}setAutoScale(e){this._priceScale.setMode({autoScale:e})}getVisiblePriceRange(){return this._priceScale.priceRangeInPrice()}setVisiblePriceRange(e){this._priceScale.setPriceRangeInPrice(e),this._chartModel.lightUpdate()}hasMainSeries(){return this._priceScale.hasMainSeries()}getStudies(){return this._priceScale.getStudies().map(e=>e.id())}currency(){const e=this._priceScale.currency(this._chartModel.availableCurrencies());return null===e?null:{selectedCurrency:e.selectedCurrency,readOnly:e.readOnly}}setCurrency(e){this._chartUndoModel.setPriceScaleCurrency(this._priceScale,e)}unit(){const e=this._priceScale.unit(this._chartModel.availableUnits());return null===e?null:{selectedUnit:e.selectedUnit,readOnly:0===e.availableGroups.size,availableGroups:Array.from(e.availableGroups)}}setUnit(e){this._chartUndoModel.setPriceScaleUnit(this._priceScale,e)}}},32112:(e,t,i)=>{"use strict";function s(e,t){const i=e.dataSourceForId(t);if(null===i)throw new Error(`Chart has no study or shape with id "${t}"`);return i}i.d(t,{SelectionApi:()=>r});class r{constructor(e){this._model=e}add(e){Array.isArray(e)?this._model.selectionMacro(t=>{e.map(s.bind(null,this._model)).forEach(e=>t.addSourceToSelection(e))}):this.add([e])}canBeAddedToSelection(e){const t=s(this._model,e);return this._model.selection().canBeAddedToSelection(t)}set(e){Array.isArray(e)?this._model.selectionMacro(t=>{t.clearSelection(),e.map(s.bind(null,this._model)).forEach(e=>t.addSourceToSelection(e))}):this.set([e])}remove(e){Array.isArray(e)?this._model.selectionMacro(t=>{e.map(s.bind(null,this._model)).forEach(e=>t.removeSourceFromSelection(e))}):this.remove([e])}contains(e){const t=s(this._model,e);return this._model.selection().isSelected(t)}allSources(){return this._model.selection().dataSources().map(e=>e.id())}isEmpty(){return this._model.selection().isEmpty()}clear(){this._model.selectionMacro(e=>{e.clearSelection()})}onChanged(){return this._model.onSelectedSourceChanged()}}},82650:(e,t,i)=>{"use strict";i.d(t,{SeriesApi:()=>l});var s=i(88537),r=i(8597),n=i(36551),o=i(27579),a=i(42534);class l{constructor(e,t){this._series=e,this._undoModel=t,this._model=t.model()}isUserEditEnabled(){return this._series.userEditEnabled()}setUserEditEnabled(e){this._series.setUserEditEnabled(e)}mergeUp(){this._model.isMergeUpAvailableForSource(this._series)&&new r.MergeUpUndoCommand(this._model,this._series,null).redo()}mergeDown(){this._model.isMergeDownAvailableForSource(this._series)&&new r.MergeDownUndoCommand(this._model,this._series,null).redo()}unmergeUp(){
|
||||
this._model.isUnmergeAvailableForSource(this._series)&&new n.UnmergeUpUndoCommand(this._model,this._series,null).redo()}unmergeDown(){this._model.isUnmergeAvailableForSource(this._series)&&new n.UnmergeDownUndoCommand(this._model,this._series,null).redo()}detachToRight(){new o.MoveToNewPriceScaleUndoCommand(this._model,this._series,this._pane(),"right",null).redo()}detachToLeft(){new o.MoveToNewPriceScaleUndoCommand(this._model,this._series,this._pane(),"left",null).redo()}detachNoScale(){new o.MoveToNewPriceScaleUndoCommand(this._model,this._series,this._pane(),"overlay",null).redo()}changePriceScale(e){const t=(0,s.ensureNotNull)(this._model.paneForSource(this._series));switch(e){case"new-left":new o.MoveToNewPriceScaleUndoCommand(this._model,this._series,t,"left",null).redo();break;case"new-right":new o.MoveToNewPriceScaleUndoCommand(this._model,this._series,t,"right",null).redo();break;case"no-scale":(0,s.assert)(t.actionNoScaleIsEnabled(this._series),"Unable to leave a pane without any non-overlay price scale"),new o.MoveToNewPriceScaleUndoCommand(this._model,this._series,t,"overlay",null).redo();break;default:const i=this._model.dataSourceForId(e);if(null===i)throw new Error(`There is no study with entityId='${e}'`);const r=this._model.paneForSource(i)===t;(0,s.assert)(r,"Study should be on the main pane");const n=(0,s.ensureNotNull)(i.priceScale());new o.MoveToExistingPriceScaleUndoCommand(this._model,this._series,t,n,null).redo()}}isVisible(){return this._series.properties().childs().visible.value()}setVisible(e){this._series.properties().childs().visible.setValue(e)}bringToFront(){this._model.bringToFront([this._series])}sendToBack(){this._model.sendToBack([this._series])}entityId(){return this._series.id()}chartStyleProperties(e){return this._series.properties().childs()[c(e)].state(["inputs","inputsInfo"])}setChartStyleProperties(e,t){this._series.properties().childs()[c(e)].mergeAndFire(t)}barsCount(){return this._series.bars().size()}symbolSource(){return{symbol:this._series.symbol(),currencyId:this._series.currency(),unitId:this._series.unit()}}isLoading(){return this._series.isLoading()}data(){return this._series.data()}priceScale(){return new a.PriceScaleApi(this._undoModel,this._series.priceScale())}_pane(){return(0,s.ensureNotNull)(this._model.paneForSource(this._series))}}function c(e){switch(e){case 0:return"barStyle";case 1:return"candleStyle";case 2:return"lineStyle";case 3:return"areaStyle";case 4:return"renkoStyle";case 5:return"kagiStyle";case 6:return"pnfStyle";case 7:return"pbStyle";case 8:return"haStyle";case 9:return"hollowCandleStyle";case 10:return"baselineStyle";case 11:return"rangeStyle";case 12:return"hiloStyle";case 13:return"columnStyle";default:(0,s.ensureNever)(e)}throw new Error("unsupported chart style: "+e)}},67e3:(e,t,i)=>{"use strict";i.d(t,{StudyApi:()=>y});var s=i(88537),r=i(2872),n=i.n(r),o=i(80643),a=i(59572),l=i(97401),c=i(13795),h=i(36551),d=i(8597),u=i(27579),p=i(61671),_=i(79222),m=i(35588),g=i(42534),f=i(13933),v=i(152),S=i(70120);class y{constructor(e,t){
|
||||
this._onStudyCompleted=new(n()),this._onStudyError=new(n()),this._study=e,this._chartWidget=t,this._undoModel=this._chartWidget.model(),this._model=this._undoModel.model(),this._study.onAboutToBeDestroyed().subscribe(this,()=>{this._study.onStatusChanged().unsubscribeAll(this),this._study.onAboutToBeDestroyed().unsubscribeAll(this)}),this._study.onStatusChanged().subscribe(this,e=>{switch(e.type){case f.StudyStatusType.Completed:this._onStudyCompleted.fire();break;case f.StudyStatusType.Error:this._onStudyError.fire()}})}isUserEditEnabled(){return this._study.userEditEnabled()}setUserEditEnabled(e){this._study.setUserEditEnabled(e)}getInputsInfo(){return(0,v.getStudyInputsInfo)(this._study.metaInfo())}getInputValues(){const e=this._study.inputs({symbolsForChartApi:!1,asObject:!0});return Object.keys(e).map(t=>{const i=e[t];return{id:t,value:(0,o.isObject)(i)?i.v:i}})}getStyleInfo(){return(0,S.getStudyStylesInfo)(this._study.metaInfo())}getStyleValues(){const{plots:e,styles:t,bands:i,filledAreas:s,palettes:r}=this._study.properties().state(),n={};return void 0!==e&&(n.plots=e),void 0!==t&&(n.styles=t),void 0!==i&&(n.bands=i),void 0!==s&&(n.filledAreas=s),void 0!==r&&(n.palettes=r),n}setInputValues(e){const t=this.getInputValues();for(const i of e){void 0!==t.find(e=>e.id===i.id)?this._study.properties().inputs[i.id].setValue(i.value):console.warn(`There is no such input: "${i.id}"`)}}mergeUp(){this._model.isMergeUpAvailableForSource(this._study)&&new d.MergeUpUndoCommand(this._model,this._study,null).redo()}mergeDown(){this._model.isMergeDownAvailableForSource(this._study)&&new d.MergeDownUndoCommand(this._model,this._study,null).redo()}unmergeUp(){this._model.isUnmergeAvailableForSource(this._study)&&new h.UnmergeUpUndoCommand(this._model,this._study,null).redo()}unmergeDown(){this._model.isUnmergeAvailableForSource(this._study)&&new h.UnmergeDownUndoCommand(this._model,this._study,null).redo()}onDataLoaded(){return this._onStudyCompleted}onStudyError(){return this._onStudyError}mergeUpWithUndo(){this._model.isMergeUpAvailableForSource(this._study)&&this._undoModel.mergeSourceUp(this._study)}mergeDownWithUndo(){this._model.isMergeDownAvailableForSource(this._study)&&this._undoModel.mergeSourceDown(this._study)}unmergeUpWithUndo(){this._model.isUnmergeAvailableForSource(this._study)&&this._undoModel.unmergeSourceUp(this._study)}unmergeDownWithUndo(){this._model.isUnmergeAvailableForSource(this._study)&&this._undoModel.unmergeSourceDown(this._study)}priceScale(){return new g.PriceScaleApi(this._undoModel,(0,s.ensureNotNull)(this._study.priceScale()))}symbolSource(){const e=(0,s.ensureNotNull)(this._study.symbolSource());return{symbol:e.symbol(),currencyId:e.currency(),unitId:e.unit()}}currency(){return this._study.currency()}changePriceScale(e){const t=(0,s.ensureNotNull)(this._model.paneForSource(this._model.mainSeries())),i=(0,s.ensureNotNull)(this._model.paneForSource(this._study));switch(e){case"no-scale":(0,
|
||||
s.assert)(i.actionNoScaleIsEnabled(this._study),"Unable to leave a pane without any non-overlay price scale"),new u.MoveToNewPriceScaleUndoCommand(this._model,this._study,i,"overlay",null).redo();break;case"as-series":(0,s.assert)(i===t,"Study should be on the main pane"),new u.MoveToExistingPriceScaleUndoCommand(this._model,this._study,i,this._model.mainSeries().priceScale(),null).redo();break;case"new-left":new u.MoveToNewPriceScaleUndoCommand(this._model,this._study,i,"left",null).redo();break;case"new-right":new u.MoveToNewPriceScaleUndoCommand(this._model,this._study,i,"right",null).redo();break;default:const r=this._model.dataSourceForId(e);if(null===r)throw new Error(`There is no study with entityId='${e}'`);const n=i===this._model.paneForSource(r);(0,s.assert)(n,"Both studies should be on the same pane");const o=(0,s.ensureNotNull)(r.priceScale()),a=(0,c.sourceNewCurrencyOnPinningToPriceScale)(this._study,o,this._model),h=(0,_.sourceNewUnitOnPinningToPriceScale)(this._study,o,this._model);new u.MoveToExistingPriceScaleUndoCommand(this._model,this._study,i,o,null).redo(),null!==a&&new l.SetPriceScaleCurrencyUndoCommand(o,a,this._undoModel.chartWidget(),null).redo(),null!==h&&new m.SetPriceScaleUnitUndoCommand(o,h,this._undoModel.chartWidget(),null).redo()}}isVisible(){return this._study.properties().visible.value()}setVisible(e){this._study.properties().visible.setValue(e)}bringToFront(){this._model.bringToFront([this._study])}sendToBack(){this._model.sendToBack([this._study])}applyOverrides(e){(0,a.applyOverridesToStudy)(this._study,e)}dataLength(){return this._study.status().type!==f.StudyStatusType.Completed?0:this._study.metaInfo().plots.length>0?this._study.data().size():this._model.mainSeries().bars().size()}isLoading(){return this._study.isLoading()}properties(){return this._study.properties()}async applyToEntireLayout(){const e=new p.ActionsProvider(this._chartWidget),t=(await e.contextMenuActionsForSources([this._study])).find(e=>"applyStudyToEntireLayout"===e.id);t&&t.execute()}}},152:(e,t,i)=>{"use strict";i.d(t,{getStudyInputsInfo:()=>r});var s=i(28353);function r(e){return void 0===e.inputs?[]:e.inputs.map(e=>({...e,id:e.id,localizedName:void 0!==e.name?(0,s.t)(e.name,{context:"input"}):""}))}},70120:(e,t,i)=>{"use strict";i.d(t,{getStudyStylesInfo:()=>n});var s,r=i(27788);function n(e){const t={};if(e.defaults){const i=(0,r.default)(e.defaults);t.defaults=i}return void 0!==e.plots&&(t.plots=(0,r.default)(e.plots)),void 0!==e.styles&&(t.styles=(0,r.default)(e.styles)),void 0!==e.bands&&(t.bands=(0,r.default)(e.bands)),void 0!==e.filledAreas&&(t.filledAreas=(0,r.default)(e.filledAreas)),void 0!==e.palettes&&(t.palettes=(0,r.default)(e.palettes)),t}!function(e){e.LeftToRight="left_to_right",e.RightToLeft="right_to_left"}(s||(s={}))},817:(e,t,i)=>{"use strict";i.d(t,{ChartSession:()=>u});var s=i(2872),r=i.n(s),n=i(88537),o=i(52714),a=i.n(o),l=i(9423),c=i(98125);const h=(0,c.getLogger)("ChartApi.AbstractSession");var d=i(80643);(0,c.getLogger)("ChartSession");class u extends class{constructor(e,t,i){
|
||||
this._isConnected=new(a())(!1),this._state=0,this._isConnectForbidden=!1,this._sessionId="",this._sessionIdChanged=new(r()),this._chartApi=e,this._sessionPrefix=t,this._shouldReconnectAfterCriticalError=i}destroy(){this._logNormal("Destroying session"),this._isConnected.unsubscribe(),this.disconnect(),this._sessionIdChanged.destroy(),delete this._chartApi,this._logNormal("Session has been destroyed")}isConnected(){return this._isConnected}sessionId(){return this._sessionId}onSessionIdChanged(){return this._sessionIdChanged}connect(){0===this._state&&((0,n.assert)(!this._isConnectForbidden,"Cannot call connect because it is forbidden at this moment"),this._setSessionId(`${this._sessionPrefix}_${(0,l.randomHash)()}`),this._logNormal("Connecting session - wait until transport stay connected"),this._state=1,this._chartApi.createSession(this._sessionId,this))}disconnect(){0!==this._state&&((0,n.assert)(""!==this._sessionId,"sessionId must not be invalid"),this._logNormal("Disconnecting session..."),this._forbidConnectWhile(()=>{this._chartApi.connected()&&this._sendRemoveSession(),this._processDestroyingOnServer()}))}onMessage(e){switch(e.method){case"connected":return void this._onChartApiConnected();case"disconnected":return void this._onChartApiDisconnected();case"critical_error":const t=String(e.params[0]),i=String(e.params[1]);return void this._onCriticalError(t,i)}this._onMessage(e)}_getChartApi(){return this._chartApi}_generateLogMessage(e){return`[${this._sessionId}] ${e}`}_onCriticalError(e,t){this._logError(`Critical error. Reason=${e}, info=${t}.`),this._forbidConnectWhile(()=>{this._processDestroyingOnServer()}),this._shouldReconnectAfterCriticalError?(this._logNormal("Reconnecting after critical error..."),this.connect()):this._logNormal("Reconnecting after critical error skipped")}_onChartApiConnected(){(0,n.assert)(1===this._state,"Session is not registered"),this._logNormal("Transport is connected. Creating session on the server"),this._sendCreateSession(),this._state=2,this._isConnected.setValue(!0)}_onChartApiDisconnected(){this._logNormal("Transport is disconnected. Reconnecting..."),this._forbidConnectWhile(()=>{this._processDestroyingOnServer()}),this.connect()}_setSessionId(e){const t=this._sessionId;this._logNormal(`Changing sessionId: old=${t}, new=${e}`),this._sessionId=e,this._sessionIdChanged.fire(e,t)}_logNormal(e){h.logNormal(this._generateLogMessage(e))}_logError(e){h.logError(this._generateLogMessage(e))}_processDestroyingOnServer(){this._state=0,this._isConnected.setValue(!1),this._chartApi.removeSession(this._sessionId),this._setSessionId("")}_forbidConnectWhile(e){this._isConnectForbidden=!0,e(),this._isConnectForbidden=!1}}{constructor(e,t=!1){super(e,"cs",!1),this._sessionDisabled=!1,this._handler=null,this._criticalError=new(r()),this._symbolResolveMap=new Map,this._disableStatistics=t}destroy(){this._criticalError.destroy(),this._handler=null,this._symbolResolveMap.clear(),super.destroy()}serverTimeOffset(){return this._getChartApi().serverTimeOffset()}switchTimezone(e){
|
||||
return this._getChartApi().switchTimezone(this.sessionId(),e)}defaultResolutions(){return this._getChartApi().defaultResolutions()}availableCurrencies(){return this._getChartApi().availableCurrencies()}availableUnits(){return this._getChartApi().availableUnits()}resolveSymbol(e,t,i){if(this._symbolResolveMap.has(t)){const[e,s]=this._symbolResolveMap.get(t);return Array.isArray(s)?s.push(i):s.then(i),e}{const s=[i];return this._getChartApi().resolveSymbol(this.sessionId(),e,t,i=>{"symbol_error"===i.method?this._symbolResolveMap.delete(t):this._symbolResolveMap.set(t,[e,Promise.resolve(i)]),s.forEach(e=>e(i))}),this._symbolResolveMap.set(t,[e,s]),e}}requestFirstBarTime(e,t,i){return this._getChartApi().requestFirstBarTime(this.sessionId(),e,t,i)}createSeries(e,t,i,s,r,n,o){return this._getChartApi().createSeries(this.sessionId(),e,t,i,s,r,n,o)}modifySeries(e,t,i,s,r,n){return this._getChartApi().modifySeries(this.sessionId(),e,t,i,s,r,n)}removeSeries(e){return!!this.isConnected().value()&&this._getChartApi().removeSeries(this.sessionId(),e)}requestMoreData(e,t,i){return"number"==typeof e?this._getChartApi().requestMoreData(this.sessionId(),e):this._getChartApi().requestMoreData(this.sessionId(),e,t,i)}requestMoreTickmarks(e,t,i){return(0,d.isNumber)(e)?this._getChartApi().requestMoreTickmarks(this.sessionId(),e):this._getChartApi().requestMoreTickmarks(this.sessionId(),e,t,i)}requestMetadata(e,t){(()=>{this._getChartApi().requestMetadata(this.sessionId(),e,t)})()}isCanCreateStudy(e){return this._getChartApi().isCanCreateStudy(e)}createStudy(e,t,i,s,r,n,o){return this._getChartApi().createStudy(this.sessionId(),e,t,i,s,r,n,o)}rebindStudy(e,t,i,s,r,n,o){return this._getChartApi().rebindStudy(this.sessionId(),e,t,i,s,r,n,o)}modifyStudy(e,t,i,s){return this._getChartApi().modifyStudy(this.sessionId(),e,t,i,s)}removeStudy(e,t){return this._getChartApi().removeStudy(this.sessionId(),e,t)}createPointset(e,t,i,s,r,n){return this._getChartApi().createPointset(this.sessionId(),e,t,i,s,r,n)}modifyPointset(e,t,i,s){return this._getChartApi().modifyPointset(this.sessionId(),e,t,i,s)}removePointset(e){return this._getChartApi().removePointset(this.sessionId(),e)}setVisibleTimeRange(e,t,i,s,r,n){this._getChartApi().setVisibleTimeRange(this.sessionId(),e,t,i,s,!0,r,n)}criticalError(){return this._criticalError}connect(e=null){null!==e&&(this._handler=e),this._symbolResolveMap.clear(),super.connect()}setHandler(e){this._handler=e}connected(){return this.isConnected().value()&&!this._sessionDisabled}disable(){this._sessionDisabled=!0}chartApi(){return this._getChartApi()}_sendCreateSession(){Object.keys(this).forEach(e=>{/^(s|st|symbol_)\d+$/.test(e)&&delete this[e]}),this._getChartApi().chartCreateSession(this.sessionId(),this._disableStatistics)}_sendRemoveSession(){this._getChartApi().chartDeleteSession(this.sessionId())}_onMessage(e){this._handler&&this._handler(e)}_onCriticalError(e,t){this._criticalError.fire(e,t),super._onCriticalError(e,t)}}},84801:(e,t,i)=>{"use strict";var s=i(80643).declareClassAsPureInterface;function r(){}
|
||||
TradingView.WEB_SOCKET_WAS_CONNECTED=!1,r.REBIND_STUDY_STANDALONE_TO_CHILD=1,r.REBIND_STUDY_CHILD_TO_STANDALONE=2,r.prototype.defaultWatchlistSymbols=function(){},r.prototype.defaultResolutions=function(){},r.prototype.availableCurrencies=function(){},r.prototype.availableUnits=function(){},r.prototype.supportedSymbolsTypes=function(){},r.prototype.supportedExchangesList=function(){},r.prototype.symbolsGrouping=function(){},r.prototype.quoteCreateSession=function(e){},r.prototype.quoteDeleteSession=function(e){},r.prototype.quoteSetFields=function(e,t){},r.prototype.quoteAddSymbols=function(e,t){},r.prototype.quoteRemoveSymbols=function(e,t){},r.prototype.quoteFastSymbols=function(e,t){},r.prototype.depthCreateSession=function(e,t,i){},r.prototype.depthDeleteSession=function(e){},r.prototype.depthSetSymbol=function(e,t){},r.prototype.depthClearSymbol=function(e){},r.prototype.depthSetScale=function(e,t){},r.prototype.chartCreateSession=function(e,t){},r.prototype.chartDeleteSession=function(e){},r.prototype.createSession=function(e,t){},r.prototype.removeSession=function(e){},r.prototype.connected=function(){},r.prototype.connect=function(){},r.prototype.disconnect=function(){},r.prototype.switchTimezone=function(e,t){},r.prototype.resolveSymbol=function(e,t,i,s){},r.prototype.createSeries=function(e,t,i,s,r,n,o,a){},r.prototype.removeSeries=function(e,t,i){},r.prototype.modifySeries=function(e,t,i,s,r,n,o){},r.prototype.requestMoreData=function(e,t,i,s){},r.prototype.requestMetadata=function(e,t,i){},r.prototype.isCanCreateStudy=function(e,t){},r.prototype.createStudy=function(e,t,i,s,r,n,o){},r.prototype.rebindStudy=function(e,t,i,s,r,n,o,a){},r.prototype.removeStudy=function(e,t,i){},r.prototype.modifyStudy=function(e,t,i,s,r){},r.prototype.createPointset=function(e,t,i,s,r,n,o){},r.prototype.modifyPointset=function(e,t,i,s,r){},r.prototype.removePointset=function(e,t,i){},r.prototype.requestMoreTickmarks=function(e,t,i,s){},r.prototype.requestFirstBarTime=function(e,t,i,s){},r.prototype._invokeHandler=function(e,t){},r.prototype._sendRequest=function(e,t){},r.prototype._onMessage=function(e){},r.prototype._dispatchNotification=function(e){},r.prototype._invokeNotificationHandler=function(e,t,i){},r.prototype._notifySessions=function(e){},r.prototype.unpack=function(e){},r.prototype.searchSymbols=function(e,t,i,s,r,n,o,a,l,c){},r.prototype.serverTimeOffset=function(){},r.prototype.getMarks=function(e,t,i,s,r){},r.prototype.getTimescaleMarks=function(e,t,i,s,r){},s(r,"ChartApiInterface"),e.exports.HandlerInfo=function(e,t){this.handler=e,this.customId=t},e.exports.ChartApiInterface=r},17437:(e,t,i)=>{"use strict";i.r(t),i.d(t,{setCustomAdapter:()=>_,initialize:()=>m,updateUser:()=>g,getChartsCount:()=>f,getCharts:()=>v,removeChart:()=>S,saveChart:()=>y,getChartContent:()=>b,loadChart:()=>w,removeStudyTemplate:()=>C,getStudyTemplateContent:()=>P,saveStudyTemplate:()=>T,getStudyTemplatesList:()=>x,invalidateStudyTemplatesList:()=>I,getStudyTemplateContentById:()=>M,getStandardStudyTemplateContentById:()=>L,
|
||||
removeStudyTemplateById:()=>A,renameStudyTemplate:()=>E,replaceStudyTemplate:()=>k,getDrawingTemplates:()=>D,loadDrawingTemplate:()=>V,removeDrawingTemplate:()=>B,saveDrawingTemplate:()=>N});var s=i(76422),r=i(98125),n=i(88461);const o=(0,r.getLogger)("Chart.SaveloadAdapter.Library");let a,l,c,h,d=null,u=null;function p(e){return`${c}/${encodeURIComponent(h)}/${e}?client=${encodeURIComponent(a)}&user=${encodeURIComponent(l)}`}function _(e){d=e}function m(e,t,i,s){a=e,l=t,c=i,h=s}function g(e){l=e}function f(e,t){throw new Error("Not implemented")}async function v(){const e=e=>e.map(e=>({id:e.id,name:e.name,image_url:String(e.id),modified_iso:e.timestamp,short_symbol:e.symbol,interval:e.resolution}));if(d)return d.getAllCharts().then(e);try{const t=await fetch(""+p("charts"),{credentials:"same-origin"});if(!t.ok)throw new Error(`Getting chart content response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Get chart content request failed: "+i.message);return e(i.data)}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function S(e){if(d)d.removeChart(e);else try{const t=await fetch(`${p("charts")}&chart=${encodeURIComponent(e)}`,{method:"DELETE",credentials:"same-origin"});if(!t.ok)throw new Error(`Remove chart response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Remove drawing template request failed: "+i.message)}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function y(e,t,i,s,r){const a=r.id.value(),l={name:e,content:JSON.stringify(s),symbol:t,resolution:i};if(d)return d.saveChart({...l,id:a});try{const e=new FormData;for(const t in l)e.append(t,l[t]);let t=p("charts");null!=a&&(t+="&chart="+encodeURIComponent(a));const i=await fetch(t,{credentials:"same-origin",method:"POST",body:e});if(!i.ok)throw new Error(`Saving chart content response was not OK. Status: ${i.status}.`);const s=await i.json();if("ok"!==s.status)throw new Error("Saving chart content request failed: "+s.message);return s.id.toString()}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function b(e){const t=t=>{const i=JSON.parse(t);return i.uid=e.id,i};if(d)return d.getChartContent(e.id).then(e=>t(e));try{const i=await fetch(`${p("charts")}&chart=${encodeURIComponent(e.id)}`,{credentials:"same-origin"});if(!i.ok)throw new Error(`Getting chart content response was not OK. Status: ${i.status}.`);const s=await i.json();if("ok"!==s.status)throw new Error("Get chart content request failed: "+s.message);return t(s.data.content)}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}function w(e){b(e).then(e=>{s.emit("chart_load_requested",e)},()=>{o.logWarn("Error loading chart")})}async function C(e){try{if(d)return d.removeStudyTemplate({name:e});const t=await fetch(`${p("study_templates")}&template=${encodeURIComponent(e)}`,{method:"DELETE",credentials:"same-origin"});if(!t.ok)throw new Error(`Remove study template response was not OK. Status: ${t.status}.`);const i=await t.json()
|
||||
;if("ok"!==i.status)throw new Error("Remove study template request failed: "+i.message)}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function P(e){try{if(d){return{content:await d.getStudyTemplateContent({name:e})}}const t=await fetch(`${p("study_templates")}&template=${encodeURIComponent(e)}`,{credentials:"same-origin"});if(!t.ok)throw new Error(`Get study template response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Get study template request failed: "+i.message);return i.data}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function T(e){try{if(d)return d.saveStudyTemplate(e).then(()=>({error:""})).catch(e=>({error:null!=e?(0,n.errorToString)(e):"error"}));const t=new FormData;t.append("name",e.name),t.append("content",e.content);const i=await fetch(p("study_templates"),{method:"POST",body:t,credentials:"same-origin"});if(!i.ok)throw new Error(`Save study template response was not OK. Status: ${i.status}.`);const s=await i.json();return{error:"ok"===s.status?"":s.status}}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function x(){try{if(u)return u;u=[];const e=e=>(u=e.map(e=>({is_default:!1,name:e.name})),u);if(d)return d.getAllStudyTemplates().then(e);const t=await fetch(p("study_templates"),{method:"GET",credentials:"same-origin"});if(!t.ok)throw new Error(`Study templates list response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Study templates list request failed: "+i.message);return e(i.data)}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}function I(){u=null}function M(e,t){throw new Error("Not implemented")}function L(e,t){throw new Error("Not implemented")}function A(e,t){throw new Error("Not implemented")}function E(e,t,i){throw new Error("Not implemented")}function k(e,t,i){throw new Error("Not implemented")}async function D(e){throw new Error("Not implemented")}async function V(e,t){throw new Error("Not implemented")}async function B(e,t){throw new Error("Not implemented")}async function N(e,t,i){throw new Error("Not implemented")}},87983:(e,t,i)=>{"use strict";var s=i(88537).ensureNotNull,r=i(69177),n=i(29823).Interval,o=i(16616),a=i(84093),l=i(84801),c=l.ChartApiInterface,h=l.HandlerInfo,d=i(80643).requireFullInterfaceImplementation,u=i(98125).getLogger("Chart.ChartApiLocal"),p=i(73383).TIMEFRAMETYPE,_=i(65862).createDwmAligner,m=i(67337);TradingView.STUDY_COUNT_LIMIT=210,JSServer.ChartApi=function(e){this._notificationHandlers={},this._sessions={},this.studyCounter=0,this._connected=!1,this._enabled=!1,this._studyEngine=new o(e),this._callbacks={},this._serverTimeOffset=0;var t=this;this._studyEngine.on("configuration_received",(function(){t._fireEvent("configuration_received")})),this._studyEngine.on("realtime_tick",(function(e){var i={time:e.value[0]/1e3,open:e.value[1],high:e.value[2],low:e.value[3],close:e.value[4],volume:e.value[5]};t._fireEvent("realtime_tick",i,!0)})),this._setVisibleRangeTimeout={}},JSServer.ChartApi.prototype.destroy=function(){
|
||||
this._studyEngine.destroy(),this._studyEngine=null},JSServer.ChartApi.prototype.purgeCache=function(e){this._studyEngine.purgeCache(),this._studyEngine.purgeDataCache()},JSServer.ChartApi.prototype.defaultWatchlistSymbols=function(){const e=this._watchlistSettings.default_symbols;return m.enabled("uppercase_instrument_names")?e.map(e=>e.toUpperCase()):e},JSServer.ChartApi.prototype.defaultResolutions=function(){return this._studyEngine.supportedResolutions()||["1","3","5","15","30","45","60","120","180","240","1D","1W","1M"]},JSServer.ChartApi.prototype.availableCurrencies=function(){var e=this._studyEngine.supportedCurrencies().map((function(e){return"string"==typeof e?{id:e,code:e}:e}));return Promise.resolve(e)},JSServer.ChartApi.prototype.availableUnits=function(){return Promise.resolve(this._studyEngine.supportedUnits())},JSServer.ChartApi.prototype.supportedSymbolsTypes=function(){return this._studyEngine.supportedSymbolsTypes()},JSServer.ChartApi.prototype.supportedExchangesList=function(){return this._studyEngine.supportedExchangesList()},JSServer.ChartApi.prototype.symbolsGrouping=function(){return this._studyEngine.symbolsGrouping()},JSServer.ChartApi.prototype.start=function(){this._enabled=!0,this._fireEvent("start_enabled")},JSServer.ChartApi.prototype.unsubscribe=function(e,t){var i=this._callbacks[e];i&&i.splice(i.indexOf(t),1)},JSServer.ChartApi.prototype.on=function(e,t){return this._callbacks.hasOwnProperty(e)||(this._callbacks[e]=[]),this._callbacks[e].push(t),this},JSServer.ChartApi.prototype._fireEvent=function(e,t,i){if(this._callbacks.hasOwnProperty(e)){var s=this._callbacks[e].slice(0);i||(this._callbacks[e]=[]);for(var r=0;r<s.length;++r)s[r](t)}},JSServer.ChartApi.prototype.chartCreateSession=function(e,t){this._studyEngine.chartCreateSession(e)},JSServer.ChartApi.prototype.chartDeleteSession=function(e){this._studyEngine.chartDeleteSession(e)},JSServer.ChartApi.prototype.createSession=function(e,t){TradingView.ChartapiMessagerInstances[e]=new a(this,e),this._sessions[e]=t,this._notificationHandlers[e]={},this.connected()&&t.onMessage({method:"connected",params:[]})},JSServer.ChartApi.prototype.removeSession=function(e){delete this._sessions[e],delete this._notificationHandlers[e],this._studyEngine.stopSources(e)},JSServer.ChartApi.prototype.connected=function(){return this._connected},JSServer.ChartApi.prototype.connect=function(){if(this._enabled)this.connected()||(this._connected=!0,this.sessionid="dummy session id",this._notifySessions({method:"connected",params:[]}));else{var e=this;this.on("start_enabled",(function(){e.connect()}))}},JSServer.ChartApi.prototype.disconnect=function(){this._connected=!1,this._notifySessions({method:"disconnected",params:[]}),this.purgeCache(),this.studyCounter=0},JSServer.ChartApi.prototype.switchTimezone=function(e,t){this._studyEngine.switchTimezone(e,t)},JSServer.ChartApi.prototype.receiveLocalResponse=function(e){this._dispatchNotification(e),this._fireEvent("message_"+e.method,void 0,!0)},JSServer.ChartApi.prototype.getMarks=function(e,t,i,s,r){
|
||||
this._studyEngine.getMarks(e,t,i,s,r)},JSServer.ChartApi.prototype.getTimescaleMarks=function(e,t,i,s,r){this._studyEngine.getTimescaleMarks(e,t,i,s,r)},JSServer.ChartApi.prototype.resolveSymbol=function(e,t,i,s){this._notificationHandlers[e][t]=new h(s,t),this._studyEngine.resolveSymbol(e,t,i)},JSServer.ChartApi.prototype._doWhenSeriesDataReceived=function(e,t){TradingView.ChartapiMessagerInstances[e].seriesCompleted.subscribe(null,t,!0)},JSServer.ChartApi.prototype.createSeries=function(e,t,i,s,r,n,o,a){var l=this;this._notificationHandlers[e][t]=new h((function(r){"series_completed"===r.method&&null!==o&&(l._applyTimeFrame(e,s,t,i,o),o=null),a(r)}),t);const c={countBack:n||300};null!==o&&o.type===p.TimeRange&&(c.to=1e3*o.to,c.from=1e3*o.from),this._studyEngine.createSeries(e,t,i,s,r,c)},JSServer.ChartApi.prototype.removeSeries=function(e,t){delete this._notificationHandlers[e][t],this._studyEngine.removeSeries(e,t)},JSServer.ChartApi.prototype.setVisibleTimeRange=function(e,t,i,r,n,o,a,l){var c=r,h=!0!==(a=a||{}).applyDefaultRightMargin&&void 0===a.percentRightMargin&&void 0!==n?n:null,d=_(this._studyEngine.getSeriesInterval(e,t),this._studyEngine.getSeriesSymbolInfo(e,t));null!==d&&(c=d.timeToSessionStart(1e3*c)/1e3,null!==h&&(h=d.timeToSessionStart(1e3*h)/1e3));var u=this;function p(){var r=u._studyEngine.sessionTimeScale(e);if(null!==r){var n,d=r.indexOfTime(1e3*c);if(null===h)n=r.lastSessionBarIndex();else{var p=r.indexOfTime(1e3*h);n=p&&p.index}if(null!==d&&null!==n){var _=d.index;if(d.timeMs<1e3*c&&(_+=1),!1===o){const e=s(r.firstSessionBarIndex());_<e&&(_=e)}_>n||(TradingView.ChartapiMessagerInstances[e].onSeriesTimeframeUpdate(t,i,_,n,a),l&&setTimeout(l,0))}}}if(this._studyEngine.isTimeScaleExtendedTo(e,1e3*r))p();else{var m=TradingView.ChartapiMessagerInstances[e].seriesCompleted,g=TradingView.ChartapiMessagerInstances[e].seriesError;void 0!==this._setVisibleRangeTimeout[e]&&clearTimeout(this._setVisibleRangeTimeout[e]),this._setVisibleRangeTimeout[e]=setTimeout(function(){delete this._setVisibleRangeTimeout[e],m.subscribe(null,f,!0),g.subscribe(null,v,!0),this._studyEngine.ensureExtendedTo(t,e,1e3*r)}.bind(this),0)}function f(e,s){e===t&&s===i&&(m.unsubscribe(null,f),g.unsubscribe(null,v),p())}function v(e,s){e===t&&s===i&&m.unsubscribe(null,f)}},JSServer.ChartApi.prototype._applyTimeFrame=function(e,t,i,s,o){var a,l,c={},h=!0;if(o.type===p.PeriodBack){var d=this._studyEngine.getSeriesLastBarTime(e,i);if(null===d)return;l=d/1e3;var u=n.parse(o.value),m=this._studyEngine.getSeriesSymbolInfo(e,i);a=r.alignPeriodsBackForVisibleRange(m.session,m.session_holidays,m.corrections,u.letter(),u.multiplier(),1,d)/1e3;var g=_(this._studyEngine.getSeriesInterval(e,i),m);null!==g&&(l=g.timeToExchangeTradingDay(1e3*l)/1e3,a=g.timeToExchangeTradingDay(1e3*a)/1e3),c={applyDefaultRightMargin:!0},h=!1}else a=o.from,l=o.to;this.setVisibleTimeRange(e,i,s,a,l,h,c)},JSServer.ChartApi.prototype.modifySeries=function(e,t,i,s,r,n,o){var a=this;this._notificationHandlers[e][t]=new h((function(r){
|
||||
"series_completed"===r.method&&null!==n&&(a._applyTimeFrame(e,s,t,i,n),n=null),o(r)}),t),this._studyEngine.modifySeries(e,t,s,r,i)},JSServer.ChartApi.prototype.requestMoreData=function(e,t){this._studyEngine.extendSeriesRange(e,t)},JSServer.ChartApi.prototype.setStudiesAccessController=function(e){this.studiesAccessController=e},JSServer.ChartApi.prototype.setWatchlistSettings=function(e){this._watchlistSettings=e},JSServer.ChartApi.prototype.allStudiesMetadata=function(){return this._studyEngine.studiesMetadata()},JSServer.ChartApi.prototype.requestMetadata=function(e,t,i){this._notificationHandlers[e][t]=new h(i,t);var s=this.studiesAccessController.getEnabledTools();TradingView.ChartapiMessagerInstances[e].onRequestMetadata(t,s)},JSServer.ChartApi.prototype.isCanCreateStudy=function(){return this.studyCounter<TradingView.STUDY_COUNT_LIMIT},JSServer.ChartApi.prototype.createStudy=function(e,t,i,s,r,n,o){if(!this.isCanCreateStudy())throw new Error("Exceeded the limit of studies");this._notificationHandlers[e][t]=new h(o,t),this._studyEngine.createStudy(e,t,s,i,r,n),this.studyCounter++},JSServer.ChartApi.prototype.rebindStudy=function(e,t,i,s,r,n,o,a){throw new Error("Not implemented")},JSServer.ChartApi.prototype.removeStudy=function(e,t,i){delete this._notificationHandlers[e][t],this._studyEngine.removeStudy(e,t),this.studyCounter--},JSServer.ChartApi.prototype.modifyStudy=function(e,t,i,s,r){this._notificationHandlers[e][t]=new h(r,t),this._studyEngine.modifyStudy(e,t,i,s)},JSServer.ChartApi.prototype.createPointset=function(e,t,i,s,r,n,o){this._notificationHandlers[e][t]=new h(o,t),this._studyEngine.createPointset(e,t,s,r,n)},JSServer.ChartApi.prototype.modifyPointset=function(e,t,i,s,r){throw Error("This call is not implemented")},JSServer.ChartApi.prototype.removePointset=function(e,t,i){this._notificationHandlers[e][t]=null,this._studyEngine.removePointset(e,t)},JSServer.ChartApi.prototype.requestMoreTickmarks=function(e,t){this._studyEngine.requestMoreTickmarks(e,t)},JSServer.ChartApi.prototype.requestFirstBarTime=function(e,t,i,s){this._notificationHandlers[e][t]=new h(s,t)},JSServer.ChartApi.prototype._invokeHandler=function(e,t){e&&e(t)},JSServer.ChartApi.prototype._sendRequest=function(e,t){throw Error("This method is not implemented")},JSServer.ChartApi.prototype._onMessage=function(e){throw Error("This method is not implemented")},JSServer.ChartApi.prototype._dispatchNotification=function(e){var t=e.params.shift();if(this._notificationHandlers[t])switch(e.method){case"timescale_update":var i=e.params[0],s=e.params[1];for(var r in s.clear=0===s.changes.length&&0===s.marks.length,this._sessions[t].onMessage({method:"timescale_update",params:s}),i){var n={method:"data_update",params:{customId:r,plots:i[r].series,nonseries:i[r].nonseries,turnaround:i[r].turnaround}};this._invokeNotificationHandler(t,r,n)}break;case"tickmark_update":this._sessions[t].onMessage({method:"timescale_update",params:e.params[0]});break;case"data_update":for(var r in e.params[0]){var o=e.params[0][r];n={method:"data_update",
|
||||
params:{customId:r,plots:o.series?o.series:o.plots,nonseries:o.nonseries,turnaround:o.turnaround}};this._invokeNotificationHandler(t,r,n)}break;case"index_update":for(var r in e.params[0]){n={method:"index_update",params:e.params[0][r]};this._invokeNotificationHandler(t,r,n)}break;case"critical_error":u.logNormal(new Date+" critical_error session:"+this.sessionid+" reason:"+e.params[0]),this._sessions[t].onMessage({method:"critical_error",params:e.params});break;case"timescale_completed":case"quote_symbol_data":case"quote_list_fields":case"depth_symbol_error":case"depth_symbol_success":case"dd":case"dpu":case"depth_bar_last_value":this._sessions[t].onMessage({method:e.method,params:e.params});break;case"clear_data":for(var a in e.params[0])this._invokeNotificationHandler(t,a,{method:"clear_data",params:e.params[0][a]});break;default:var l=e.params[0];this._invokeNotificationHandler(t,l,e)}},JSServer.ChartApi.prototype._invokeNotificationHandler=function(e,t,i){if(void 0!==t){var s=this._notificationHandlers[e][t];void 0!==s&&s&&this._invokeHandler(s.handler,i)}},JSServer.ChartApi.prototype.searchSymbols=function(e,t,i,s,r,n,o,a,l,c){this._studyEngine.searchSymbols(e,t,i,c)},JSServer.ChartApi.prototype._notifySessions=function(e){for(var t in this._sessions){if(!this._sessions.hasOwnProperty(t))return;var i=this._sessions[t];"function"==typeof i.onMessage&&i.onMessage(e)}},JSServer.ChartApi.prototype.unpack=function(e){throw Error("This method is not implemented")},JSServer.ChartApi.prototype.quoteCreateSession=function(e){return this._studyEngine.quoteCreateSession(e)},JSServer.ChartApi.prototype.quoteDeleteSession=function(e){return this._studyEngine.quoteDeleteSession(e)},JSServer.ChartApi.prototype.quoteSetFields=function(e,t){return this._studyEngine.quoteSetFields(e,t)},JSServer.ChartApi.prototype.quoteAddSymbols=function(e,t){return-1!==t.indexOf(void 0)&&(console.warn("Got undefined in quoteAddSymbols"),t=t.filter((function(e){return!!e}))),this._studyEngine.quoteAddSymbols(e,t)},JSServer.ChartApi.prototype.quoteRemoveSymbols=function(e,t){return this._studyEngine.quoteRemoveSymbols(e,t)},JSServer.ChartApi.prototype.quoteFastSymbols=function(e,t){return this._studyEngine.quoteFastSymbols(e,t)},JSServer.ChartApi.prototype.quoteHibernateAll=function(e){return this._studyEngine.quoteHibernateAll(e)},JSServer.ChartApi.prototype.depthCreateSession=function(e){return this._studyEngine.depthCreateSession(e)},JSServer.ChartApi.prototype.depthDeleteSession=function(e){return this._studyEngine.depthDeleteSession(e)},JSServer.ChartApi.prototype.depthSetSymbol=function(e,t){return this._studyEngine.depthSetSymbol(e,t)},JSServer.ChartApi.prototype.depthClearSymbol=function(e){},JSServer.ChartApi.prototype.depthSetScale=function(e,t){},JSServer.ChartApi.prototype.createStudiesAccessController=function(e,t,i){return new this.StudiesAccessController(this._studyEngine,e&&JSON.parse(e)||{type:"black",tools:[]})},JSServer.ChartApi.prototype.StudiesAccessController=function(e,t){this._studyEngine=e,this._studiesAccess=t},
|
||||
JSServer.ChartApi.prototype.StudiesAccessController.prototype._findTool=function(e){for(var t=null,i=0;i<this._studiesAccess.tools.length;++i){var s=this._studiesAccess.tools[i];if(s.name===e||s===e){t=s;break}}return t},JSServer.ChartApi.prototype.StudiesAccessController.prototype.getEnabledTools=function(){return this._studyEngine.studiesMetadata().filter((function(e){return this.isToolEnabled(e.description)||e.is_hidden_study}),this)},JSServer.ChartApi.prototype.StudiesAccessController.prototype.isToolEnabled=function(e){var t=this._findTool(e);return"black"===this._studiesAccess.type?!t||t.grayed:!!t},JSServer.ChartApi.prototype.StudiesAccessController.prototype.isToolGrayed=function(e){var t=this._findTool(e);return t&&t.grayed},JSServer.ChartApi.prototype.serverTimeOffset=function(){return this._studyEngine.serverTimeOffset()},JSServer.ChartApi.prototype.serverTime=function(){return this._studyEngine.serverTime()},JSServer.ChartApi.prototype.disconnectCount=function(){return 0},d(JSServer.ChartApi,"JSServer.ChartApi",c,"ChartApiInterface"),e.exports=JSServer.ChartApi},84093:(e,t,i)=>{"use strict";var s=i(2872),r=function(e,t){this._server=e,this._session=t,this.seriesCompleted=new s,this.seriesError=new s};r.prototype.onRequestMetadata=function(e,t){this._server.receiveLocalResponse({method:"studies_metadata",params:[this._session,e,{errors:[],hash:"",metainfo:t,migrations:[]}]})},r.prototype.onSymbolResolved=function(e,t){this._server.receiveLocalResponse({method:"symbol_resolved",params:[this._session,e,t]})},r.prototype.onSymbolError=function(e,t){this._server.receiveLocalResponse({method:"symbol_error",params:[this._session,e,t]})},r.prototype.onStudyError=function(e,t,i){this._server.receiveLocalResponse({method:"study_error",params:[this._session,e,t,i]})},r.prototype.onSeriesLoading=function(e,t){this._server.receiveLocalResponse({method:"series_loading",params:[this._session,e,t]})},r.prototype.onSeriesCompleted=function(e,t,i){this._server.receiveLocalResponse({method:"series_completed",params:[this._session,e,i,t]}),this.seriesCompleted.fire(e,t)},r.prototype.onSeriesError=function(e,t,i){this._server.receiveLocalResponse({method:"series_error",params:[this._session,e,t,i]}),this.seriesError.fire(e,t)},r.prototype.onStudyCompleted=function(e,t){this._server.receiveLocalResponse({method:"study_completed",params:[this._session,e,t]})},r.prototype.onStudyLoading=function(e,t){this._server.receiveLocalResponse({method:"study_loading",params:[this._session,e,t]})},r.prototype.onTickmarksUpdated=function(e,t){var i={method:"tickmark_update",params:[this._session,{index:e,zoffset:0,changes:[],marks:t,index_diff:[]}]};this._server.receiveLocalResponse(i)},r.prototype.onTimescaleUpdate=function(e,t){var i={method:"timescale_update",params:[this._session,this._prepareDataUpdateObjects(t),{index:e.pointsIndex,zoffset:0,changes:e.points,marks:e.marks,index_diff:e.indexChange,baseIndex:e.baseIndex}]};this._server.receiveLocalResponse(i)},r.prototype.onTimescaleCompleted=function(e){
|
||||
this._server.receiveLocalResponse({method:"timescale_completed",params:[this._session,e]})},r.prototype.onSeriesTimeframeUpdate=function(e,t,i,s,r){var n={method:"series_timeframe",params:[this._session,e,t,i,s,null,!0,r]};this._server.receiveLocalResponse(n)},r.prototype.onPointsetDataUpdate=function(e,t,i){this.onDataUpdate(e,t,i,null)},r.prototype._prepareDataUpdateObjects=function(e){var t={};return e.forEach((function(e){t[e.objId]={series:e.data,turnaround:e.turnaround},e.nonSeriesData&&(e.nonSeriesData.data?t[e.objId].nonseries={d:JSON.stringify(e.nonSeriesData.data),indexes:e.nonSeriesData.indexes}:t[e.objId].nonseries={d:"",indexes:[]})})),t},r.prototype.onDataUpdate=function(e,t,i,s){var r={method:"data_update",params:[this._session,this._prepareDataUpdateObjects([{objId:e,turnaround:t,data:i,nonSeriesData:s}])]};this._server.receiveLocalResponse(r)},r.prototype.onQuotesData=function(e){this._server.receiveLocalResponse({method:"quote_symbol_data",params:e})},r.prototype.onDepthData=function(e){this._server.receiveLocalResponse({method:"dd",params:e})},r.prototype.onDepthUpdate=function(e){this._server.receiveLocalResponse({method:"dpu",params:e})},r.prototype.onClearData=function(e){this._server.receiveLocalResponse({method:"clear_data",params:[this._session,e]})},TradingView.ChartapiMessagerInstances=[],e.exports=r},41986:(e,t,i)=>{"use strict";i.d(t,{DatafeedRequestsCachedProcessor:()=>_});var s=i(88537),r=i(29823),n=i(55257),o=i(216),a=i(67337),l=i(69177),c=i(65862),h=i(90388);i(94419);function d(e,t){return e.ticker+(e.currency_code?"_#_"+e.currency_code:"")+(e.unit_id?"_#_"+e.unit_id:"")+(e.subsession_id?"_#_"+e.subsession_id:"")+"_#_"+t}function u(e){return new Date(e).toISOString()}class p{constructor(e,t,i,s,n,o){this._cache={bars:[]},this._nextSubscriptionId=0,this._pendingSubscribers=[],this._subscribers=[],this._requesting=!1,this._leftDate=null,this._nextTime=null,this._realtimeOn=!1,this._endOfData=!1,this._resetCacheTimeout=null,this._errorMessage=null,this._destroyed=!1,this._emptyResponsesCount=0,this._datafeed=e,this._symbolInfo=t,this._interval=r.Interval.parse(i),this._resolution=this._interval.value(),this._dwmAligner=n,this._serverTimeOffsetGetter=s,this._resetCacheTimePeriod=void 0===o?1e4:o,this._sessionSpec=new h.SessionSpec(t.timezone,t.session,t.session_holidays,t.corrections),this._updateDatesFromExpirationDate()}destroy(){0!==this._subscribers.length&&console.warn("Destroying with not-empty state"),this._clearResetCacheTimeout(),this._unsubscribeRealtime(),this._purgeCache(),delete this._datafeed,this._destroyed=!0}addSubscription(e,t,i){const s=this._getNextSubscriptionId();this._pendingSubscribers.push({key:s,range:e,onHistoryCallback:t,onErrorCallback:i}),r.Interval.isDWM(this._resolution)&&void 0!==e.to&&null!==this._dwmAligner&&e.to%864e5&&console.warn(`Internal error: invalid date for DWM resolution ${u(e.to)}, expected time without a time part`),this._clearResetCacheTimeout();return setTimeout(()=>{this._destroyed||this._processPendingSubscribers()},0),s}
|
||||
removeSubscription(e){const t=this._pendingSubscribers.find(t=>t.key===e);if(t)return void this._pendingSubscribers.splice(this._pendingSubscribers.indexOf(t),1);const i=this._subscribers.find(t=>t.key===e);if(i)return this._subscribers.splice(this._subscribers.indexOf(i),1),void(this._subscribers.length||(this._resetCacheTimeout=setTimeout(()=>{this._resetCacheTimeout=null,this._purgeCache(),this._unsubscribeRealtime()},this._resetCacheTimePeriod)));console.warn("Unknown subscription symbol={0}, resolution={1}, key={2}".format(this._symbolInfo.name,this._resolution,e))}_logMessage(e,t){if(a.enabled("charting_library_debug_mode")||t){const t=this._symbolInfo.currency_code,i=this._symbolInfo.unit_id;console.log(`FEED [${this._symbolInfo.name}|${this._resolution}${t?"|"+t:""}${i?"|"+i:""}]: ${e}`)}}_clearResetCacheTimeout(){null!==this._resetCacheTimeout&&(clearTimeout(this._resetCacheTimeout),this._resetCacheTimeout=null)}_purgeCache(){this._logMessage("Reset cache"),this._cache={bars:[]},this._errorMessage=null,this._leftDate=null,this._endOfData=!1,this._updateDatesFromExpirationDate()}_updateDatesFromExpirationDate(){void 0!==this._symbolInfo.expiration_date&&(this._nextTime=1e3*this._symbolInfo.expiration_date,this._leftDate=1e3*(this._symbolInfo.expiration_date+1))}_dealignTime(e){return null===this._dwmAligner?e:this._dwmAligner.timeToExchangeTradingDay(e)}_normalizeRange(e){const t=void 0!==e.to?e.to:this._dealignTime(this._now());if(0===this._cache.bars.length||void 0!==e.to&&t<=(0,s.ensureNotNull)(this._leftDate))return{countBack:e.countBack,to:t};const i=null!==this._dwmAligner?this._dwmAligner.timeToSessionStart(t):t,r=(0,n.lowerbound)(this._cache.bars,i,(e,t)=>e.time<t);return e.countBack<r?{countBack:0,to:0!==e.countBack&&r<=this._cache.bars.length?this._dealignTime(this._cache.bars[r-e.countBack].time):t}:{countBack:e.countBack-r,to:this._dealignTime(this._cache.bars[0].time)}}_processPendingSubscribers(){const e=this._pendingSubscribers;if(!e.length)return;if(this._requesting)return void this._logMessage("Processing is skipped due active request");if(this._logMessage("Processing pending subscribers, count="+e.length),this._errorMessage){const t=this._errorMessage;return this._logMessage("Return error: "+t),this._pendingSubscribers=[],void e.forEach(e=>{e.onErrorCallback(t)})}let t=this._normalizeRange(e[0].range);for(const i of e.map(e=>this._normalizeRange(e.range)))(i.to<t.to||i.to===t.to&&i.countBack>t.countBack)&&(t=i);this._logMessage(`Leftmost subscriber requires ${t.countBack} bars prior ${u(t.to)}`);!(null===this._leftDate||t.to<this._leftDate&&(null===this._nextTime||t.to<this._nextTime)||0!==t.countBack)||this._endOfData?(this._pendingSubscribers=[],e.forEach(e=>{const t=this._moveSubscriberToRealtime(e);this._returnHistoryDataToSubscriber(e,t)}),this._subscribeRealtimeIfNeeded()):this._ensureRequestedTo(t)}_moveSubscriberToRealtime(e){const t={key:e.key,onHistoryCallback:e.onHistoryCallback,barset:null};return this._subscribers.push(t),t}_isSymbolExpired(){
|
||||
return this._symbolInfo.expired||void 0!==this._symbolInfo.expiration_date}_subscribeRealtimeIfNeeded(){!this._subscribers.length||this._realtimeOn||this._isSymbolExpired()||this._subscribeRealtime()}_subscribeRealtime(){if(this._symbolInfo.expired||this._realtimeOn)return;this._realtimeOn=!0,this._datafeed.subscribeBars(this._symbolInfo,this._resolution,e=>{null!==this._dwmAligner&&(e.time=this._dwmAligner.timeToSessionStart(e.time)),this._putToCacheNewBar(e),this._subscribers.forEach(t=>{const i=t.barset;if(null===i)throw new Error("subscriber.barset is null");i.add(e),t.onHistoryCallback(i)})},d(this._symbolInfo,this._resolution),()=>{this._unsubscribeRealtime();const e=this._leftDate;this._purgeCache(),null!==e&&this._ensureRequestedTo({to:e,countBack:0})}),this._logMessage("Subscribed to realtime")}_unsubscribeRealtime(){!this._isSymbolExpired()&&this._realtimeOn&&(this._datafeed.unsubscribeBars(d(this._symbolInfo,this._resolution)),this._logMessage("Unsubscribed from realtime"),this._realtimeOn=!1)}_returnHistoryDataToSubscriber(e,t){const i=this._normalizeRange(e.range),s=this._createBarsetForRange(i);s.count()>0?this._logMessage("Bars to return for request {0}: total {1} bars in [{2} ... {3}] ".format(e.key,s.count(),u(s.bars[0].time),u(s.bars[s.count()-1].time))):this._logMessage("Request {0}. Nothing to return.".format(e.key)),t.barset=s,this._endOfData&&null!==this._leftDate&&i.to<=this._leftDate&&(s.endOfData=!0),e.onHistoryCallback(s)}_createBarsetForRange(e){const t=null!==this._dwmAligner?this._dwmAligner.timeToSessionStart(e.to):e.to,i=(0,n.lowerbound)(this._cache.bars,t,(e,t)=>e.time<t),r=new o.BarSet(this._symbolInfo,this._cache.bars.slice(Math.max(0,i-e.countBack)));return 0!==r.bars.length?r.firstLoadedTimeMs=this._dealignTime(r.bars[0].time):0!==this._cache.bars.length?r.firstLoadedTimeMs=this._dealignTime(this._cache.bars[this._cache.bars.length-1].time):r.firstLoadedTimeMs=this._dealignTime((0,s.ensureNotNull)(this._leftDate)),r}_ensureRequestedTo(e){var t;let i;if(this._requesting&&this._logMessage("Internal error: trying to call getBars while the previous request is active",!0),null!==this._leftDate)i=this._leftDate;else{const e=this._now();if(null===this._dwmAligner)i=e;else{let t=this._sessionSpec.alignToNearestSessionStart(new Date(e),1).getTime();if(t<e){const e=this._sessionSpec.alignToNearestSessionEnd(new Date(t),1).getTime();t=this._sessionSpec.alignToNearestSessionStart(new Date(e+1e3),1).getTime()}i=this._dealignTime(t)}}const s=(0,l.alignPeriodsBackForDataRequest)(this._symbolInfo.session,this._symbolInfo.session_holidays,this._symbolInfo.corrections,this._interval.letter(),this._interval.multiplier(),e.countBack,Math.min(e.to,i,null!==(t=this._nextTime)&&void 0!==t?t:1/0));let r=e.countBack;if(e.to<i&&(r+=(0,l.getPeriodsBetweenDates)(this._symbolInfo.session,this._symbolInfo.session_holidays,this._symbolInfo.corrections,this._interval.letter(),this._interval.multiplier(),e.to,i)),null!==this._leftDate&&this._leftDate<s)return void this._processPendingSubscribers()
|
||||
;const n=this._isSymbolExpired()?0===this._cache.bars.length:null===this._leftDate;this._requesting=!0,this._nextTime=null,this._leftDate=s;const o=`[${u(s)} ... ${u(i)}, ${r} bars]`;this._logMessage("Requesting data: "+o);let a=!1;const c=s/1e3,h=i/1e3;this._datafeed.getBars(this._symbolInfo,this._resolution,{from:this._interval.isTicks()?c:Math.floor(c),to:this._interval.isTicks()?h:Math.floor(h),countBack:r,firstDataRequest:n},(e,t)=>{if(!this._destroyed)if(a)this._logMessage("getBars callback is already called before",!0);else{if(a=!0,e.length>0){const t=` [${u(e[0].time)} ... ${u(e[e.length-1].time)}]`;this._logMessage(`Receiving bars: total ${e.length} bars in ${t}, requested range: ${o}`)}else this._logMessage("Receiving bars: barset is empty, requested range: "+o);this._requesting=!1,this._processBars(e,t)}},e=>{this._destroyed||(a?this._logMessage("getBars callback is already called before",!0):(a=!0,this._requesting=!1,this._errorMessage=e||null,this._processPendingSubscribers()))})}_processBars(e,t){this._checkBars(e),this._alignBarsTime(e),e.length>0?(this._emptyResponsesCount=0,this._processFullBarset(e,t)):(this._emptyResponsesCount+=1,this._processEmptyBarset(t)),this._processPendingSubscribers()}_processEmptyBarset(e){e&&e.nextTime?(this._logMessage("Next time received: `{0}`".format(u(1e3*e.nextTime))),this._nextTime=1e3*e.nextTime):e&&e.noData?(this._logMessage("EOD received"),this._setEndOfData()):this._logMessage("nextTime or noData should present in metainfo when empty barset is returned"),50===this._emptyResponsesCount&&(this._logMessage("EOD detected due 50 empty responses in a row"),this._setEndOfData())}_setEndOfData(){this._endOfData=!0,this._cache.bars.length&&(this._leftDate=this._dealignTime(this._cache.bars[0].time))}_processFullBarset(e,t){this._putToCache(e)?null!==this._leftDate&&0!==this._cache.bars.length&&(this._interval.isTicks()?this._leftDate=this._dealignTime(this._cache.bars[0].time):this._leftDate=Math.min(this._leftDate,this._dealignTime(this._cache.bars[0].time))):this._logMessage("Incremental update failed. Starting full update. Returned data should be in the requested range.",!0),t&&t.nextTime?console.warn("nextTime should be set when there is no data in the requested period only"):t&&t.noData&&console.warn("noData should be set when there is no data in the requested period and earlier only")}_getNextSubscriptionId(){return this._nextSubscriptionId++}_checkBars(e,t=!1){if(a.enabled("charting_library_debug_mode"))for(let i=1;i<e.length;i++){if(e[i].time<=e[i-1].time){let s="Wrong bars time: time {0} of bar {1} should be more than time {2} of bar {3}".format(e[i].time,i,e[i-1].time,i-1);t&&null!==this._dwmAligner&&(s+="\nCheck that you provide DWM bars without time part, i.e. 00:00 GMT"),console.error(s)}["high","low","open","close","time"].some(t=>"number"!=typeof e[i][t]||!isFinite(e[i][t]))&&console.error("Wrong bars values: all OHLC values should be numbers")}}_putToCache(e){if(0===e.length)return!0
|
||||
;if(this._cache.bars.length===e.length&&this._cache.bars[0].time===e[0].time&&this._cache.bars[this._cache.bars.length-1].time===e[e.length-1].time)return this._logMessage("Time range of received data is the same as cached one. Skip the update."),!0;if(0!==this._cache.bars.length&&e[e.length-1].time===this._cache.bars[0].time&&this._cache.bars.splice(0,1),0!==this._cache.bars.length&&e[e.length-1].time>=this._cache.bars[0].time){const t=this._cache.bars[this._cache.bars.length-1].time===e[e.length-1].time;if(this._cache.bars=[],!t)return this._leftDate=null,!1;this._logMessage("Received history up to now instead of incremental update. Return exactly what is requested.")}return this._cache.bars=[...e,...this._cache.bars],this._checkBars(this._cache.bars,!0),!0}_putToCacheNewBar(e){const t=this._cache.bars.length,i=e.time,s=0===t?NaN:this._cache.bars[t-1].time;0===t||s<i?this._cache.bars.push(e):s===i?(this._interval.isTicks()&&this._logMessage("Received update for the last tick bar"),this._cache.bars[t-1]=e):console.error("putToCacheNewBar: time violation, previous bar time: "+u(s)+" should be less or equal to new time: "+u(i))}_alignBarsTime(e){if(this._dwmAligner)for(const t of e)t.time=this._dwmAligner.timeToSessionStart(t.time)}_now(){return Date.now()+1e3*this._serverTimeOffsetGetter()+6e4}}class _{constructor(e,t,i){this._threads={},this._datafeed=e,this._serverTimeOffsetGetter=t,this._resetCacheTimePeriod=i}destroy(){this._forEachThread((e,t)=>t.destroy()),this._threads={},delete this._datafeed}purgeCache(){this._forEachThread((e,t)=>t.destroy()),this._threads={}}subscribe(e,t,i,s,r){const n=d(e,t);this._threads[n]||(this._threads[n]=this._createThread(e,t));return n+'"'+this._threads[n].addSubscription(i,s,r)}unsubscribe(e){const t=e.split('"');if(2!==t.length)return void console.warn("Wrong guid format");const i=t[0],s=parseInt(t[1]);this._threads.hasOwnProperty(i)?this._threads[i].removeSubscription(s):console.warn("Data thread doesnt exist: "+e)}_createThread(e,t){return new p(this._datafeed,e,t,this._serverTimeOffsetGetter,(0,c.createDwmAligner)(t,e),this._resetCacheTimePeriod)}_forEachThread(e){Object.keys(this._threads).forEach(t=>e(t,this._threads[t]))}}},42934:(e,t,i)=>{"use strict";i.d(t,{barTimeToEndOfPeriod:()=>r,endOfPeriodToBarTime:()=>n});var s=i(68684);function r(e,t,i){if(i.isDays())return t;if(e.moveTo(1e3*t),i.isIntraday()){const i=e.indexOfBar(1e3*t);if(i<0)throw new Error(t+" is out of the instrument session ");return e.endOfBar(i)/1e3}return e.startOfBar(s.SessionStage.LASTBAR_SESSION)/1e3}function n(e,t,i){if(i.isDays())return t;const s=1e3*t-1;if(e.moveTo(s),i.isIntraday()){const i=e.indexOfBar(s);if(i<0)throw new Error(t+" is out of the instrument session ");return e.startOfBar(i)/1e3}return t=e.startOfBar(0)/1e3}},79283:(e,t,i)=>{"use strict";i.d(t,{replaceGraphicsTimesWithTimePointIndexIndex:()=>n})
|
||||
;const s=new Map([["horizlines",e=>[e.startIndex,e.endIndex]],["hhists",e=>[e.firstBarTime,e.firstBarTime]],["vertlines",e=>[e.index]],["polygons",e=>e.points.map(e=>e.index)],["backgrounds",e=>[e.start,e.stop]]]),r=new Map([["horizlines",(e,t)=>{const i=e;i.startIndex=t.get(i.startIndex),i.endIndex=t.get(i.endIndex)}],["hhists",(e,t)=>{const i=e;i.firstBarTime=t.get(i.firstBarTime),i.lastBarTime=t.get(i.lastBarTime)}],["vertlines",(e,t)=>{const i=e;i.index=t.get(i.index)}],["polygons",(e,t)=>{const i=e;for(const e of i.points)e.index=t.get(e.index)}],["backgrounds",(e,t)=>{const i=e;i.start=t.get(i.start),i.stop=t.get(i.stop)}]]);function n(e){const t=e.data&&e.data.graphicsCmds&&e.data.graphicsCmds.create;if(!t)return[];const i=new Map,n=new Set;s.forEach((e,s)=>{const r=t[s];if(r)for(const t of r)for(const s of t.data){const t=e(s);for(const e of t)i.set(e,-1),n.add(e)}});const o=Array.from(n).sort((e,t)=>e-t);return o.forEach((e,t)=>i.set(e,t)),r.forEach((e,s)=>{const r=t[s];if(r)for(const t of r)for(const s of t.data)e(s,i)}),o}},65235:(e,t,i)=>{"use strict";var s=i(67337);window.onload=function(){location.hostname.indexOf(".")>=0&&!function(){try{return/^(192|172|10)\.[0-9][0-9][0-9]\.[0-9][0-9][0-9]\.[0-9][0-9][0-9]/.test(location.hostname)||/^.*((?:\.local)|localhost)$/.test(location.hostname)}catch(e){return!1}}()&&setTimeout((function(){try{var e=function(){var e=0;return JSON.parse(urlParams.logo).image&&(e="C",s.enabled("link_to_tradingview")||(e="D")),e}();window.ga&&(0!==e&&window.ga("send","event","s",e),urlParams.utm||window.ga("send","event","l"))}catch(e){}}),3e4)}},41728:(e,t,i)=>{"use strict";var s=i(69177),r={};e.exports=function(e,t,i){var n,o,a={},l=r[i]||"out_of_session",c=!1,h=i,d=t,u=null;function p(){var e={};e.symbolname=h,e.status="ok",e.values={},e.values.current_session=l,r[h]=l,TradingView.ChartapiMessagerInstances[d].onQuotesData([d].concat([e]))}function _(){if(n)if(o)l="out_of_session";else{var e=s.isTradingNow((new Date).getTime(),n)?"market":"out_of_session";e!==l&&(l=e,p())}}return e(i,null,(function(e){c||function(e){n=new s.SessionInfo(e.timezone,e.session,e.session_holidays,e.corrections),o=e.expired,u=setInterval(_,6e4),_(),p()}(e)}),(function(){})),a.stop=function(){c=!0,u&&clearInterval(u)},a.marketStatus=function(){return l},a}},11565:(e,t,i)=>{"use strict";i.d(t,{getChartStyleStudy:()=>n});var s=i(216);class r{main(e){const t=e.new_var(s.Std.open(e)),i=e.new_var(s.Std.close(e)),r=t.get(1),n=i.get(1),o=s.Std.ohlc4(e),a=s.Std.na(t.get(1))?(s.Std.open(e)+s.Std.close(e))/2:(r+n)/2;t.set(a),i.set(o);const l=s.Std.max(s.Std.high(e),s.Std.max(a,o)),c=s.Std.min(s.Std.low(e),s.Std.min(a,o)),h=s.Std.volume(e),d=e.symbol;return[d.time,a,l,c,o,h,d.updatetime,d.isBarClosed]}}function n(e){if(0===e.type.indexOf("BarSetHeikenAshi@tv-basicstudies-"))return new r;const t="unknown builder type: "+e.type;throw console.error(t),new Error(t)}},37750:(e,t,i)=>{"use strict"
|
||||
;var s=i(29823).Interval,r=i(65862).isAlignmentEnabled,n=i(11565).getChartStyleStudy,o=i(19234).decodeExtendedSymbol,a=i(983).findSuitableResolutionToBuildFrom,l=i(28930).SubsessionId,c=function(){var e=i(216),t=e.StudyEngine,c=e.BarBuilder,h=e.BarSet;function d(e){this.host=e,this.cache={}}function u(t){console.error(t),e.Std.error(t)}d.prototype.getCache=function(e){return this.cache[e]},d.prototype.putCache=function(e,t){this.cache[e]=t},d.prototype.subscribe=function(e,t,i,s,r,n,o,a,l,c,h){var d=l(o),u=function(e,t,i,s,r,n,o,a,l){var c=r.has_empty_bars?"_":"";return n+e+s+(t||"")+(i||"")+(l||"")+c+"_"+o.countBack+"_"+o.to+"_"+Boolean(a)}(e,t,i,s,o,a,d,c,h),p=this.getCache(u);return p||(p=this.createItem(e,t,i,s,o,d,a,c,h),this.putCache(u,p)),p.listeners.addListener(r,n),{key:u,listener:r}},d.prototype.unsubscribe=function(e){var t=this.getCache(e.key);t&&t.listeners.removeListener(e.listener)},d.prototype.removeUnused=function(){var e=[];for(var t in this.cache){if(this.cache[t])0===this.cache[t].listeners.listenersCount()&&e.push(t)}if(0!==e.length){for(var i=0;i<e.length;i++){var s=e[i],r=this.cache[s];this.cache[s]=null,r.stop()}this.removeUnused()}},d.prototype.rebuildFrom=function(e,t){var i=a(e,t);return i.error&&u(i.errorMessage),i.resolution};var p=s.parse("1M").inMilliseconds(0);d.prototype.createItem=function(e,t,i,a,h,d,f,v,S){var y=new g,b=o(e),w="string"!=typeof b.symbol?b.symbol:b;t=w["currency-id"]||t,i=w["unit-id"]||i;var C=w.symbol,P=w.session&&w.session!==l.Extended;if((S=w.session||S)===l.Regular&&(S=void 0),"type"in b){var T=Object.assign({},h);return h.has_empty_bars&&(T.has_empty_bars=!1),new m(y,C,t,i,a,n(b),T,d,f,S)}v&&!r()&&u("Internal error: rebuilding is requested but it is disabled."),!v&&h.has_empty_bars&&u('Misconfiguration error: attempt to request data for symbol with "has_empty_bars" flag, but "disable_resolution_rebuild" featureset is enabled');var x,I,M=this.rebuildFrom(a,h);if(!s.isTicks(a)&&(!s.isEqual(a,M)||v)){r()||u('Misconfiguration error: remove "disable_resolution_rebuild" featureset or provide '+a+" data by yourself");var L=h.has_empty_bars;T=Object.assign({},h);h.has_empty_bars&&(T.has_empty_bars=!1);var A=Math.ceil((x=s.parse(a),I=s.parse(M),x.kind()===I.kind()?x.multiplier()/I.multiplier():(x.isMonths()?x.multiplier()*p:x.inMilliseconds())/(I.isMonths()?I.multiplier()*p:I.inMilliseconds())));return d=Object.assign({},d,{countBack:d.countBack*A}),new m(y,e,t,i,M,new c(a,L),T,d,f,S)}return new _(y,C,{currency:t,unit:i,session:S},a,P,this.host,h,d)};var _=function(e,t,i,s,r,n,o,a){this.listeners=e,this.host=n;var l=this;this.host.resolve(t,i,(function(e){r&&e.regular_session&&(e.session=e.regular_session),l.subs=l.host.subscribe(e,s,a,(function(e){l.listeners.fire(e)}),(function(e){l.listeners.onError(e)}))}),(function(e){l.listeners.onError(e)}))};_.prototype.stop=function(){this.subs&&this.host.unsubscribe(this.subs)};var m=function(e,i,s,r,n,o,a,l,c,h){this.listeners=e,this.isRecalculated=!1,this.symbolInfo=a;var d=this;this.engine=new t({tickerid:i,currencyCode:s,
|
||||
unitId:r,subsessionId:h,period:n,body:o,sessionId:c,symbolInfo:a,dataRange:l,forceAlignBars:!1,recalc:function(e,t){d._recalc(t)},out:function(e,t){d._out(e,t)},nonseriesOut:function(e,t){d._nonseriesOut(e,t)},setNoMoreData:function(){d.barset&&(d.barset.endOfData=!0)},onErrorCallback:function(e){d.listeners.onError(e)}})};m.prototype.stop=function(){this.engine?this.engine.stop():console.error("Internal library error 0x1")},m.prototype._recalc=function(e){this.isRecalculated&&console.error("recalc called twice!"),this.barset||(this.barset=new h(this.symbolInfo)),e&&(this.barset.firstLoadedTimeMs=e.firstLoadedTimeMs,this.barset.endOfData=e.endOfData),this.listeners.fire(this.barset),this.isRecalculated=!0},m.prototype._nonseriesOut=function(e,t){var i=Object.assign({},t);i.nonseries=!0,i.data=t.bars,delete i.bars,i.barsetSize=this.barset?this.barset.count():0,i.lastBar=this.barset?this.barset.bar(this.barset.count()-1):null,this.listeners.fire(i,!0)},m.prototype._out=function(e,t){var i=t[0];if(!isNaN(i)){var s={time:i,open:t[1],high:t[2],low:t[3],close:t[4],volume:t[5],updatetime:t[6]},r=t[7];this.barset||(this.barset=new h(e.info));var n=t[8];if(n instanceof Array)for(var o=0;o<n.length;o++){var a=t[9],l=n[o],c={time:l,open:a,high:a,low:a,close:a,volume:0,updatetime:l};this.barset.add(c,!0,!0),this.isRecalculated&&this.listeners.fire(this.barset)}this.barset.add(s,r),this.barset.isBarClosed=r,this.isRecalculated&&this.listeners.fire(this.barset)}};var g=function(){this.listeners=[]};return g.prototype.listenersCount=function(){return this.listeners.reduce((function(e,t){return e+(t?1:0)}),0)},g.prototype.addListener=function(e,t){this.listeners.push({dataListener:e,onErrorCallback:t}),this.barset&&e(this.barset),this.errorMsg&&t(this.errorMsg)},g.prototype.removeListener=function(e){var t=this.listeners.filter((function(t){return t.dataListener===e}));if(0!==t.length){var i=this.listeners.indexOf(t[0]);delete this.listeners[i]}},g.prototype.onError=function(e){this.errorMsg=e||"unspecified error";for(var t=this.listeners,i=t.length,s=0;s<i;s++){var r=t[s];r&&r.onErrorCallback&&r.onErrorCallback(e)}},g.prototype.fire=function(e,t){t||(this.barset=e);for(var i=this.listeners,s=i.length,r=0;r<s;r++){var n=i[r];n&&n.dataListener(e)}},{setupFeed:function(t){d.instance=new d(t),e.setupFeed(d.instance)},unsubscribeUnused:function(){d.instance.removeUnused()}}}();e.exports=c},983:(e,t,i)=>{"use strict";i.d(t,{findSuitableResolutionToBuildFrom:()=>o});var s=i(29823);function r(e,t){const i=t.multiplier();for(let s=e.length-1;s>=0;s--){const r=Number(e[s]);if(i%r==0)return{error:!1,resolution:`${r}${t.letter()}`}}return{error:!0,errorMessage:n(t.value())}}function n(e){return`Misconfiguration error: it is trying to request ${e} but we cannot build it from lower resolution`}function o(e,t){const i=s.Interval.parse(e);if((i.isWeeks()||i.isMonths())&&t.has_weekly_and_monthly){let e=["1"];i.isWeeks()&&void 0!==t.weekly_multipliers&&(e=t.weekly_multipliers),i.isMonths()&&void 0!==t.monthly_multipliers&&(e=t.monthly_multipliers)
|
||||
;const s=r(e,i);if(!s.error)return s}if(i.isDWM()&&(void 0===t.has_daily||t.has_daily))return i.isDays()&&void 0!==t.daily_multipliers?r(t.daily_multipliers,i):void 0===t.daily_multipliers||t.daily_multipliers.includes("1")?{error:!1,resolution:"1D"}:{error:!0,errorMessage:"Misconfiguration error: it is trying to request a resolution but symbol does not support it"};if(i.isDWM())return{error:!0,errorMessage:n(i.value())};if(i.isMinutes()&&!t.has_intraday)return{error:!0,errorMessage:"Misconfiguration error: it is trying to request intraday resolution but symbol does not support it"};if(i.isSeconds()&&!t.has_seconds)return{error:!0,errorMessage:"Misconfiguration error: it is trying to request seconds resolution but symbol does not support it"};if(i.isTicks())return!t.has_ticks||i.multiplier()>1?{error:!0,errorMessage:`Misconfiguration error: it is trying to request ${i.multiplier()} ticks resolution but symbol does not support it`}:{error:!1,resolution:"1T"};const o=i.isSeconds()?t.seconds_multipliers:t.intraday_multipliers;return void 0===o?{error:!1,resolution:i.value()}:r(o,i)}},216:function(e,t,i){"use strict";var s=i(54631).StudyError,r=i(55257),n=i(80643).inherit,o=i(68684).SessionStage,a=i(29823).Interval,l=i(65862).createDwmAligner,c=i(65862).createTimeToBarTimeAligner,h=i(19234).decodeExtendedSymbol,d=i(19234).encodeExtendedSymbolOrGetSimpleSymbolString,u=i(28930).SubsessionId,p=i(37415).PrePostMarketBarIdentifier,_=i(90388).SessionSpec,m=function(){var e,t="undefined"!=typeof window?window:i.g,g=t.PineJsCalendar?t.PineJsCalendar:i(10480),f=i(69177),v=i(11075).extrapolateBarsFrontToTime,S={};function y(e,t,i,s,r){var n=r,o=0;if(isNaN(e.get(t-1)))return{index:NaN,value:NaN};for(var a=0;a<t;++a)s(e.get(a),n)&&(o=a,n=e.get(a));return{index:o,value:n}}function b(e,t,i,s,r){this._areaRight=e,this._areaLeft=t,this._pivotType=i,this._series=s,this._currentIndex=r.new_var(0),this._currentValue=r.new_var(NaN),this._pivotIndex=r.new_var(-1),this._index=S.n(r),this._isNewBar=r.symbol.isNewBar;var n=this._currentIndex.get(1),o=this._currentValue.get(1),a=this._pivotIndex.get(1);this._index>1&&(this._currentIndex.set(n),this._currentValue.set(o),this._pivotIndex.set(a))}function w(e,t,i){this._deviation=e;var s=i.new_var(S.high(i)),r=i.new_var(S.low(i));s.get(2*t+1),r.get(2*t+1),this._pivotHigh=new b(t,t,b.HIGH,s,i),this._pivotLow=new b(t,t,b.LOW,r,i),this._lastVal=i.new_var(NaN),this._lastIndex=i.new_var(-1),this._lastType=i.new_var(),this._index=S.n(i),this._isNewBar=i.symbol.isNewBar,this._isBarClosed=i.symbol.isBarClosed;var n=this._lastIndex.get(1),o=this._lastVal.get(1),a=this._lastType.get(1);this._index>1&&this.addPivot(n,o,a),this.processPivot(this._pivotHigh),this.processPivot(this._pivotLow)}function C(e){this.symbol=e,this.vars=[],this.vars_index=0,this.ctx=[],this.ctx_index=0,this.minimumAdditionalDepth=null}function P(e){this.mindepth=0,this.original=NaN,this.modified=!1,this.symbol=e}function T(e){P.call(this,e)}function x(e,t,i,s,r,n,o){var l=h(e);const c="string"==typeof l.symbol?l:l.symbol
|
||||
;this.ticker=c.symbol,this.currencyCode=i||c["currency-id"],this.unitId=s||c["unit-id"],this.subsessionId=o||c.session;var u=c["currency-id"]!==this.currencyCode||c["unit-id"]!==this.unitId;c["currency-id"]=this.currencyCode,c["unit-id"]=this.unitId,u&&(e=d(l)),this.tickerid=e;var p=a.parse(t);this.resolution=p.letter(),this.interval=p.multiplier(),this.period=p.value(),this.index=-1,this.time=NaN,this.open=NaN,this.high=NaN,this.low=NaN,this.close=NaN,this.volume=NaN,this.updatetime=NaN,this.isNewBar=!1,this.isBarClosed=!1,this.session=new f.SessionInfo("Etc/UTC","24x7"),this.regularSubsession=null,this.preMarketSubsession=null,this.postMarketSubsession=null,this.script=r,this.isAdditionalDepthAllowed=void 0===l.type,n&&this.set_symbolinfo(n)}function I(e,t,i,s,r,n,o,a,l,c,h){this.body=n,this.symbols=[],this.runner=r,this.inputCallback=a,this.out=o,this.nonseriesOut=l,this.ctx=new C(this.add_sym(e,t,i,s,c,h)),this.init()}function M(e){this.symbols=[],this.barsets=[],this.subscription=[],this.host=e,this.isRecalculated=!1,this.isStarted=!1,this.start()}function L(e){this.runner=new M(e)}function A(e,t){this.info=e,this.bars=t||[],this.isBarClosed=!0,this.firstLoadedTimeMs=0!==this.bars.length?this.bars[0].time:1/0,this._emptyBarCount=0,this._lastBarIsEmpty=!1}function E(e,t){this.period=e,this.generateEmptyBars=!!t}function k(){}return S.max_series_default_size=10001,S.n=function(e){return e.symbol.index+1},S.nz=function(e,t){return t=t||0,isFinite(e)?e:t},S.na=function(e){return 0===arguments.length?NaN:isNaN(e)?1:0},S.isZero=function(e){return Math.abs(e)<=1e-10},S.toBool=function(e){return isFinite(e)&&!S.isZero(e)},S.eq=function(e,t){return S.isZero(e-t)},S.neq=function(e,t){return!S.eq(e,t)},S.ge=function(e,t){return S.isZero(e-t)||e>t},S.gt=function(e,t){return!S.isZero(e-t)&&e>t},S.lt=function(e,t){return!S.isZero(e-t)&&e<t},S.le=function(e,t){return S.isZero(e-t)||e<t},S.and=function(e,t){return isNaN(e)||isNaN(t)?NaN:S.isZero(e)||S.isZero(t)?0:1},S.or=function(e,t){return isNaN(e)||isNaN(t)?NaN:S.isZero(e)&&S.isZero(t)?0:1},S.not=function(e){return isNaN(e)?NaN:S.isZero(e)?1:0},S.eps=function(){return 1e-10},S.greaterOrEqual=function(e,t,i){return t-e<(i||1e-10)},S.lessOrEqual=function(e,t,i){return e-t<(i||1e-10)},S.equal=function(e,t,i){return Math.abs(e-t)<(i||1e-10)},S.greater=function(e,t,i){return e-t>(i||1e-10)},S.less=function(e,t,i){return t-e>(i||1e-10)},S.compare=function(e,t,i){return S.equal(e,t,i)?0:S.greater(e,t,i)?1:-1},S.max=Math.max,S.min=Math.min,S.pow=Math.pow,S.abs=Math.abs,S.log=Math.log,S.log10=function(e){return Math.log(e)/Math.LN10},S.sqrt=Math.sqrt,S.sign=function(e){return isNaN(e)?NaN:S.isZero(e)?0:e>0?1:-1},S.exp=Math.exp,S.sin=Math.sin,S.cos=Math.cos,S.tan=Math.tan,S.asin=Math.asin,S.acos=Math.acos,S.atan=Math.atan,S.floor=Math.floor,S.ceil=Math.ceil,S.round=Math.round,S.avg=function(e,t,i,s,r,n){if(2===arguments.length)return(e+t)/2;for(var o=0,a=0;a<arguments.length;a++)o+=arguments[a];return o/arguments.length},S.open=function(e){return e.symbol.open},S.high=function(e){
|
||||
return e.symbol.high},S.low=function(e){return e.symbol.low},S.close=function(e){return e.symbol.close},S.hl2=function(e){return(e.symbol.high+e.symbol.low)/2},S.hlc3=function(e){return(e.symbol.high+e.symbol.low+e.symbol.close)/3},S.ohlc4=function(e){return(e.symbol.open+e.symbol.high+e.symbol.low+e.symbol.close)/4},S.volume=function(e){return e.symbol.volume},S.updatetime=function(e){return e.symbol.updatetime},S.time=function(e){return e.symbol.bartime()},S.period=function(e){return e.symbol.period},S.tickerid=function(e){return e.symbol.tickerid},S.currencyCode=function(e){return e.symbol.currencyCode},S.unitId=function(e){return e.symbol.unitId},S.ticker=function(e){return e.symbol.ticker},S.interval=function(e){return e.symbol.interval},S.isdwm=function(e){return e.symbol.isdwm()},S.isintraday=function(e){return!e.symbol.isdwm()},S.isdaily=function(e){return"D"===e.symbol.resolution},S.isweekly=function(e){return"W"===e.symbol.resolution},S.ismonthly=function(e){return"M"===e.symbol.resolution},S.year=function(e){return S.timepart(e.symbol,g.YEAR,arguments[1])},S.month=function(e){return S.timepart(e.symbol,g.MONTH,arguments[1])},S.weekofyear=function(e){return S.timepart(e.symbol,g.WEEK_OF_YEAR,arguments[1])},S.dayofmonth=function(e){return S.timepart(e.symbol,g.DAY_OF_MONTH,arguments[1])},S.dayofweek=function(e){return S.timepart(e.symbol,g.DAY_OF_WEEK,arguments[1])},S.hour=function(e){return S.timepart(e.symbol,g.HOUR_OF_DAY,arguments[1])},S.minute=function(e){return S.timepart(e.symbol,g.MINUTE,arguments[1])},S.second=function(e){return S.timepart(e.symbol,g.SECOND,arguments[1])},S.add_days_considering_dst=function(e,t,i){return g.add_days_considering_dst(g.get_timezone(e),t,i)},S.selectSessionBreaks=function(e,t){if(S.isdwm(e)||void 0===e.symbol.session.timezone)return[];var i=f.newBarBuilder(e.symbol.period,e.symbol.session),s=[],r=t.length;if(i.moveTo(t[r-1]),1===r&&i.startOfBar(0)===t[0])s.push(t[0]);else{for(var n=r-2;n>=0;--n){var o=t[n];if(!(o>=i.startOfBar(0))){i.moveTo(o);var a=t[n+1];s.push(a)}}s.reverse()}return s},S.iff=function(e,t,i){return S.not(e)?i:t},S.rising=function(e,t){for(var i=1;i<t+1;++i)if(e.get(i)>e.get(0))return 0;return 1},S.falling=function(e,t){for(var i=1;i<t+1;++i)if(e.get(i)<e.get(0))return 0;return 1},S.timepart=function(e,t,i){var s=g.utc_to_cal(e.timezone,i||e.bartime());return g.get_part(s,t)},S.rsi=function(e,t){return S.isZero(t)?100:S.isZero(e)?0:100-100/(1+e/t)},S.selectPreAndPostMarketTimes=function(e,t){if(S.isdwm(e)||void 0===e.symbol.session.timezone)return{preMarket:[],postMarket:[]};if(null===e.symbol.regularSubsession||null===e.symbol.preMarketSubsession||null===e.symbol.postMarketSubsession)return{preMarket:[],postMarket:[]};return new p(e.symbol.timezone,e.symbol.regularSubsession,e.symbol.preMarketSubsession,e.symbol.postMarketSubsession).getPreAndPostMarketTimes(t)},S.sum=function(e,t,i){var s=i.new_var(),r=S.nz(e.get())+S.nz(s.get(1))-S.nz(e.get(t));return s.set(r),r},S.sma=function(e,t,i){var s=S.sum(e,t,i);return S.na(e.get(t-1))?NaN:s/t},
|
||||
S.smma=function(e,t,i){var s=i.new_var(e),r=m.Std.sma(s,t,i),n=i.new_var(),o=(n.get(1)*(t-1)+e)/t;return n.set(m.Std.na(n.get(1))?r:o),n.get(0)},S.rma=function(e,t,i){var s=S.sum(e,t,i),r=t-1,n=e.get(r),o=i.new_var(),a=o.get(1),l=e.get(),c=S.na(n)?NaN:S.na(a)?s/t:(l+a*r)/t;return o.set(c),c},S.fixnan=function(e,t){var i=t.new_var();return isNaN(e)?i.get(1):(i.set(e),e)},S.tr=function(e,t){1===arguments.length&&(t=e,e=void 0);var i=void 0!==e&&!!e,s=t.new_var(S.close(t)),r=s.get(1);return i&&isNaN(r)&&(r=S.close(t)),S.max(S.max(S.high(t)-S.low(t),S.abs(S.high(t)-r)),S.abs(S.low(t)-r))},S.atr=function(e,t){var i=t.new_var(S.tr(t));return S.rma(i,e,t)},S.ema=function(e,t,i){var s=S.sum(e,t,i),r=i.new_var(),n=e.get(0),o=e.get(t-1),a=r.get(1),l=S.na(o)?NaN:S.na(a)?s/t:2*(n-a)/(t+1)+a;return r.set(l),l},S.wma=function(e,t,i){for(var s=0,r=t=Math.round(t);r>=0;r--){s+=(t-r)*e.get(r)}return 2*s/(t*(t+1))},S.vwma=function(e,t,i){var s=i.new_var(S.volume(i)),r=i.new_var(e.get(0)*S.volume(i));return S.sma(r,t,i)/S.sma(s,t,i)},S.swma=function(e,t){return(e.get(0)+2*e.get(1)+2*e.get(2)+e.get(3))/6},S.supertrend=function(e,t,i){var s=m.Std.atr(t,i),r=i.new_var(s).get(1),n=m.Std.hl2(i),o=n+s*e,a=n-s*e,l=m.Std.close(i),c=i.new_var(l).get(1),h=i.new_var(),d=m.Std.nz(h.get(1)),u=i.new_var(),p=m.Std.nz(u.get(1));a=S.gt(a,d)||S.lt(c,d)?a:d,h.set(a),o=S.lt(o,p)||S.gt(c,p)?o:p,u.set(o);var _=m.Std.na(),g=i.new_var(),f=g.get(1),v=-1===(_=m.Std.na(r)?1:f===p?l>o?-1:1:l<a?1:-1)?a:o;return g.set(v),[v,_]},S.lowestbars=function(e,t,i){return-y(e,t,0,(function(e,t){return S.lt(e,t)}),Number.MAX_VALUE).index},S.lowest=function(e,t,i){return y(e,t,0,(function(e,t){return S.lt(e,t)}),Number.MAX_VALUE).value},S.highestbars=function(e,t,i){return-y(e,t,0,(function(e,t){return S.gt(e,t)}),Number.MIN_VALUE).index},S.highest=function(e,t,i){return y(e,t,0,(function(e,t){return S.gt(e,t)}),Number.MIN_VALUE).value},S.cum=function(e,t){var i=t.new_var(),s=S.nz(i.get(1))+e;return i.set(s),s},S.accdist=function(e){var t=S.high(e),i=S.low(e),s=S.close(e),r=S.volume(e);return S.cum(s===t&&s===i||t===i?0:r*(2*s-i-t)/(t-i),e)},S.correlation=function(e,t,i,s){var r=S.sma(e,i,s),n=S.sma(t,i,s),o=s.new_var(e.get()*t.get());return(S.sma(o,i,s)-r*n)/Math.sqrt(S.variance2(e,r,i)*S.variance2(t,n,i))},S.stoch=function(e,t,i,s,r){var n=S.highest(t,s),o=S.lowest(i,s);return S.fixnan(100*(e.get()-o)/(n-o),r)},S.tsi=function(e,t,i,s){var r=s.new_var(S.change(e)),n=s.new_var(S.abs(S.change(e))),o=s.new_var(S.ema(r,i,s)),a=s.new_var(S.ema(n,i,s));return S.ema(o,t,s)/S.ema(a,t,s)},S.cross=function(e,t,i){if(isNaN(e)||isNaN(t))return!1;var s,r=i.new_var((s=e-t)<0?-1:0===s?0:1);return!isNaN(r.get(1))&&r.get(1)!==r.get()},S.linreg=function(e,t,i){for(var s=0,r=0,n=0,o=0,a=0;a<t;++a){var l=e.get(a),c=t-1-a+1;s+=c,r+=l,n+=c*c,o+=l*c}var h=(t*o-s*r)/(t*n-s*s);return r/t-h*s/t+h+h*(t-1-i)},S.sar=function(e,t,i,s){
|
||||
var r=s.new_var(),n=s.new_var(),o=s.new_var(),a=S.high(s),l=S.low(s),c=S.close(s),h=s.new_var(a),d=s.new_var(l),u=s.new_var(c),p=s.new_var(),_=p.get(1),m=n.get(1),g=o.get(1);n.set(m),o.set(g);var f=!1,v=d.get(1),y=d.get(2),b=h.get(1),w=h.get(2),C=u.get(),P=u.get(1);2===S.n(s)&&(S.greater(C,P)?(r.set(1),o.set(h.get()),_=v,g=h.get()):(r.set(-1),o.set(d.get()),_=b,g=d.get()),f=!0,n.set(e),m=e);var T=_+m*(g-_);return 1===r.get()?S.greater(T,d.get())&&(f=!0,r.set(-1),T=Math.max(h.get(),o.get()),o.set(d.get()),n.set(e)):S.less(T,h.get())&&(f=!0,r.set(1),T=Math.min(d.get(),o.get()),o.set(h.get()),n.set(e)),f||(1===r.get()?S.greater(h.get(),o.get())&&(o.set(h.get()),n.set(Math.min(n.get()+t,i))):S.less(d.get(),o.get())&&(o.set(d.get()),n.set(Math.min(n.get()+t,i)))),1===r.get()?(T=Math.min(T,v),S.n(s)>2&&(T=Math.min(T,y))):(T=Math.max(T,b),S.n(s)>2&&(T=Math.max(T,w))),p.set(T),T},S.alma=function(e,t,i,s){for(var r=Math.floor(i*(t-1)),n=t/s*(t/s),o=[],a=0,l=0;l<t;++l){var c=Math.exp(-1*Math.pow(l-r,2)/(2*n));a+=c,o.push(c)}for(l=0;l<t;++l)o[l]/=a;var h=0;for(l=0;l<t;++l)h+=o[l]*e.get(t-l-1);return h},S.wvap=function(e,t){return e.get()-e.get(1)},S.change=function(e){return e.get()-e.get(1)},S.roc=function(e,t){var i=e.get(t);return 100*(e.get()-i)/i},S.dev=function(e,t,i){var s=S.sma(e,t,i);return S.dev2(e,t,s)},S.dev2=function(e,t,i){for(var s=0,r=0;r<t;r++){var n=e.get(r);s+=S.abs(n-i)}return s/t},S.stdev=function(e,t,i){var s=S.variance(e,t,i);return S.sqrt(s)},S.variance=function(e,t,i){var s=S.sma(e,t,i);return S.variance2(e,s,t)},S.variance2=function(e,t,i){for(var s=0,r=0;r<i;r++){var n=e.get(r),o=S.abs(n-t);s+=o*o}return s/i},S.percentrank=function(e,t){if(S.na(e.get(t-1)))return NaN;for(var i=0,s=e.get(),r=1;r<t;r++){var n=e.get(r);S.ge(s,n)&&i++}return 100*i/t},S.createNewSessionCheck=function(e){if(void 0===e.symbol.session.timezone)return function(){return!1};var t=f.newBarBuilder(e.symbol.period,e.symbol.session);return function(e){return t.indexOfBar(e)===o.POST_SESSION&&(t.moveTo(e),!0)}},S.error=function(e){throw new s(e)},S.dmi=function(e,t,i){var s=i.new_var(S.high(i)),r=i.new_var(S.low(i)),n=S.change(s),o=-S.change(r),a=i.new_var(S.na(n)||S.na(o)?S.na():S.and(S.gt(n,o),S.gt(n,0))?n:0),l=i.new_var(S.na(o)?S.na():S.and(S.gt(o,n),S.gt(o,0))?o:0),c=S.atr(e,i),h=S.fixnan(100*S.rma(a,e,i)/c,i),d=S.fixnan(100*S.rma(l,e,i)/c,i),u=h+d;S.isZero(u)&&(u+=1);var p=Math.abs(h-d)/u*100,_=i.new_var(p),m=S.rma(_,t,i),g=i.new_var(m);return[h,d,p,m,(g.get(0)+g.get(e-1))/2]},b.LOW=0,b.HIGH=1,b.prototype.isPivotFound=function(){return-1!==this._pivotIndex.get()},b.prototype.pivotIndex=function(){return this._pivotIndex.get()},b.prototype.currentValue=function(){return this._currentValue.get()},b.prototype.pivotType=function(){return this._pivotType},b.prototype.reset=function(){this._currentValue.set(NaN),this._currentIndex.set(0),this._pivotIndex.set(-1)},b.prototype.isRightSideOk=function(e){return e-this._currentIndex.get()===this._areaRight},b.prototype.isViolate=function(e,t){
|
||||
if(e<1||isNaN(this._currentValue.get()))return!0;var i=this._series.get(this._index-e);return!!isNaN(i)||(i===this._currentValue.get()?t:this._pivotType===b.HIGH?i>this._currentValue.get():i<this._currentValue.get())},b.prototype.processPoint=function(e){this.isViolate(e,!1)&&(this._currentValue.set(this._series.get()),this._currentIndex.set(e))},b.prototype.isRestartNeeded=function(e){return e-this._currentIndex.get()>this._areaRight},b.prototype.update=function(){if(this._isNewBar&&this.isPivotFound()&&this.reset(),this.processPoint(this._index),this.isRightSideOk(this._index)){if(-1===this._pivotIndex.get()){for(var e=!0,t=0;t<this._areaLeft;++t)if(this.isViolate(this._currentIndex.get()-1-t,!0)){e=!1;break}e&&this._pivotIndex.set(this._currentIndex.get())}}else-1!==this._pivotIndex.get()&&this._pivotIndex.set(-1);if(this.isRestartNeeded(this._index)){this.reset();for(t=0;t<=this._areaRight;++t)this.processPoint(this._index-this._areaRight+t)}},w.prototype.addPivot=function(e,t,i){this._lastIndex.set(e),this._lastVal.set(t),this._lastType.set(i)},w.prototype.updatePivot=function(e,t){this._lastIndex.set(e),this._lastVal.set(t)},w.prototype.lastPrice=function(){return this._lastVal.get()},w.prototype.lastIndex=function(){return this._lastIndex.get()},w.prototype.addPoint=function(e,t,i){if(isNaN(this._lastVal.get()))this.addPivot(e,t,i);else{var s=this._lastVal.get();if(this._lastType.get()!==i)Math.abs(s-t)/t>this._deviation&&this.addPivot(e,t,i);else(i===b.HIGH?t>s:t<s)&&this.updatePivot(e,t)}},w.prototype.processPivot=function(e){e.update(),this._isBarClosed&&e.isPivotFound()&&this.addPoint(e.pivotIndex(),e.currentValue(),e.pivotType())},S.zigzag=function(e,t,i){return new w(e,t,i).lastPrice()},S.zigzagbars=function(e,t,i){var s=new w(e,t,i);return-1===s.lastIndex()?NaN:s.lastIndex()-S.n(i)},C.prototype.new_sym=function(e,t,i,s){return this.symbol.script.add_sym(e,t,i,s)},C.prototype.select_sym=function(e){this.symbol=this.symbol.script.get_sym(e)},C.prototype.is_main_symbol=function(e){return void 0!==e&&e===this.symbol.script.get_sym(0)},C.prototype.new_var=function(e){var t=this.vars;t.length<=this.vars_index&&t.push(new P(this.symbol));var i=t[this.vars_index++];return arguments.length>0&&i.set(e),i},C.prototype.new_unlimited_var=function(e){var t=this.vars;t.length<=this.vars_index&&t.push(new T(this.symbol));var i=t[this.vars_index++];return arguments.length>0&&i.set(e),i},C.prototype.new_ctx=function(){return this.ctx.length<=this.ctx_index&&this.ctx.push(new C(this.symbol)),this.ctx[this.ctx_index++]},C.prototype.prepare=function(e){this.ctx_index=0,this.vars_index=0;for(var t=0;t<this.vars.length;t++)this.vars[t].prepare(e);for(var i=0;i<this.ctx.length;i++)this.ctx[i].prepare(e)},C.prototype.maxAdditionalDepth=function(){if(null!==this.minimumAdditionalDepth)return this.minimumAdditionalDepth;for(var e=0,t=0;t<this.vars.length;t++){var i=this.vars[t].mindepth;!isNaN(i)&&i>e&&(e=i)}return e},C.prototype.stop=function(){this.symbol=null,this.vars=null},C.prototype.setMinimumAdditionalDepth=function(e){
|
||||
this.minimumAdditionalDepth=e},P.prototype.valueOf=function(){return this.get(0)},P.prototype.get=function(e){return isNaN(e)&&(e=0),e=e||0,this.hist?e>=this.hist.length?(console.error("not enough depth: "+this),NaN):this._get(e):(this.mindepth=S.max(this.mindepth,e),NaN)},P.prototype._get=function(e){var t=this.hist_pos-e;return t<0&&(t+=this.hist.length),this.hist[t]},P.prototype.set=function(e){this.hist&&(this.hist[this.hist_pos]=e,this.modified=!0)},P.prototype.prepare=function(e){e===this.symbol&&(e.isNewBar?(this.original=this.get(0),!this.modified&&this.hist||this.add_hist()):this.set(this.original),this.modified=!1)},P.prototype.add_hist=function(){if(!this.hist){var e=S.na(this.mindepth)?S.max_series_default_size:S.max(this.mindepth+1,1);e=Math.round(e);for(var t=new Array(e),i=0;i<e;i++)t[i]=NaN;this.hist=t,this.hist_pos=-1}this.hist_pos=Math.min(this.hist_pos+1,this.hist.length),this.hist_pos===this.hist.length&&(this.hist_pos=this.hist.length-1,this.hist.shift(),this.hist.push(NaN)),this.hist[this.hist_pos]=this.original},P.prototype.adopt=function(e,t,i){this.hist||(this.mindepth=NaN);var s=t.get(),r=e.indexOf(s);if(0!==i){var n=t.get(1);if(!S.na(n))r=r===e.indexOf(n)?-1:r}return r<0?NaN:this._get(r)},P.prototype.indexOf=function(e){if(!this.hist)return this.mindepth=NaN,-1;if(S.na(e))return-1;var t=this.hist.length,i=this.symbol.index+1,s=Math.min(t,i),n=r.upperbound_int(this.hist,e,0,s);return 0===n?-1:s-n},n(T,P),T.prototype.add_hist=function(){if(this.hist||(this.hist=new Float64Array(2e3),this.hist_pos=-1),this.hist_pos=this.hist_pos+1,this.hist_pos===this.hist.length){var e=new Float64Array(2*this.hist.length);e.set(this.hist),this.hist=e}this.hist[this.hist_pos]=this.original},x.prototype.set_symbolinfo=function(e){if(e||console.error("WARN: symbolinfo isn't defined for "+this.tickerid),this.info=e,this.minTick=e.minmov/e.pricescale,this.currencyCode=e.currency_code,this.unitId=e.unit_id,this.subsessionId=e.subsession_id,this.timezone=g.get_timezone(e.timezone),this.session.init(e.timezone,e.session,e.session_holidays,e.corrections),void 0!==e.subsessions){const t=e.subsessions.find(e=>e.id===u.Regular),i=e.subsessions.find(e=>e.id===u.PreMarket),s=e.subsessions.find(e=>e.id===u.PostMarket);void 0!==t&&(this.regularSubsession=new _(e.timezone,t.session,e.session_holidays,t["session-correction"])),void 0!==i&&(this.preMarketSubsession=new _(e.timezone,i.session,e.session_holidays,i["session-correction"])),void 0!==s&&(this.postMarketSubsession=new _(e.timezone,s.session,e.session_holidays,s["session-correction"]))}},x.prototype.isdwm=function(){return""!==this.resolution&&"S"!==this.resolution&&"T"!==this.resolution},x.prototype.enable_dwm_aligning=function(e,t){this.dwm_aligner=f.newBarBuilder(this.period,e,t)},x.prototype.bartime=function(){var e=this.time;if(!this.isdwm()||isNaN(e))return e;var t=g.utc_to_cal(this.timezone,e);return this.session.spec.correctTradingDay(t),g.cal_to_utc(this.timezone,t)},x.prototype.lastbar=function(e){if(!isNaN(e.time)){var t=e.time
|
||||
;this.dwm_aligner&&(this.dwm_aligner.moveTo(t),t=this.dwm_aligner.startOfBar(0));var i=this.time!==t;i&&this.index>=0&&!this.isBarClosed&&(this.isNewBar=!1,this.isBarClosed=!0,this.script.calc(this)),this.time=t,this.open=e.open,this.high=e.high,this.low=e.low,this.close=e.close,this.volume=e.volume,this.updatetime=e.updatetime,this.isNewBar=i,this.isBarClosed=e.isBarClosed,this.isLastBar=e.isLastBar,this.isNewBar&&(this.index++,this.isFirstBar=0===this.index),this.script.calc(this)}},I.prototype.calc=function(e){var t=this.ctx,i=this.body;t.prepare(e);var s=i.main(t,this.inputCallback,e);if(s&&"composite"===s.type)for(let e=0;e<s.data.length;++e)this._processResult(s.data[e]);else this._processResult(s)},I.prototype._processResult=function(e){var t=this.ctx,i=this;this.out&&e&&(!isNaN(t.symbol.time)||e.nonseries)&&(e.nonseries?("projection"===e.type&&(e.projectionTime=t.symbol.time),this.nonseriesOut(t.symbol,e)):e.bars?e.bars.forEach((function(e){i.out(t.symbol,e)})):this.out(t.symbol,e))},I.prototype.init=function(){var e=this.ctx,t=this.body;t.init&&t.init(e,this.inputCallback),t.main(e,this.inputCallback)},I.prototype.add_sym=function(e,t,i,s,r,n){var o=this.runner.add_sym(e,t,i,s,this,r);return this.symbols.push(o),o.isdwm()&&this.symbols.length>1&&o.enable_dwm_aligning(this.symbols[0].session,o.session),o},I.prototype.maxAdditionalDepth=function(){return this.symbols[0].isAdditionalDepthAllowed?this.ctx.maxAdditionalDepth():0},I.prototype.stop=function(){this.symbols=null,this.ctx.stop(),this.ctx=null},I.prototype.get_sym=function(e){return this.symbols[e]},M.prototype.add_sym=function(e,t,i,s,r,n,o){var a=new x(e,t,i,s,r,n);return this.symbols.push(a),a},M.prototype.get_sym=function(e){return this.symbols[e]},M.prototype.out=function(e,t){if(this.nonseriesUpdate){var i=Object.assign({},this.nonseriesUpdate);t.splice(0,0,e.time),i.lastBar=t,this.host.nonseriesOut(e,i)}else this.host.out(e,t)},M.prototype.start=function(){this.isStarted=!0;var e=this.host;this._script=new I(e.tickerid,e.period,e.currencyCode,e.unitId,this,e.body,this.out.bind(this),e.input,e.nonseriesOut,e.symbolInfo,e.subsessionId);var t=this,i=[],s=this.symbols,r=Object.assign({},e.dataRange,{countBack:e.dataRange.countBack+t._script.maxAdditionalDepth()}),n=s[0];function o(t,s,r){i.push(M.feed.subscribe(t.tickerid,t.currencyCode,t.unitId,t.period,r,e.onErrorCallback,e.symbolInfo,e.sessionId,s,e.forceAlignBars,t.subsessionId))}function h(i,s){"series"===(s.nonseries?"nonseries":"series")?t.update(i,s):s.lastBar?(t.nonseriesUpdate=s,s.lastBar.isLastBar=!0,t.symbols[0].lastbar(s.lastBar),t.nonseriesUpdate=null):e.nonseriesOut(p,s)}function d(){return r}o(n,d,(function(e){!e.nonseries&&Number.isFinite(e.firstLoadedTimeMs)&&function(e){function i(i,s){var r=c(i,s)(e),n=l(i,s);return null!==n&&(r=n.timeToExchangeTradingDay(r)),{to:r,countBack:t._script.maxAdditionalDepth()}}for(var r=1;r<s.length;r++){var d=s[r],u=d.period;a.isEqual(u,n.period)||o(d,i.bind(null,u),h.bind(null,r))}}(e.firstLoadedTimeMs),h(0,e)}));for(var u=1;u<s.length;u++){
|
||||
var p=s[u];a.isEqual(p.period,n.period)&&o(p,d,h.bind(null,u))}this.subscription=i},M.prototype.stop=function(){var e=this.subscription;if(e||this._script){for(var t=0;t<e.length;t++)M.feed.unsubscribe(e[t]);this.subscription=null,this._script.stop(),this._script=null,this.symbols=null,this.isStarted=!1}else console.warn("Recurring script engine stop happened.")},M.prototype.update=function(e,t){if(t){var i=this.symbols[e];if(this.isRecalculated){var s=t.bar(t.count()-1);s.isBarClosed=t.isLastBarClosed(),s.isLastBar=!0,i.lastbar(s)}else this.barsets[e]||(this.barsets[e]=t,i.set_symbolinfo(t.symbolinfo()),this.recalc())}else console.error("Unexpected barset = null")},M.prototype.recalc=function(){for(var e=this.symbols,t=0;t<e.length;t++)if(!this.barsets[t])return;try{for(var i=e.length-1;i>=0;i--)for(var s=e[i],r=this.barsets[i],n=r.count(),o=0;o<n;o++){var a=r.bar(o);a.isLastBar=o===n-1,a.isBarClosed=!a.isLastBar||r.isLastBarClosed(),s.lastbar(a)}this.isRecalculated=!0,this.barsets[0]&&this.barsets[0].endOfData&&this.host.setNoMoreData(),this.host.recalc(this,{endOfData:this.barsets[0].endOfData,firstLoadedTimeMs:this.barsets[0].firstLoadedTimeMs,emptyBarCount:this.barsets[0].emptyBarCount()})}catch(e){if(!e.studyError)throw e;this.host.onErrorCallback(e.message)}},M.feed={subscribe:function(e,t,i,s,r){console.error("must be initialized with setupFeed")},unsubscribe:function(e){console.error("must be initialized with setupFeed")}},L.prototype.stop=function(){this.runner.stop()},L.prototype.isStarted=function(){return this.runner.isStarted},A.prototype.symbolinfo=function(){return this.info},A.prototype.isLastBarClosed=function(){return this.isBarClosed},A.prototype.setLastBarClosed=function(e){this.isBarClosed=e},A.prototype.bar=function(e){return this.bars[e]},A.prototype.count=function(){return this.bars.length},A.prototype.emptyBarCount=function(){return this._emptyBarCount},A.prototype.add=function(e,t,i){void 0===i&&(i=!1);var s=e,r=this.bars,n=r.length,o=s.time,a=0===n?NaN:r[n-1].time;0===n||a<o?(r.push(s),i&&(this._emptyBarCount+=1,this._lastBarIsEmpty=!0)):a===o?(i!==this._lastBarIsEmpty&&(this._emptyBarCount+=i?1:-1,this._lastBarIsEmpty=i),r[n-1]=s):console.error("time order violation, prev: "+new Date(a).toUTCString()+", cur: "+new Date(o).toUTCString()),this.isBarClosed=!!t},E.prototype.init=function(e){this.bb=f.newBarBuilder(this.period,e.symbol.session),this.bbEmptyBars=this.generateEmptyBars?f.newBarBuilder(this.period,e.symbol.session):void 0,e.setMinimumAdditionalDepth(0)},E.prototype.extrapolate=function(e,t){return isNaN(e)||isNaN(t)?void 0:v(this.bbEmptyBars,e,t,Number.MAX_SAFE_INTEGER,!0).times},E.prototype.main=function(e){
|
||||
return this._source.properties().currencyId.value()}unit(){return this._source.properties().unitId.value()}share(e){this._undoModel.shareLineTools([this._source],e)}sharingMode(){return this._source.sharingMode().value()}_setProps(e,t,i){for(const s in t){if(!t.hasOwnProperty(s))continue;const n=0===i.length?s:`${i}.${s}`;if(e.hasOwnProperty(s)){const i=t[s];(0,r.isHashObject)(i)?this._setProps(e[s],i,n):e[s].setValue(i)}else console.warn(`Unknown property "${n}"`)}}}},56233:(e,t,i)=>{"use strict";i.d(t,{PaneApi:()=>u});var s=i(88537),r=i(42534),n=i(45973),o=i(80643),a=i(28353),l=i(24980),c=i(35762);const h=new l.TranslatedString("change pane height",(0,a.t)("change pane height"));class d extends c.UndoCommand{constructor(e,t,i){super(h),this._model=e,this._paneIndex=t,this._paneHeight=i,this._prevStretchFactors=this._model.panes().map(e=>e.stretchFactor())}redo(){this._model.changePanesHeight(this._paneIndex,this._paneHeight)}undo(){const e=this._model.panes();for(let t=0;t<e.length;++t)e[t].setStretchFactor((0,s.ensureDefined)(this._prevStretchFactors[t]));this._model.fullUpdate()}}class u{constructor(e,t){this._priceScales=new WeakMap,this._pane=e,this._chartWidget=t}hasMainSeries(){return this._pane.containsMainSeries()}getLeftPriceScales(){return this._pane.leftPriceScales().map(this._getPriceScaleApi,this)}getRightPriceScales(){return this._pane.rightPriceScales().map(this._getPriceScaleApi,this)}getMainSourcePriceScale(){const e=this._pane.mainDataSource();if(null===e)return null;const t=e.priceScale();return null===t||this._pane.isOverlay(e)?null:this._getPriceScaleApi(t)}setMaximized(e){if(this._pane.maximized().value()!==e)for(const e of this._chartWidget.paneWidgets())if(e.state()===this._pane){this._chartWidget.toggleMaximizePane(e);break}}legendLoaded(){const e=this._chartWidget.paneByState(this._pane);return Boolean(e&&e.statusWidget())}getAllEntities(){const e=this._pane.model();return this._pane.sourcesByGroup().allIncludingHidden().map(t=>(0,n.entityForDataSource)(e,t)).filter(o.notNull).filter(e=>null!==e.name)}getHeight(){return this._pane.height()}setHeight(e){const t=this._chartWidget.model().model(),i=t.panes();(0,s.assert)(i.length>1,"Unable to change pane's height if there is only one pane");const r=i.indexOf(this._pane);(0,s.assert)(-1!==r,"Invalid pane index");const n=new d(t,r,e);this._chartWidget.model().undoHistory().pushUndoCommand(n)}moveTo(e){const t=this.paneIndex();t!==e&&((0,s.assert)(e>=0&&e<this._chartWidget.paneWidgets().length,"Invalid pane index"),this._chartWidget.model().movePane(t,e))}paneIndex(){return this._chartWidget.model().model().panes().indexOf(this._pane)}collapse(){if(1===this._chartWidget.paneWidgets().length)throw new Error("Cannot collapse a single pane!");const e=this._chartWidget.paneByState(this._pane);if(null===e||this._pane.collapsed().value())throw new Error("Cannot collapse current pane!");this._chartWidget.toggleCollapsedPane(e)}restore(){if(1===this._chartWidget.paneWidgets().length)throw new Error("Cannot restore a single pane!")
|
||||
;const e=this._chartWidget.paneByState(this._pane);if(null===e||!this._pane.collapsed().value())throw new Error("Cannot restore current pane!");this._chartWidget.toggleCollapsedPane(e)}_getPriceScaleApi(e){let t=this._priceScales.get(e);return void 0===t&&(t=new r.PriceScaleApi(this._chartWidget.model(),e),this._priceScales.set(e,t)),t}}},42534:(e,t,i)=>{"use strict";i.d(t,{PriceScaleApi:()=>s});class s{constructor(e,t){this._chartUndoModel=e,this._chartModel=e.model(),this._priceScale=t}getMode(){const e=this._priceScale.properties().childs();return e.percentage.value()?2:e.indexedTo100.value()?3:e.log.value()?1:0}setMode(e){this._priceScale.setMode({percentage:2===e,log:1===e,indexedTo100:3===e})}isInverted(){return this._priceScale.isInverted()}setInverted(e){this._priceScale.properties().childs().isInverted.setValue(e)}isLocked(){return this._priceScale.isLockScale()}setLocked(e){this._priceScale.setMode({lockScale:e})}isAutoScale(){return this._priceScale.isAutoScale()}setAutoScale(e){this._priceScale.setMode({autoScale:e})}getVisiblePriceRange(){return this._priceScale.priceRangeInPrice()}setVisiblePriceRange(e){this._priceScale.setPriceRangeInPrice(e),this._chartModel.lightUpdate()}hasMainSeries(){return this._priceScale.hasMainSeries()}getStudies(){return this._priceScale.getStudies().map(e=>e.id())}currency(){const e=this._priceScale.currency(this._chartModel.availableCurrencies());return null===e?null:{selectedCurrency:e.selectedCurrency,readOnly:e.readOnly}}setCurrency(e){this._chartUndoModel.setPriceScaleCurrency(this._priceScale,e)}unit(){const e=this._priceScale.unit(this._chartModel.availableUnits());return null===e?null:{selectedUnit:e.selectedUnit,readOnly:0===e.availableGroups.size,availableGroups:Array.from(e.availableGroups)}}setUnit(e){this._chartUndoModel.setPriceScaleUnit(this._priceScale,e)}}},32112:(e,t,i)=>{"use strict";function s(e,t){const i=e.dataSourceForId(t);if(null===i)throw new Error(`Chart has no study or shape with id "${t}"`);return i}i.d(t,{SelectionApi:()=>r});class r{constructor(e){this._model=e}add(e){Array.isArray(e)?this._model.selectionMacro(t=>{e.map(s.bind(null,this._model)).forEach(e=>t.addSourceToSelection(e))}):this.add([e])}canBeAddedToSelection(e){const t=s(this._model,e);return this._model.selection().canBeAddedToSelection(t)}set(e){Array.isArray(e)?this._model.selectionMacro(t=>{t.clearSelection(),e.map(s.bind(null,this._model)).forEach(e=>t.addSourceToSelection(e))}):this.set([e])}remove(e){Array.isArray(e)?this._model.selectionMacro(t=>{e.map(s.bind(null,this._model)).forEach(e=>t.removeSourceFromSelection(e))}):this.remove([e])}contains(e){const t=s(this._model,e);return this._model.selection().isSelected(t)}allSources(){return this._model.selection().dataSources().map(e=>e.id())}isEmpty(){return this._model.selection().isEmpty()}clear(){this._model.selectionMacro(e=>{e.clearSelection()})}onChanged(){return this._model.onSelectedSourceChanged()}}},82650:(e,t,i)=>{"use strict";i.d(t,{SeriesApi:()=>l});var s=i(88537),r=i(8597),n=i(36551),o=i(27579),a=i(42534)
|
||||
;class l{constructor(e,t){this._series=e,this._undoModel=t,this._model=t.model()}isUserEditEnabled(){return this._series.userEditEnabled()}setUserEditEnabled(e){this._series.setUserEditEnabled(e)}mergeUp(){this._model.isMergeUpAvailableForSource(this._series)&&new r.MergeUpUndoCommand(this._model,this._series,null).redo()}mergeDown(){this._model.isMergeDownAvailableForSource(this._series)&&new r.MergeDownUndoCommand(this._model,this._series,null).redo()}unmergeUp(){this._model.isUnmergeAvailableForSource(this._series)&&new n.UnmergeUpUndoCommand(this._model,this._series,null).redo()}unmergeDown(){this._model.isUnmergeAvailableForSource(this._series)&&new n.UnmergeDownUndoCommand(this._model,this._series,null).redo()}detachToRight(){new o.MoveToNewPriceScaleUndoCommand(this._model,this._series,this._pane(),"right",null).redo()}detachToLeft(){new o.MoveToNewPriceScaleUndoCommand(this._model,this._series,this._pane(),"left",null).redo()}detachNoScale(){new o.MoveToNewPriceScaleUndoCommand(this._model,this._series,this._pane(),"overlay",null).redo()}changePriceScale(e){const t=(0,s.ensureNotNull)(this._model.paneForSource(this._series));switch(e){case"new-left":new o.MoveToNewPriceScaleUndoCommand(this._model,this._series,t,"left",null).redo();break;case"new-right":new o.MoveToNewPriceScaleUndoCommand(this._model,this._series,t,"right",null).redo();break;case"no-scale":(0,s.assert)(t.actionNoScaleIsEnabled(this._series),"Unable to leave a pane without any non-overlay price scale"),new o.MoveToNewPriceScaleUndoCommand(this._model,this._series,t,"overlay",null).redo();break;default:const i=this._model.dataSourceForId(e);if(null===i)throw new Error(`There is no study with entityId='${e}'`);const r=this._model.paneForSource(i)===t;(0,s.assert)(r,"Study should be on the main pane");const n=(0,s.ensureNotNull)(i.priceScale());new o.MoveToExistingPriceScaleUndoCommand(this._model,this._series,t,n,null).redo()}}isVisible(){return this._series.properties().childs().visible.value()}setVisible(e){this._series.properties().childs().visible.setValue(e)}bringToFront(){this._model.bringToFront([this._series])}sendToBack(){this._model.sendToBack([this._series])}entityId(){return this._series.id()}chartStyleProperties(e){return this._series.properties().childs()[c(e)].state(["inputs","inputsInfo"])}setChartStyleProperties(e,t){this._series.properties().childs()[c(e)].mergeAndFire(t)}barsCount(){return this._series.bars().size()}symbolSource(){return{symbol:this._series.symbol(),currencyId:this._series.currency(),unitId:this._series.unit()}}isLoading(){return this._series.isLoading()}data(){return this._series.data()}priceScale(){return new a.PriceScaleApi(this._undoModel,this._series.priceScale())}_pane(){return(0,s.ensureNotNull)(this._model.paneForSource(this._series))}}function c(e){switch(e){case 0:return"barStyle";case 1:return"candleStyle";case 2:return"lineStyle";case 3:return"areaStyle";case 4:return"renkoStyle";case 5:return"kagiStyle";case 6:return"pnfStyle";case 7:return"pbStyle";case 8:return"haStyle";case 9:
|
||||
return"hollowCandleStyle";case 10:return"baselineStyle";case 11:return"rangeStyle";case 12:return"hiloStyle";case 13:return"columnStyle";default:(0,s.ensureNever)(e)}throw new Error("unsupported chart style: "+e)}},67e3:(e,t,i)=>{"use strict";i.d(t,{StudyApi:()=>y});var s=i(88537),r=i(2872),n=i.n(r),o=i(80643),a=i(59572),l=i(97401),c=i(13795),h=i(36551),d=i(8597),u=i(27579),p=i(61671),_=i(79222),m=i(35588),g=i(42534),f=i(13933),v=i(152),S=i(70120);class y{constructor(e,t){this._onStudyCompleted=new(n()),this._onStudyError=new(n()),this._study=e,this._chartWidget=t,this._undoModel=this._chartWidget.model(),this._model=this._undoModel.model(),this._study.onAboutToBeDestroyed().subscribe(this,()=>{this._study.onStatusChanged().unsubscribeAll(this),this._study.onAboutToBeDestroyed().unsubscribeAll(this)}),this._study.onStatusChanged().subscribe(this,e=>{switch(e.type){case f.StudyStatusType.Completed:this._onStudyCompleted.fire();break;case f.StudyStatusType.Error:this._onStudyError.fire()}})}isUserEditEnabled(){return this._study.userEditEnabled()}setUserEditEnabled(e){this._study.setUserEditEnabled(e)}getInputsInfo(){return(0,v.getStudyInputsInfo)(this._study.metaInfo())}getInputValues(){const e=this._study.inputs({symbolsForChartApi:!1,asObject:!0});return Object.keys(e).map(t=>{const i=e[t];return{id:t,value:(0,o.isObject)(i)?i.v:i}})}getStyleInfo(){return(0,S.getStudyStylesInfo)(this._study.metaInfo())}getStyleValues(){const{plots:e,styles:t,bands:i,filledAreas:s,palettes:r}=this._study.properties().state(),n={};return void 0!==e&&(n.plots=e),void 0!==t&&(n.styles=t),void 0!==i&&(n.bands=i),void 0!==s&&(n.filledAreas=s),void 0!==r&&(n.palettes=r),n}setInputValues(e){const t=this.getInputValues();for(const i of e){void 0!==t.find(e=>e.id===i.id)?this._study.properties().inputs[i.id].setValue(i.value):console.warn(`There is no such input: "${i.id}"`)}}mergeUp(){this._model.isMergeUpAvailableForSource(this._study)&&new d.MergeUpUndoCommand(this._model,this._study,null).redo()}mergeDown(){this._model.isMergeDownAvailableForSource(this._study)&&new d.MergeDownUndoCommand(this._model,this._study,null).redo()}unmergeUp(){this._model.isUnmergeAvailableForSource(this._study)&&new h.UnmergeUpUndoCommand(this._model,this._study,null).redo()}unmergeDown(){this._model.isUnmergeAvailableForSource(this._study)&&new h.UnmergeDownUndoCommand(this._model,this._study,null).redo()}onDataLoaded(){return this._onStudyCompleted}onStudyError(){return this._onStudyError}mergeUpWithUndo(){this._model.isMergeUpAvailableForSource(this._study)&&this._undoModel.mergeSourceUp(this._study)}mergeDownWithUndo(){this._model.isMergeDownAvailableForSource(this._study)&&this._undoModel.mergeSourceDown(this._study)}unmergeUpWithUndo(){this._model.isUnmergeAvailableForSource(this._study)&&this._undoModel.unmergeSourceUp(this._study)}unmergeDownWithUndo(){this._model.isUnmergeAvailableForSource(this._study)&&this._undoModel.unmergeSourceDown(this._study)}priceScale(){return new g.PriceScaleApi(this._undoModel,(0,s.ensureNotNull)(this._study.priceScale()))}
|
||||
symbolSource(){const e=(0,s.ensureNotNull)(this._study.symbolSource());return{symbol:e.symbol(),currencyId:e.currency(),unitId:e.unit()}}currency(){return this._study.currency()}changePriceScale(e){const t=(0,s.ensureNotNull)(this._model.paneForSource(this._model.mainSeries())),i=(0,s.ensureNotNull)(this._model.paneForSource(this._study));switch(e){case"no-scale":(0,s.assert)(i.actionNoScaleIsEnabled(this._study),"Unable to leave a pane without any non-overlay price scale"),new u.MoveToNewPriceScaleUndoCommand(this._model,this._study,i,"overlay",null).redo();break;case"as-series":(0,s.assert)(i===t,"Study should be on the main pane"),new u.MoveToExistingPriceScaleUndoCommand(this._model,this._study,i,this._model.mainSeries().priceScale(),null).redo();break;case"new-left":new u.MoveToNewPriceScaleUndoCommand(this._model,this._study,i,"left",null).redo();break;case"new-right":new u.MoveToNewPriceScaleUndoCommand(this._model,this._study,i,"right",null).redo();break;default:const r=this._model.dataSourceForId(e);if(null===r)throw new Error(`There is no study with entityId='${e}'`);const n=i===this._model.paneForSource(r);(0,s.assert)(n,"Both studies should be on the same pane");const o=(0,s.ensureNotNull)(r.priceScale()),a=(0,c.sourceNewCurrencyOnPinningToPriceScale)(this._study,o,this._model),h=(0,_.sourceNewUnitOnPinningToPriceScale)(this._study,o,this._model);new u.MoveToExistingPriceScaleUndoCommand(this._model,this._study,i,o,null).redo(),null!==a&&new l.SetPriceScaleCurrencyUndoCommand(o,a,this._undoModel.chartWidget(),null).redo(),null!==h&&new m.SetPriceScaleUnitUndoCommand(o,h,this._undoModel.chartWidget(),null).redo()}}isVisible(){return this._study.properties().visible.value()}setVisible(e){this._study.properties().visible.setValue(e)}bringToFront(){this._model.bringToFront([this._study])}sendToBack(){this._model.sendToBack([this._study])}applyOverrides(e){(0,a.applyOverridesToStudy)(this._study,e)}dataLength(){return this._study.status().type!==f.StudyStatusType.Completed?0:this._study.metaInfo().plots.length>0?this._study.data().size():this._model.mainSeries().bars().size()}isLoading(){return this._study.isLoading()}properties(){return this._study.properties()}async applyToEntireLayout(){const e=new p.ActionsProvider(this._chartWidget),t=(await e.contextMenuActionsForSources([this._study])).find(e=>"applyStudyToEntireLayout"===e.id);t&&t.execute()}}},152:(e,t,i)=>{"use strict";i.d(t,{getStudyInputsInfo:()=>r});var s=i(28353);function r(e){return void 0===e.inputs?[]:e.inputs.map(e=>({...e,id:e.id,localizedName:void 0!==e.name?(0,s.t)(e.name,{context:"input"}):""}))}},70120:(e,t,i)=>{"use strict";i.d(t,{getStudyStylesInfo:()=>n});var s,r=i(27788);function n(e){const t={};if(e.defaults){const i=(0,r.default)(e.defaults);t.defaults=i}return void 0!==e.plots&&(t.plots=(0,r.default)(e.plots)),void 0!==e.styles&&(t.styles=(0,r.default)(e.styles)),void 0!==e.bands&&(t.bands=(0,r.default)(e.bands)),void 0!==e.filledAreas&&(t.filledAreas=(0,r.default)(e.filledAreas)),void 0!==e.palettes&&(t.palettes=(0,
|
||||
r.default)(e.palettes)),t}!function(e){e.LeftToRight="left_to_right",e.RightToLeft="right_to_left"}(s||(s={}))},817:(e,t,i)=>{"use strict";i.d(t,{ChartSession:()=>u});var s=i(2872),r=i.n(s),n=i(88537),o=i(52714),a=i.n(o),l=i(9423),c=i(98125);const h=(0,c.getLogger)("ChartApi.AbstractSession");var d=i(80643);(0,c.getLogger)("ChartSession");class u extends class{constructor(e,t,i){this._isConnected=new(a())(!1),this._state=0,this._isConnectForbidden=!1,this._sessionId="",this._sessionIdChanged=new(r()),this._chartApi=e,this._sessionPrefix=t,this._shouldReconnectAfterCriticalError=i}destroy(){this._logNormal("Destroying session"),this._isConnected.unsubscribe(),this.disconnect(),this._sessionIdChanged.destroy(),delete this._chartApi,this._logNormal("Session has been destroyed")}isConnected(){return this._isConnected}sessionId(){return this._sessionId}onSessionIdChanged(){return this._sessionIdChanged}connect(){0===this._state&&((0,n.assert)(!this._isConnectForbidden,"Cannot call connect because it is forbidden at this moment"),this._setSessionId(`${this._sessionPrefix}_${(0,l.randomHash)()}`),this._logNormal("Connecting session - wait until transport stay connected"),this._state=1,this._chartApi.createSession(this._sessionId,this))}disconnect(){0!==this._state&&((0,n.assert)(""!==this._sessionId,"sessionId must not be invalid"),this._logNormal("Disconnecting session..."),this._forbidConnectWhile(()=>{this._chartApi.connected()&&this._sendRemoveSession(),this._processDestroyingOnServer()}))}onMessage(e){switch(e.method){case"connected":return void this._onChartApiConnected();case"disconnected":return void this._onChartApiDisconnected();case"critical_error":const t=String(e.params[0]),i=String(e.params[1]);return void this._onCriticalError(t,i)}this._onMessage(e)}_getChartApi(){return this._chartApi}_generateLogMessage(e){return`[${this._sessionId}] ${e}`}_onCriticalError(e,t){this._logError(`Critical error. Reason=${e}, info=${t}.`),this._forbidConnectWhile(()=>{this._processDestroyingOnServer()}),this._shouldReconnectAfterCriticalError?(this._logNormal("Reconnecting after critical error..."),this.connect()):this._logNormal("Reconnecting after critical error skipped")}_onChartApiConnected(){(0,n.assert)(1===this._state,"Session is not registered"),this._logNormal("Transport is connected. Creating session on the server"),this._sendCreateSession(),this._state=2,this._isConnected.setValue(!0)}_onChartApiDisconnected(){this._logNormal("Transport is disconnected. Reconnecting..."),this._forbidConnectWhile(()=>{this._processDestroyingOnServer()}),this.connect()}_setSessionId(e){const t=this._sessionId;this._logNormal(`Changing sessionId: old=${t}, new=${e}`),this._sessionId=e,this._sessionIdChanged.fire(e,t)}_logNormal(e){h.logNormal(this._generateLogMessage(e))}_logError(e){h.logError(this._generateLogMessage(e))}_processDestroyingOnServer(){this._state=0,this._isConnected.setValue(!1),this._chartApi.removeSession(this._sessionId),this._setSessionId("")}_forbidConnectWhile(e){this._isConnectForbidden=!0,e(),
|
||||
this._isConnectForbidden=!1}}{constructor(e,t=!1){super(e,"cs",!1),this._sessionDisabled=!1,this._handler=null,this._criticalError=new(r()),this._symbolResolveMap=new Map,this._disableStatistics=t}destroy(){this._criticalError.destroy(),this._handler=null,this._symbolResolveMap.clear(),super.destroy()}serverTimeOffset(){return this._getChartApi().serverTimeOffset()}switchTimezone(e){return this._getChartApi().switchTimezone(this.sessionId(),e)}defaultResolutions(){return this._getChartApi().defaultResolutions()}availableCurrencies(){return this._getChartApi().availableCurrencies()}availableUnits(){return this._getChartApi().availableUnits()}resolveSymbol(e,t,i){if(this._symbolResolveMap.has(t)){const[e,s]=this._symbolResolveMap.get(t);return Array.isArray(s)?s.push(i):s.then(i),e}{const s=[i];return this._getChartApi().resolveSymbol(this.sessionId(),e,t,i=>{"symbol_error"===i.method?this._symbolResolveMap.delete(t):this._symbolResolveMap.set(t,[e,Promise.resolve(i)]),s.forEach(e=>e(i))}),this._symbolResolveMap.set(t,[e,s]),e}}requestFirstBarTime(e,t,i){return this._getChartApi().requestFirstBarTime(this.sessionId(),e,t,i)}createSeries(e,t,i,s,r,n,o){return this._getChartApi().createSeries(this.sessionId(),e,t,i,s,r,n,o)}modifySeries(e,t,i,s,r,n){return this._getChartApi().modifySeries(this.sessionId(),e,t,i,s,r,n)}removeSeries(e){return!!this.isConnected().value()&&this._getChartApi().removeSeries(this.sessionId(),e)}requestMoreData(e,t,i){return"number"==typeof e?this._getChartApi().requestMoreData(this.sessionId(),e):this._getChartApi().requestMoreData(this.sessionId(),e,t,i)}requestMoreTickmarks(e,t,i){return(0,d.isNumber)(e)?this._getChartApi().requestMoreTickmarks(this.sessionId(),e):this._getChartApi().requestMoreTickmarks(this.sessionId(),e,t,i)}requestMetadata(e,t){(()=>{this._getChartApi().requestMetadata(this.sessionId(),e,t)})()}isCanCreateStudy(e){return this._getChartApi().isCanCreateStudy(e)}createStudy(e,t,i,s,r,n,o){return this._getChartApi().createStudy(this.sessionId(),e,t,i,s,r,n,o)}rebindStudy(e,t,i,s,r,n,o){return this._getChartApi().rebindStudy(this.sessionId(),e,t,i,s,r,n,o)}modifyStudy(e,t,i,s){return this._getChartApi().modifyStudy(this.sessionId(),e,t,i,s)}removeStudy(e,t){return this._getChartApi().removeStudy(this.sessionId(),e,t)}createPointset(e,t,i,s,r,n){return this._getChartApi().createPointset(this.sessionId(),e,t,i,s,r,n)}modifyPointset(e,t,i,s){return this._getChartApi().modifyPointset(this.sessionId(),e,t,i,s)}removePointset(e){return this._getChartApi().removePointset(this.sessionId(),e)}setVisibleTimeRange(e,t,i,s,r,n){this._getChartApi().setVisibleTimeRange(this.sessionId(),e,t,i,s,!0,r,n)}criticalError(){return this._criticalError}connect(e=null){null!==e&&(this._handler=e),this._symbolResolveMap.clear(),super.connect()}setHandler(e){this._handler=e}connected(){return this.isConnected().value()&&!this._sessionDisabled}disable(){this._sessionDisabled=!0}chartApi(){return this._getChartApi()}_sendCreateSession(){Object.keys(this).forEach(e=>{
|
||||
/^(s|st|symbol_)\d+$/.test(e)&&delete this[e]}),this._getChartApi().chartCreateSession(this.sessionId(),this._disableStatistics)}_sendRemoveSession(){this._getChartApi().chartDeleteSession(this.sessionId())}_onMessage(e){this._handler&&this._handler(e)}_onCriticalError(e,t){this._criticalError.fire(e,t),super._onCriticalError(e,t)}}},84801:(e,t,i)=>{"use strict";var s=i(80643).declareClassAsPureInterface;function r(){}TradingView.WEB_SOCKET_WAS_CONNECTED=!1,r.REBIND_STUDY_STANDALONE_TO_CHILD=1,r.REBIND_STUDY_CHILD_TO_STANDALONE=2,r.prototype.defaultWatchlistSymbols=function(){},r.prototype.defaultResolutions=function(){},r.prototype.availableCurrencies=function(){},r.prototype.availableUnits=function(){},r.prototype.supportedSymbolsTypes=function(){},r.prototype.supportedExchangesList=function(){},r.prototype.symbolsGrouping=function(){},r.prototype.quoteCreateSession=function(e){},r.prototype.quoteDeleteSession=function(e){},r.prototype.quoteSetFields=function(e,t){},r.prototype.quoteAddSymbols=function(e,t){},r.prototype.quoteRemoveSymbols=function(e,t){},r.prototype.quoteFastSymbols=function(e,t){},r.prototype.depthCreateSession=function(e,t,i){},r.prototype.depthDeleteSession=function(e){},r.prototype.depthSetSymbol=function(e,t){},r.prototype.depthClearSymbol=function(e){},r.prototype.depthSetScale=function(e,t){},r.prototype.chartCreateSession=function(e,t){},r.prototype.chartDeleteSession=function(e){},r.prototype.createSession=function(e,t){},r.prototype.removeSession=function(e){},r.prototype.connected=function(){},r.prototype.connect=function(){},r.prototype.disconnect=function(){},r.prototype.switchTimezone=function(e,t){},r.prototype.resolveSymbol=function(e,t,i,s){},r.prototype.createSeries=function(e,t,i,s,r,n,o,a){},r.prototype.removeSeries=function(e,t,i){},r.prototype.modifySeries=function(e,t,i,s,r,n,o){},r.prototype.requestMoreData=function(e,t,i,s){},r.prototype.requestMetadata=function(e,t,i){},r.prototype.isCanCreateStudy=function(e,t){},r.prototype.createStudy=function(e,t,i,s,r,n,o){},r.prototype.rebindStudy=function(e,t,i,s,r,n,o,a){},r.prototype.removeStudy=function(e,t,i){},r.prototype.modifyStudy=function(e,t,i,s,r){},r.prototype.createPointset=function(e,t,i,s,r,n,o){},r.prototype.modifyPointset=function(e,t,i,s,r){},r.prototype.removePointset=function(e,t,i){},r.prototype.requestMoreTickmarks=function(e,t,i,s){},r.prototype.requestFirstBarTime=function(e,t,i,s){},r.prototype._invokeHandler=function(e,t){},r.prototype._sendRequest=function(e,t){},r.prototype._onMessage=function(e){},r.prototype._dispatchNotification=function(e){},r.prototype._invokeNotificationHandler=function(e,t,i){},r.prototype._notifySessions=function(e){},r.prototype.unpack=function(e){},r.prototype.searchSymbols=function(e,t,i,s,r,n,o,a,l,c){},r.prototype.serverTimeOffset=function(){},r.prototype.getMarks=function(e,t,i,s,r){},r.prototype.getTimescaleMarks=function(e,t,i,s,r){},s(r,"ChartApiInterface"),e.exports.HandlerInfo=function(e,t){this.handler=e,this.customId=t},e.exports.ChartApiInterface=r},17437:(e,t,i)=>{
|
||||
"use strict";i.r(t),i.d(t,{setCustomAdapter:()=>_,initialize:()=>m,updateUser:()=>g,getChartsCount:()=>f,getCharts:()=>v,removeChart:()=>S,saveChart:()=>y,getChartContent:()=>b,loadChart:()=>w,removeStudyTemplate:()=>C,getStudyTemplateContent:()=>P,saveStudyTemplate:()=>T,getStudyTemplatesList:()=>x,invalidateStudyTemplatesList:()=>I,getStudyTemplateContentById:()=>M,getStandardStudyTemplateContentById:()=>L,removeStudyTemplateById:()=>A,renameStudyTemplate:()=>E,replaceStudyTemplate:()=>k,getDrawingTemplates:()=>D,loadDrawingTemplate:()=>V,removeDrawingTemplate:()=>B,saveDrawingTemplate:()=>N});var s=i(76422),r=i(98125),n=i(88461);const o=(0,r.getLogger)("Chart.SaveloadAdapter.Library");let a,l,c,h,d=null,u=null;function p(e){return`${c}/${encodeURIComponent(h)}/${e}?client=${encodeURIComponent(a)}&user=${encodeURIComponent(l)}`}function _(e){d=e}function m(e,t,i,s){a=e,l=t,c=i,h=s}function g(e){l=e}function f(e,t){throw new Error("Not implemented")}async function v(){const e=e=>e.map(e=>({id:e.id,name:e.name,image_url:String(e.id),modified_iso:e.timestamp,short_symbol:e.symbol,interval:e.resolution}));if(d)return d.getAllCharts().then(e);try{const t=await fetch(""+p("charts"),{credentials:"same-origin"});if(!t.ok)throw new Error(`Getting chart content response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Get chart content request failed: "+i.message);return e(i.data)}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function S(e){if(d)d.removeChart(e);else try{const t=await fetch(`${p("charts")}&chart=${encodeURIComponent(e)}`,{method:"DELETE",credentials:"same-origin"});if(!t.ok)throw new Error(`Remove chart response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Remove drawing template request failed: "+i.message)}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function y(e,t,i,s,r){const a=r.id.value(),l={name:e,content:JSON.stringify(s),symbol:t,resolution:i};if(d)return d.saveChart({...l,id:a});try{const e=new FormData;for(const t in l)e.append(t,l[t]);let t=p("charts");null!=a&&(t+="&chart="+encodeURIComponent(a));const i=await fetch(t,{credentials:"same-origin",method:"POST",body:e});if(!i.ok)throw new Error(`Saving chart content response was not OK. Status: ${i.status}.`);const s=await i.json();if("ok"!==s.status)throw new Error("Saving chart content request failed: "+s.message);return s.id.toString()}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function b(e){const t=t=>{const i=JSON.parse(t);return i.uid=e.id,i};if(d)return d.getChartContent(e.id).then(e=>t(e));try{const i=await fetch(`${p("charts")}&chart=${encodeURIComponent(e.id)}`,{credentials:"same-origin"});if(!i.ok)throw new Error(`Getting chart content response was not OK. Status: ${i.status}.`);const s=await i.json();if("ok"!==s.status)throw new Error("Get chart content request failed: "+s.message);return t(s.data.content)}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}function w(e){b(e).then(e=>{
|
||||
s.emit("chart_load_requested",e)},()=>{o.logWarn("Error loading chart")})}async function C(e){try{if(d)return d.removeStudyTemplate({name:e});const t=await fetch(`${p("study_templates")}&template=${encodeURIComponent(e)}`,{method:"DELETE",credentials:"same-origin"});if(!t.ok)throw new Error(`Remove study template response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Remove study template request failed: "+i.message)}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function P(e){try{if(d){return{content:await d.getStudyTemplateContent({name:e})}}const t=await fetch(`${p("study_templates")}&template=${encodeURIComponent(e)}`,{credentials:"same-origin"});if(!t.ok)throw new Error(`Get study template response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Get study template request failed: "+i.message);return i.data}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function T(e){try{if(d)return d.saveStudyTemplate(e).then(()=>({error:""})).catch(e=>({error:null!=e?(0,n.errorToString)(e):"error"}));const t=new FormData;t.append("name",e.name),t.append("content",e.content);const i=await fetch(p("study_templates"),{method:"POST",body:t,credentials:"same-origin"});if(!i.ok)throw new Error(`Save study template response was not OK. Status: ${i.status}.`);const s=await i.json();return{error:"ok"===s.status?"":s.status}}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}async function x(){try{if(u)return u;u=[];const e=e=>(u=e.map(e=>({is_default:!1,name:e.name})),u);if(d)return d.getAllStudyTemplates().then(e);const t=await fetch(p("study_templates"),{method:"GET",credentials:"same-origin"});if(!t.ok)throw new Error(`Study templates list response was not OK. Status: ${t.status}.`);const i=await t.json();if("ok"!==i.status)throw new Error("Study templates list request failed: "+i.message);return e(i.data)}catch(e){throw o.logWarn((0,n.errorToString)(e)),e}}function I(){u=null}function M(e,t){throw new Error("Not implemented")}function L(e,t){throw new Error("Not implemented")}function A(e,t){throw new Error("Not implemented")}function E(e,t,i){throw new Error("Not implemented")}function k(e,t,i){throw new Error("Not implemented")}async function D(e){throw new Error("Not implemented")}async function V(e,t){throw new Error("Not implemented")}async function B(e,t){throw new Error("Not implemented")}async function N(e,t,i){throw new Error("Not implemented")}},87983:(e,t,i)=>{"use strict";var s=i(88537).ensureNotNull,r=i(69177),n=i(29823).Interval,o=i(16616),a=i(84093),l=i(84801),c=l.ChartApiInterface,h=l.HandlerInfo,d=i(80643).requireFullInterfaceImplementation,u=i(98125).getLogger("Chart.ChartApiLocal"),p=i(73383).TIMEFRAMETYPE,_=i(65862).createDwmAligner,m=i(67337);TradingView.STUDY_COUNT_LIMIT=210,JSServer.ChartApi=function(e){this._notificationHandlers={},this._sessions={},this.studyCounter=0,this._connected=!1,this._enabled=!1,this._studyEngine=new o(e),this._callbacks={},this._serverTimeOffset=0;var t=this
|
||||
;this._studyEngine.on("configuration_received",(function(){t._fireEvent("configuration_received")})),this._studyEngine.on("realtime_tick",(function(e){var i={time:e.value[0]/1e3,open:e.value[1],high:e.value[2],low:e.value[3],close:e.value[4],volume:e.value[5]};t._fireEvent("realtime_tick",i,!0)})),this._setVisibleRangeTimeout={}},JSServer.ChartApi.prototype.destroy=function(){this._studyEngine.destroy(),this._studyEngine=null},JSServer.ChartApi.prototype.purgeCache=function(e){this._studyEngine.purgeCache(),this._studyEngine.purgeDataCache()},JSServer.ChartApi.prototype.defaultWatchlistSymbols=function(){const e=this._watchlistSettings.default_symbols;return m.enabled("uppercase_instrument_names")?e.map(e=>e.toUpperCase()):e},JSServer.ChartApi.prototype.defaultResolutions=function(){return this._studyEngine.supportedResolutions()||["1","3","5","15","30","45","60","120","180","240","1D","1W","1M"]},JSServer.ChartApi.prototype.availableCurrencies=function(){var e=this._studyEngine.supportedCurrencies().map((function(e){return"string"==typeof e?{id:e,code:e}:e}));return Promise.resolve(e)},JSServer.ChartApi.prototype.availableUnits=function(){return Promise.resolve(this._studyEngine.supportedUnits())},JSServer.ChartApi.prototype.supportedSymbolsTypes=function(){return this._studyEngine.supportedSymbolsTypes()},JSServer.ChartApi.prototype.supportedExchangesList=function(){return this._studyEngine.supportedExchangesList()},JSServer.ChartApi.prototype.symbolsGrouping=function(){return this._studyEngine.symbolsGrouping()},JSServer.ChartApi.prototype.start=function(){this._enabled=!0,this._fireEvent("start_enabled")},JSServer.ChartApi.prototype.unsubscribe=function(e,t){var i=this._callbacks[e];i&&i.splice(i.indexOf(t),1)},JSServer.ChartApi.prototype.on=function(e,t){return this._callbacks.hasOwnProperty(e)||(this._callbacks[e]=[]),this._callbacks[e].push(t),this},JSServer.ChartApi.prototype._fireEvent=function(e,t,i){if(this._callbacks.hasOwnProperty(e)){var s=this._callbacks[e].slice(0);i||(this._callbacks[e]=[]);for(var r=0;r<s.length;++r)s[r](t)}},JSServer.ChartApi.prototype.chartCreateSession=function(e,t){this._studyEngine.chartCreateSession(e)},JSServer.ChartApi.prototype.chartDeleteSession=function(e){this._studyEngine.chartDeleteSession(e)},JSServer.ChartApi.prototype.createSession=function(e,t){TradingView.ChartapiMessagerInstances[e]=new a(this,e),this._sessions[e]=t,this._notificationHandlers[e]={},this.connected()&&t.onMessage({method:"connected",params:[]})},JSServer.ChartApi.prototype.removeSession=function(e){delete this._sessions[e],delete this._notificationHandlers[e],this._studyEngine.stopSources(e)},JSServer.ChartApi.prototype.connected=function(){return this._connected},JSServer.ChartApi.prototype.connect=function(){if(this._enabled)this.connected()||(this._connected=!0,this.sessionid="dummy session id",this._notifySessions({method:"connected",params:[]}));else{var e=this;this.on("start_enabled",(function(){e.connect()}))}},JSServer.ChartApi.prototype.disconnect=function(){this._connected=!1,
|
||||
this._notifySessions({method:"disconnected",params:[]}),this.purgeCache(),this.studyCounter=0},JSServer.ChartApi.prototype.switchTimezone=function(e,t){this._studyEngine.switchTimezone(e,t)},JSServer.ChartApi.prototype.receiveLocalResponse=function(e){this._dispatchNotification(e),this._fireEvent("message_"+e.method,void 0,!0)},JSServer.ChartApi.prototype.getMarks=function(e,t,i,s,r){this._studyEngine.getMarks(e,t,i,s,r)},JSServer.ChartApi.prototype.getTimescaleMarks=function(e,t,i,s,r){this._studyEngine.getTimescaleMarks(e,t,i,s,r)},JSServer.ChartApi.prototype.resolveSymbol=function(e,t,i,s){this._notificationHandlers[e][t]=new h(s,t),this._studyEngine.resolveSymbol(e,t,i)},JSServer.ChartApi.prototype._doWhenSeriesDataReceived=function(e,t){TradingView.ChartapiMessagerInstances[e].seriesCompleted.subscribe(null,t,!0)},JSServer.ChartApi.prototype.createSeries=function(e,t,i,s,r,n,o,a){var l=this;this._notificationHandlers[e][t]=new h((function(r){"series_completed"===r.method&&null!==o&&(l._applyTimeFrame(e,s,t,i,o),o=null),a(r)}),t);const c={countBack:n||300};null!==o&&o.type===p.TimeRange&&(c.to=1e3*o.to,c.from=1e3*o.from),this._studyEngine.createSeries(e,t,i,s,r,c)},JSServer.ChartApi.prototype.removeSeries=function(e,t){delete this._notificationHandlers[e][t],this._studyEngine.removeSeries(e,t)},JSServer.ChartApi.prototype.setVisibleTimeRange=function(e,t,i,r,n,o,a,l){var c=r,h=!0!==(a=a||{}).applyDefaultRightMargin&&void 0===a.percentRightMargin&&void 0!==n?n:null,d=_(this._studyEngine.getSeriesInterval(e,t),this._studyEngine.getSeriesSymbolInfo(e,t));null!==d&&(c=d.timeToSessionStart(1e3*c)/1e3,null!==h&&(h=d.timeToSessionStart(1e3*h)/1e3));var u=this;function p(){var r=u._studyEngine.sessionTimeScale(e);if(null!==r){var n,d=r.indexOfTime(1e3*c);if(null===h)n=r.lastSessionBarIndex();else{var p=r.indexOfTime(1e3*h);n=p&&p.index}if(null!==d&&null!==n){var _=d.index;if(d.timeMs<1e3*c&&(_+=1),!1===o){const e=s(r.firstSessionBarIndex());_<e&&(_=e)}_>n||(TradingView.ChartapiMessagerInstances[e].onSeriesTimeframeUpdate(t,i,_,n,a),l&&setTimeout(l,0))}}}if(this._studyEngine.isTimeScaleExtendedTo(e,1e3*r))p();else{var m=TradingView.ChartapiMessagerInstances[e].seriesCompleted,g=TradingView.ChartapiMessagerInstances[e].seriesError;void 0!==this._setVisibleRangeTimeout[e]&&clearTimeout(this._setVisibleRangeTimeout[e]),this._setVisibleRangeTimeout[e]=setTimeout(function(){delete this._setVisibleRangeTimeout[e],m.subscribe(null,f,!0),g.subscribe(null,v,!0),this._studyEngine.ensureExtendedTo(t,e,1e3*r)}.bind(this),0)}function f(e,s){e===t&&s===i&&(m.unsubscribe(null,f),g.unsubscribe(null,v),p())}function v(e,s){e===t&&s===i&&m.unsubscribe(null,f)}},JSServer.ChartApi.prototype._applyTimeFrame=function(e,t,i,s,o){var a,l,c={},h=!0;if(o.type===p.PeriodBack){var d=this._studyEngine.getSeriesLastBarTime(e,i);if(null===d)return;l=d/1e3;var u=n.parse(o.value),m=this._studyEngine.getSeriesSymbolInfo(e,i);a=r.alignPeriodsBackForVisibleRange(m.session,m.session_holidays,m.corrections,u.letter(),u.multiplier(),1,d)/1e3
|
||||
;var g=_(this._studyEngine.getSeriesInterval(e,i),m);null!==g&&(l=g.timeToExchangeTradingDay(1e3*l)/1e3,a=g.timeToExchangeTradingDay(1e3*a)/1e3),c={applyDefaultRightMargin:!0},h=!1}else a=o.from,l=o.to;this.setVisibleTimeRange(e,i,s,a,l,h,c)},JSServer.ChartApi.prototype.modifySeries=function(e,t,i,s,r,n,o){var a=this;this._notificationHandlers[e][t]=new h((function(r){"series_completed"===r.method&&null!==n&&(a._applyTimeFrame(e,s,t,i,n),n=null),o(r)}),t),this._studyEngine.modifySeries(e,t,s,r,i)},JSServer.ChartApi.prototype.requestMoreData=function(e,t){this._studyEngine.extendSeriesRange(e,t)},JSServer.ChartApi.prototype.setStudiesAccessController=function(e){this.studiesAccessController=e},JSServer.ChartApi.prototype.setWatchlistSettings=function(e){this._watchlistSettings=e},JSServer.ChartApi.prototype.allStudiesMetadata=function(){return this._studyEngine.studiesMetadata()},JSServer.ChartApi.prototype.requestMetadata=function(e,t,i){this._notificationHandlers[e][t]=new h(i,t);var s=this.studiesAccessController.getEnabledTools();TradingView.ChartapiMessagerInstances[e].onRequestMetadata(t,s)},JSServer.ChartApi.prototype.isCanCreateStudy=function(){return this.studyCounter<TradingView.STUDY_COUNT_LIMIT},JSServer.ChartApi.prototype.createStudy=function(e,t,i,s,r,n,o){if(!this.isCanCreateStudy())throw new Error("Exceeded the limit of studies");this._notificationHandlers[e][t]=new h(o,t),this._studyEngine.createStudy(e,t,s,i,r,n),this.studyCounter++},JSServer.ChartApi.prototype.rebindStudy=function(e,t,i,s,r,n,o,a){throw new Error("Not implemented")},JSServer.ChartApi.prototype.removeStudy=function(e,t,i){delete this._notificationHandlers[e][t],this._studyEngine.removeStudy(e,t),this.studyCounter--},JSServer.ChartApi.prototype.modifyStudy=function(e,t,i,s,r){this._notificationHandlers[e][t]=new h(r,t),this._studyEngine.modifyStudy(e,t,i,s)},JSServer.ChartApi.prototype.createPointset=function(e,t,i,s,r,n,o){this._notificationHandlers[e][t]=new h(o,t),this._studyEngine.createPointset(e,t,s,r,n)},JSServer.ChartApi.prototype.modifyPointset=function(e,t,i,s,r){throw Error("This call is not implemented")},JSServer.ChartApi.prototype.removePointset=function(e,t,i){this._notificationHandlers[e][t]=null,this._studyEngine.removePointset(e,t)},JSServer.ChartApi.prototype.requestMoreTickmarks=function(e,t){this._studyEngine.requestMoreTickmarks(e,t)},JSServer.ChartApi.prototype.requestFirstBarTime=function(e,t,i,s){this._notificationHandlers[e][t]=new h(s,t)},JSServer.ChartApi.prototype._invokeHandler=function(e,t){e&&e(t)},JSServer.ChartApi.prototype._sendRequest=function(e,t){throw Error("This method is not implemented")},JSServer.ChartApi.prototype._onMessage=function(e){throw Error("This method is not implemented")},JSServer.ChartApi.prototype._dispatchNotification=function(e){var t=e.params.shift();if(this._notificationHandlers[t])switch(e.method){case"timescale_update":var i=e.params[0],s=e.params[1];for(var r in s.clear=0===s.changes.length&&0===s.marks.length,this._sessions[t].onMessage({method:"timescale_update",
|
||||
params:s}),i){var n={method:"data_update",params:{customId:r,plots:i[r].series,nonseries:i[r].nonseries,turnaround:i[r].turnaround}};this._invokeNotificationHandler(t,r,n)}break;case"tickmark_update":this._sessions[t].onMessage({method:"timescale_update",params:e.params[0]});break;case"data_update":for(var r in e.params[0]){var o=e.params[0][r];n={method:"data_update",params:{customId:r,plots:o.series?o.series:o.plots,nonseries:o.nonseries,turnaround:o.turnaround}};this._invokeNotificationHandler(t,r,n)}break;case"index_update":for(var r in e.params[0]){n={method:"index_update",params:e.params[0][r]};this._invokeNotificationHandler(t,r,n)}break;case"critical_error":u.logNormal(new Date+" critical_error session:"+this.sessionid+" reason:"+e.params[0]),this._sessions[t].onMessage({method:"critical_error",params:e.params});break;case"timescale_completed":case"quote_symbol_data":case"quote_list_fields":case"depth_symbol_error":case"depth_symbol_success":case"dd":case"dpu":case"depth_bar_last_value":this._sessions[t].onMessage({method:e.method,params:e.params});break;case"clear_data":for(var a in e.params[0])this._invokeNotificationHandler(t,a,{method:"clear_data",params:e.params[0][a]});break;default:var l=e.params[0];this._invokeNotificationHandler(t,l,e)}},JSServer.ChartApi.prototype._invokeNotificationHandler=function(e,t,i){if(void 0!==t){var s=this._notificationHandlers[e][t];void 0!==s&&s&&this._invokeHandler(s.handler,i)}},JSServer.ChartApi.prototype.searchSymbols=function(e,t,i,s,r,n,o,a,l,c){this._studyEngine.searchSymbols(e,t,i,c)},JSServer.ChartApi.prototype._notifySessions=function(e){for(var t in this._sessions){if(!this._sessions.hasOwnProperty(t))return;var i=this._sessions[t];"function"==typeof i.onMessage&&i.onMessage(e)}},JSServer.ChartApi.prototype.unpack=function(e){throw Error("This method is not implemented")},JSServer.ChartApi.prototype.quoteCreateSession=function(e){return this._studyEngine.quoteCreateSession(e)},JSServer.ChartApi.prototype.quoteDeleteSession=function(e){return this._studyEngine.quoteDeleteSession(e)},JSServer.ChartApi.prototype.quoteSetFields=function(e,t){return this._studyEngine.quoteSetFields(e,t)},JSServer.ChartApi.prototype.quoteAddSymbols=function(e,t){return-1!==t.indexOf(void 0)&&(console.warn("Got undefined in quoteAddSymbols"),t=t.filter((function(e){return!!e}))),this._studyEngine.quoteAddSymbols(e,t)},JSServer.ChartApi.prototype.quoteRemoveSymbols=function(e,t){return this._studyEngine.quoteRemoveSymbols(e,t)},JSServer.ChartApi.prototype.quoteFastSymbols=function(e,t){return this._studyEngine.quoteFastSymbols(e,t)},JSServer.ChartApi.prototype.quoteHibernateAll=function(e){return this._studyEngine.quoteHibernateAll(e)},JSServer.ChartApi.prototype.depthCreateSession=function(e){return this._studyEngine.depthCreateSession(e)},JSServer.ChartApi.prototype.depthDeleteSession=function(e){return this._studyEngine.depthDeleteSession(e)},JSServer.ChartApi.prototype.depthSetSymbol=function(e,t){return this._studyEngine.depthSetSymbol(e,t)},
|
||||
JSServer.ChartApi.prototype.depthClearSymbol=function(e){},JSServer.ChartApi.prototype.depthSetScale=function(e,t){},JSServer.ChartApi.prototype.createStudiesAccessController=function(e,t,i){return new this.StudiesAccessController(this._studyEngine,e&&JSON.parse(e)||{type:"black",tools:[]})},JSServer.ChartApi.prototype.StudiesAccessController=function(e,t){this._studyEngine=e,this._studiesAccess=t},JSServer.ChartApi.prototype.StudiesAccessController.prototype._findTool=function(e){for(var t=null,i=0;i<this._studiesAccess.tools.length;++i){var s=this._studiesAccess.tools[i];if(s.name===e||s===e){t=s;break}}return t},JSServer.ChartApi.prototype.StudiesAccessController.prototype.getEnabledTools=function(){return this._studyEngine.studiesMetadata().filter((function(e){return this.isToolEnabled(e.description)||e.is_hidden_study}),this)},JSServer.ChartApi.prototype.StudiesAccessController.prototype.isToolEnabled=function(e){var t=this._findTool(e);return"black"===this._studiesAccess.type?!t||t.grayed:!!t},JSServer.ChartApi.prototype.StudiesAccessController.prototype.isToolGrayed=function(e){var t=this._findTool(e);return t&&t.grayed},JSServer.ChartApi.prototype.serverTimeOffset=function(){return this._studyEngine.serverTimeOffset()},JSServer.ChartApi.prototype.serverTime=function(){return this._studyEngine.serverTime()},JSServer.ChartApi.prototype.disconnectCount=function(){return 0},d(JSServer.ChartApi,"JSServer.ChartApi",c,"ChartApiInterface"),e.exports=JSServer.ChartApi},84093:(e,t,i)=>{"use strict";var s=i(2872),r=function(e,t){this._server=e,this._session=t,this.seriesCompleted=new s,this.seriesError=new s};r.prototype.onRequestMetadata=function(e,t){this._server.receiveLocalResponse({method:"studies_metadata",params:[this._session,e,{errors:[],hash:"",metainfo:t,migrations:[]}]})},r.prototype.onSymbolResolved=function(e,t){this._server.receiveLocalResponse({method:"symbol_resolved",params:[this._session,e,t]})},r.prototype.onSymbolError=function(e,t){this._server.receiveLocalResponse({method:"symbol_error",params:[this._session,e,t]})},r.prototype.onStudyError=function(e,t,i){this._server.receiveLocalResponse({method:"study_error",params:[this._session,e,t,i]})},r.prototype.onSeriesLoading=function(e,t){this._server.receiveLocalResponse({method:"series_loading",params:[this._session,e,t]})},r.prototype.onSeriesCompleted=function(e,t,i){this._server.receiveLocalResponse({method:"series_completed",params:[this._session,e,i,t]}),this.seriesCompleted.fire(e,t)},r.prototype.onSeriesError=function(e,t,i){this._server.receiveLocalResponse({method:"series_error",params:[this._session,e,t,i]}),this.seriesError.fire(e,t)},r.prototype.onStudyCompleted=function(e,t){this._server.receiveLocalResponse({method:"study_completed",params:[this._session,e,t]})},r.prototype.onStudyLoading=function(e,t){this._server.receiveLocalResponse({method:"study_loading",params:[this._session,e,t]})},r.prototype.onTickmarksUpdated=function(e,t){var i={method:"tickmark_update",params:[this._session,{index:e,zoffset:0,changes:[],marks:t,index_diff:[]
|
||||
}]};this._server.receiveLocalResponse(i)},r.prototype.onTimescaleUpdate=function(e,t){var i={method:"timescale_update",params:[this._session,this._prepareDataUpdateObjects(t),{index:e.pointsIndex,zoffset:0,changes:e.points,marks:e.marks,index_diff:e.indexChange,baseIndex:e.baseIndex}]};this._server.receiveLocalResponse(i)},r.prototype.onTimescaleCompleted=function(e){this._server.receiveLocalResponse({method:"timescale_completed",params:[this._session,e]})},r.prototype.onSeriesTimeframeUpdate=function(e,t,i,s,r){var n={method:"series_timeframe",params:[this._session,e,t,i,s,null,!0,r]};this._server.receiveLocalResponse(n)},r.prototype.onPointsetDataUpdate=function(e,t,i){this.onDataUpdate(e,t,i,null)},r.prototype._prepareDataUpdateObjects=function(e){var t={};return e.forEach((function(e){t[e.objId]={series:e.data,turnaround:e.turnaround},e.nonSeriesData&&(e.nonSeriesData.data?t[e.objId].nonseries={d:JSON.stringify(e.nonSeriesData.data),indexes:e.nonSeriesData.indexes}:t[e.objId].nonseries={d:"",indexes:[]})})),t},r.prototype.onDataUpdate=function(e,t,i,s){var r={method:"data_update",params:[this._session,this._prepareDataUpdateObjects([{objId:e,turnaround:t,data:i,nonSeriesData:s}])]};this._server.receiveLocalResponse(r)},r.prototype.onQuotesData=function(e){this._server.receiveLocalResponse({method:"quote_symbol_data",params:e})},r.prototype.onDepthData=function(e){this._server.receiveLocalResponse({method:"dd",params:e})},r.prototype.onDepthUpdate=function(e){this._server.receiveLocalResponse({method:"dpu",params:e})},r.prototype.onClearData=function(e){this._server.receiveLocalResponse({method:"clear_data",params:[this._session,e]})},TradingView.ChartapiMessagerInstances=[],e.exports=r},41986:(e,t,i)=>{"use strict";i.d(t,{DatafeedRequestsCachedProcessor:()=>_});var s=i(88537),r=i(29823),n=i(55257),o=i(216),a=i(67337),l=i(69177),c=i(65862),h=i(90388);i(94419);function d(e,t){return e.ticker+(e.currency_code?"_#_"+e.currency_code:"")+(e.unit_id?"_#_"+e.unit_id:"")+(e.subsession_id?"_#_"+e.subsession_id:"")+"_#_"+t}function u(e){return new Date(e).toISOString()}class p{constructor(e,t,i,s,n,o){this._cache={bars:[]},this._nextSubscriptionId=0,this._pendingSubscribers=[],this._subscribers=[],this._requesting=!1,this._leftDate=null,this._nextTime=null,this._realtimeOn=!1,this._endOfData=!1,this._resetCacheTimeout=null,this._errorMessage=null,this._destroyed=!1,this._emptyResponsesCount=0,this._datafeed=e,this._symbolInfo=t,this._interval=r.Interval.parse(i),this._resolution=this._interval.value(),this._dwmAligner=n,this._serverTimeOffsetGetter=s,this._resetCacheTimePeriod=void 0===o?1e4:o,this._sessionSpec=new h.SessionSpec(t.timezone,t.session,t.session_holidays,t.corrections),this._updateDatesFromExpirationDate()}destroy(){0!==this._subscribers.length&&console.warn("Destroying with not-empty state"),this._clearResetCacheTimeout(),this._unsubscribeRealtime(),this._purgeCache(),delete this._datafeed,this._destroyed=!0}addSubscription(e,t,i){const s=this._getNextSubscriptionId();this._pendingSubscribers.push({key:s,
|
||||
range:e,onHistoryCallback:t,onErrorCallback:i}),r.Interval.isDWM(this._resolution)&&void 0!==e.to&&null!==this._dwmAligner&&e.to%864e5&&console.warn(`Internal error: invalid date for DWM resolution ${u(e.to)}, expected time without a time part`),this._clearResetCacheTimeout();return setTimeout(()=>{this._destroyed||this._processPendingSubscribers()},0),s}removeSubscription(e){const t=this._pendingSubscribers.find(t=>t.key===e);if(t)return void this._pendingSubscribers.splice(this._pendingSubscribers.indexOf(t),1);const i=this._subscribers.find(t=>t.key===e);if(i)return this._subscribers.splice(this._subscribers.indexOf(i),1),void(this._subscribers.length||(this._resetCacheTimeout=setTimeout(()=>{this._resetCacheTimeout=null,this._purgeCache(),this._unsubscribeRealtime()},this._resetCacheTimePeriod)));console.warn("Unknown subscription symbol={0}, resolution={1}, key={2}".format(this._symbolInfo.name,this._resolution,e))}_logMessage(e,t){if(a.enabled("charting_library_debug_mode")||t){const t=this._symbolInfo.currency_code,i=this._symbolInfo.unit_id;console.log(`FEED [${this._symbolInfo.name}|${this._resolution}${t?"|"+t:""}${i?"|"+i:""}]: ${e}`)}}_clearResetCacheTimeout(){null!==this._resetCacheTimeout&&(clearTimeout(this._resetCacheTimeout),this._resetCacheTimeout=null)}_purgeCache(){this._logMessage("Reset cache"),this._cache={bars:[]},this._errorMessage=null,this._leftDate=null,this._endOfData=!1,this._updateDatesFromExpirationDate()}_updateDatesFromExpirationDate(){void 0!==this._symbolInfo.expiration_date&&(this._nextTime=1e3*this._symbolInfo.expiration_date,this._leftDate=1e3*(this._symbolInfo.expiration_date+1))}_dealignTime(e){return null===this._dwmAligner?e:this._dwmAligner.timeToExchangeTradingDay(e)}_normalizeRange(e){const t=void 0!==e.to?e.to:this._dealignTime(this._now());if(0===this._cache.bars.length||void 0!==e.to&&t<=(0,s.ensureNotNull)(this._leftDate))return{countBack:e.countBack,to:t};const i=null!==this._dwmAligner?this._dwmAligner.timeToSessionStart(t):t,r=(0,n.lowerbound)(this._cache.bars,i,(e,t)=>e.time<t);return e.countBack<r?{countBack:0,to:0!==e.countBack&&r<=this._cache.bars.length?this._dealignTime(this._cache.bars[r-e.countBack].time):t}:{countBack:e.countBack-r,to:this._dealignTime(this._cache.bars[0].time)}}_processPendingSubscribers(){const e=this._pendingSubscribers;if(!e.length)return;if(this._requesting)return void this._logMessage("Processing is skipped due active request");if(this._logMessage("Processing pending subscribers, count="+e.length),this._errorMessage){const t=this._errorMessage;return this._logMessage("Return error: "+t),this._pendingSubscribers=[],void e.forEach(e=>{e.onErrorCallback(t)})}let t=this._normalizeRange(e[0].range);for(const i of e.map(e=>this._normalizeRange(e.range)))(i.to<t.to||i.to===t.to&&i.countBack>t.countBack)&&(t=i);this._logMessage(`Leftmost subscriber requires ${t.countBack} bars prior ${u(t.to)}`)
|
||||
;!(null===this._leftDate||t.to<this._leftDate&&(null===this._nextTime||t.to<this._nextTime)||0!==t.countBack)||this._endOfData?(this._pendingSubscribers=[],e.forEach(e=>{const t=this._moveSubscriberToRealtime(e);this._returnHistoryDataToSubscriber(e,t)}),this._subscribeRealtimeIfNeeded()):this._ensureRequestedTo(t)}_moveSubscriberToRealtime(e){const t={key:e.key,onHistoryCallback:e.onHistoryCallback,barset:null};return this._subscribers.push(t),t}_isSymbolExpired(){return this._symbolInfo.expired||void 0!==this._symbolInfo.expiration_date}_subscribeRealtimeIfNeeded(){!this._subscribers.length||this._realtimeOn||this._isSymbolExpired()||this._subscribeRealtime()}_subscribeRealtime(){if(this._symbolInfo.expired||this._realtimeOn)return;this._realtimeOn=!0,this._datafeed.subscribeBars(this._symbolInfo,this._resolution,e=>{null!==this._dwmAligner&&(e.time=this._dwmAligner.timeToSessionStart(e.time)),this._putToCacheNewBar(e),this._subscribers.forEach(t=>{const i=t.barset;if(null===i)throw new Error("subscriber.barset is null");i.add(e),t.onHistoryCallback(i)})},d(this._symbolInfo,this._resolution),()=>{this._unsubscribeRealtime();const e=this._leftDate;this._purgeCache(),null!==e&&this._ensureRequestedTo({to:e,countBack:0})}),this._logMessage("Subscribed to realtime")}_unsubscribeRealtime(){!this._isSymbolExpired()&&this._realtimeOn&&(this._datafeed.unsubscribeBars(d(this._symbolInfo,this._resolution)),this._logMessage("Unsubscribed from realtime"),this._realtimeOn=!1)}_returnHistoryDataToSubscriber(e,t){const i=this._normalizeRange(e.range),s=this._createBarsetForRange(i);s.count()>0?this._logMessage("Bars to return for request {0}: total {1} bars in [{2} ... {3}] ".format(e.key,s.count(),u(s.bars[0].time),u(s.bars[s.count()-1].time))):this._logMessage("Request {0}. Nothing to return.".format(e.key)),t.barset=s,this._endOfData&&null!==this._leftDate&&i.to<=this._leftDate&&(s.endOfData=!0),e.onHistoryCallback(s)}_createBarsetForRange(e){const t=null!==this._dwmAligner?this._dwmAligner.timeToSessionStart(e.to):e.to,i=(0,n.lowerbound)(this._cache.bars,t,(e,t)=>e.time<t),r=new o.BarSet(this._symbolInfo,this._cache.bars.slice(Math.max(0,i-e.countBack)));return 0!==r.bars.length?r.firstLoadedTimeMs=this._dealignTime(r.bars[0].time):0!==this._cache.bars.length?r.firstLoadedTimeMs=this._dealignTime(this._cache.bars[this._cache.bars.length-1].time):r.firstLoadedTimeMs=this._dealignTime((0,s.ensureNotNull)(this._leftDate)),r}_ensureRequestedTo(e){var t;let i;if(this._requesting&&this._logMessage("Internal error: trying to call getBars while the previous request is active",!0),null!==this._leftDate)i=this._leftDate;else{const e=this._now();if(null===this._dwmAligner)i=e;else{let t=this._sessionSpec.alignToNearestSessionStart(new Date(e),1).getTime();if(t<e){const e=this._sessionSpec.alignToNearestSessionEnd(new Date(t),1).getTime();t=this._sessionSpec.alignToNearestSessionStart(new Date(e+1e3),1).getTime()}i=this._dealignTime(t)}}const s=(0,
|
||||
l.alignPeriodsBackForDataRequest)(this._symbolInfo.session,this._symbolInfo.session_holidays,this._symbolInfo.corrections,this._interval.letter(),this._interval.multiplier(),e.countBack,Math.min(e.to,i,null!==(t=this._nextTime)&&void 0!==t?t:1/0));let r=e.countBack;if(e.to<i&&(r+=(0,l.getPeriodsBetweenDates)(this._symbolInfo.session,this._symbolInfo.session_holidays,this._symbolInfo.corrections,this._interval.letter(),this._interval.multiplier(),e.to,i)),null!==this._leftDate&&this._leftDate<s)return void this._processPendingSubscribers();const n=this._isSymbolExpired()?0===this._cache.bars.length:null===this._leftDate;this._requesting=!0,this._nextTime=null,this._leftDate=s;const o=`[${u(s)} ... ${u(i)}, ${r} bars]`;this._logMessage("Requesting data: "+o);let a=!1;const c=s/1e3,h=i/1e3;this._datafeed.getBars(this._symbolInfo,this._resolution,{from:this._interval.isTicks()?c:Math.floor(c),to:this._interval.isTicks()?h:Math.floor(h),countBack:r,firstDataRequest:n},(e,t)=>{if(!this._destroyed)if(a)this._logMessage("getBars callback is already called before",!0);else{if(a=!0,e.length>0){const t=` [${u(e[0].time)} ... ${u(e[e.length-1].time)}]`;this._logMessage(`Receiving bars: total ${e.length} bars in ${t}, requested range: ${o}`)}else this._logMessage("Receiving bars: barset is empty, requested range: "+o);this._requesting=!1,this._processBars(e,t)}},e=>{this._destroyed||(a?this._logMessage("getBars callback is already called before",!0):(a=!0,this._requesting=!1,this._errorMessage=e||null,this._processPendingSubscribers()))})}_processBars(e,t){this._checkBars(e),this._alignBarsTime(e),e.length>0?(this._emptyResponsesCount=0,this._processFullBarset(e,t)):(this._emptyResponsesCount+=1,this._processEmptyBarset(t)),this._processPendingSubscribers()}_processEmptyBarset(e){e&&e.nextTime?(this._logMessage("Next time received: `{0}`".format(u(1e3*e.nextTime))),this._nextTime=1e3*e.nextTime):e&&e.noData?(this._logMessage("EOD received"),this._setEndOfData()):this._logMessage("nextTime or noData should present in metainfo when empty barset is returned"),50===this._emptyResponsesCount&&(this._logMessage("EOD detected due 50 empty responses in a row"),this._setEndOfData())}_setEndOfData(){this._endOfData=!0,this._cache.bars.length&&(this._leftDate=this._dealignTime(this._cache.bars[0].time))}_processFullBarset(e,t){this._putToCache(e)?null!==this._leftDate&&0!==this._cache.bars.length&&(this._interval.isTicks()?this._leftDate=this._dealignTime(this._cache.bars[0].time):this._leftDate=Math.min(this._leftDate,this._dealignTime(this._cache.bars[0].time))):this._logMessage("Incremental update failed. Starting full update. Returned data should be in the requested range.",!0),t&&t.nextTime?console.warn("nextTime should be set when there is no data in the requested period only"):t&&t.noData&&console.warn("noData should be set when there is no data in the requested period and earlier only")}_getNextSubscriptionId(){return this._nextSubscriptionId++}_checkBars(e,t=!1){
|
||||
if(a.enabled("charting_library_debug_mode"))for(let i=1;i<e.length;i++){if(e[i].time<=e[i-1].time){let s="Wrong bars time: time {0} of bar {1} should be more than time {2} of bar {3}".format(e[i].time,i,e[i-1].time,i-1);t&&null!==this._dwmAligner&&(s+="\nCheck that you provide DWM bars without time part, i.e. 00:00 GMT"),console.error(s)}["high","low","open","close","time"].some(t=>"number"!=typeof e[i][t]||!isFinite(e[i][t]))&&console.error("Wrong bars values: all OHLC values should be numbers")}}_putToCache(e){if(0===e.length)return!0;if(this._cache.bars.length===e.length&&this._cache.bars[0].time===e[0].time&&this._cache.bars[this._cache.bars.length-1].time===e[e.length-1].time)return this._logMessage("Time range of received data is the same as cached one. Skip the update."),!0;if(0!==this._cache.bars.length&&e[e.length-1].time===this._cache.bars[0].time&&this._cache.bars.splice(0,1),0!==this._cache.bars.length&&e[e.length-1].time>=this._cache.bars[0].time){const t=this._cache.bars[this._cache.bars.length-1].time===e[e.length-1].time;if(this._cache.bars=[],!t)return this._leftDate=null,!1;this._logMessage("Received history up to now instead of incremental update. Return exactly what is requested.")}return this._cache.bars=[...e,...this._cache.bars],this._checkBars(this._cache.bars,!0),!0}_putToCacheNewBar(e){const t=this._cache.bars.length,i=e.time,s=0===t?NaN:this._cache.bars[t-1].time;0===t||s<i?this._cache.bars.push(e):s===i?(this._interval.isTicks()&&this._logMessage("Received update for the last tick bar"),this._cache.bars[t-1]=e):console.error("putToCacheNewBar: time violation, previous bar time: "+u(s)+" should be less or equal to new time: "+u(i))}_alignBarsTime(e){if(this._dwmAligner)for(const t of e)t.time=this._dwmAligner.timeToSessionStart(t.time)}_now(){return Date.now()+1e3*this._serverTimeOffsetGetter()+6e4}}class _{constructor(e,t,i){this._threads={},this._datafeed=e,this._serverTimeOffsetGetter=t,this._resetCacheTimePeriod=i}destroy(){this._forEachThread((e,t)=>t.destroy()),this._threads={},delete this._datafeed}purgeCache(){this._forEachThread((e,t)=>t.destroy()),this._threads={}}subscribe(e,t,i,s,r){const n=d(e,t);this._threads[n]||(this._threads[n]=this._createThread(e,t));return n+'"'+this._threads[n].addSubscription(i,s,r)}unsubscribe(e){const t=e.split('"');if(2!==t.length)return void console.warn("Wrong guid format");const i=t[0],s=parseInt(t[1]);this._threads.hasOwnProperty(i)?this._threads[i].removeSubscription(s):console.warn("Data thread doesnt exist: "+e)}_createThread(e,t){return new p(this._datafeed,e,t,this._serverTimeOffsetGetter,(0,c.createDwmAligner)(t,e),this._resetCacheTimePeriod)}_forEachThread(e){Object.keys(this._threads).forEach(t=>e(t,this._threads[t]))}}},42934:(e,t,i)=>{"use strict";i.d(t,{barTimeToEndOfPeriod:()=>r,endOfPeriodToBarTime:()=>n});var s=i(68684);function r(e,t,i){if(i.isDays())return t;if(e.moveTo(1e3*t),i.isIntraday()){const i=e.indexOfBar(1e3*t);if(i<0)throw new Error(t+" is out of the instrument session ");return e.endOfBar(i)/1e3}
|
||||
return e.startOfBar(s.SessionStage.LASTBAR_SESSION)/1e3}function n(e,t,i){if(i.isDays())return t;const s=1e3*t-1;if(e.moveTo(s),i.isIntraday()){const i=e.indexOfBar(s);if(i<0)throw new Error(t+" is out of the instrument session ");return e.startOfBar(i)/1e3}return t=e.startOfBar(0)/1e3}},79283:(e,t,i)=>{"use strict";i.d(t,{replaceGraphicsTimesWithTimePointIndexIndex:()=>n});const s=new Map([["horizlines",e=>[e.startIndex,e.endIndex]],["hhists",e=>[e.firstBarTime,e.firstBarTime]],["vertlines",e=>[e.index]],["polygons",e=>e.points.map(e=>e.index)],["backgrounds",e=>[e.start,e.stop]]]),r=new Map([["horizlines",(e,t)=>{const i=e;i.startIndex=t.get(i.startIndex),i.endIndex=t.get(i.endIndex)}],["hhists",(e,t)=>{const i=e;i.firstBarTime=t.get(i.firstBarTime),i.lastBarTime=t.get(i.lastBarTime)}],["vertlines",(e,t)=>{const i=e;i.index=t.get(i.index)}],["polygons",(e,t)=>{const i=e;for(const e of i.points)e.index=t.get(e.index)}],["backgrounds",(e,t)=>{const i=e;i.start=t.get(i.start),i.stop=t.get(i.stop)}]]);function n(e){const t=e.data&&e.data.graphicsCmds&&e.data.graphicsCmds.create;if(!t)return[];const i=new Map,n=new Set;s.forEach((e,s)=>{const r=t[s];if(r)for(const t of r)for(const s of t.data){const t=e(s);for(const e of t)i.set(e,-1),n.add(e)}});const o=Array.from(n).sort((e,t)=>e-t);return o.forEach((e,t)=>i.set(e,t)),r.forEach((e,s)=>{const r=t[s];if(r)for(const t of r)for(const s of t.data)e(s,i)}),o}},65235:(e,t,i)=>{"use strict";var s=i(67337);window.onload=function(){location.hostname.indexOf(".")>=0&&!function(){try{return/^(192|172|10)\.[0-9][0-9][0-9]\.[0-9][0-9][0-9]\.[0-9][0-9][0-9]/.test(location.hostname)||/^.*((?:\.local)|localhost)$/.test(location.hostname)}catch(e){return!1}}()&&setTimeout((function(){try{var e=function(){var e=0;return JSON.parse(urlParams.logo).image&&(e="C",s.enabled("link_to_tradingview")||(e="D")),e}();window.ga&&(0!==e&&window.ga("send","event","s",e),urlParams.utm||window.ga("send","event","l"))}catch(e){}}),3e4)}},41728:(e,t,i)=>{"use strict";var s=i(69177),r={};e.exports=function(e,t,i){var n,o,a={},l=r[i]||"out_of_session",c=!1,h=i,d=t,u=null;function p(){var e={};e.symbolname=h,e.status="ok",e.values={},e.values.current_session=l,r[h]=l,TradingView.ChartapiMessagerInstances[d].onQuotesData([d].concat([e]))}function _(){if(n)if(o)l="out_of_session";else{var e=s.isTradingNow((new Date).getTime(),n)?"market":"out_of_session";e!==l&&(l=e,p())}}return e(i,null,(function(e){c||function(e){n=new s.SessionInfo(e.timezone,e.session,e.session_holidays,e.corrections),o=e.expired,u=setInterval(_,6e4),_(),p()}(e)}),(function(){})),a.stop=function(){c=!0,u&&clearInterval(u)},a.marketStatus=function(){return l},a}},11565:(e,t,i)=>{"use strict";i.d(t,{getChartStyleStudy:()=>n});var s=i(216);class r{main(e){const t=e.new_var(s.Std.open(e)),i=e.new_var(s.Std.close(e)),r=t.get(1),n=i.get(1),o=s.Std.ohlc4(e),a=s.Std.na(t.get(1))?(s.Std.open(e)+s.Std.close(e))/2:(r+n)/2;t.set(a),i.set(o)
|
||||
;const l=s.Std.max(s.Std.high(e),s.Std.max(a,o)),c=s.Std.min(s.Std.low(e),s.Std.min(a,o)),h=s.Std.volume(e),d=e.symbol;return[d.time,a,l,c,o,h,d.updatetime,d.isBarClosed]}}function n(e){if(0===e.type.indexOf("BarSetHeikenAshi@tv-basicstudies-"))return new r;const t="unknown builder type: "+e.type;throw console.error(t),new Error(t)}},37750:(e,t,i)=>{"use strict";var s=i(29823).Interval,r=i(65862).isAlignmentEnabled,n=i(11565).getChartStyleStudy,o=i(19234).decodeExtendedSymbol,a=i(983).findSuitableResolutionToBuildFrom,l=i(28930).SubsessionId,c=function(){var e=i(216),t=e.StudyEngine,c=e.BarBuilder,h=e.BarSet;function d(e){this.host=e,this.cache={}}function u(t){console.error(t),e.Std.error(t)}d.prototype.getCache=function(e){return this.cache[e]},d.prototype.putCache=function(e,t){this.cache[e]=t},d.prototype.subscribe=function(e,t,i,s,r,n,o,a,l,c,h){var d=l(o),u=function(e,t,i,s,r,n,o,a,l){var c=r.has_empty_bars?"_":"";return n+e+s+(t||"")+(i||"")+(l||"")+c+"_"+o.countBack+"_"+o.to+"_"+Boolean(a)}(e,t,i,s,o,a,d,c,h),p=this.getCache(u);return p||(p=this.createItem(e,t,i,s,o,d,a,c,h),this.putCache(u,p)),p.listeners.addListener(r,n),{key:u,listener:r}},d.prototype.unsubscribe=function(e){var t=this.getCache(e.key);t&&t.listeners.removeListener(e.listener)},d.prototype.removeUnused=function(){var e=[];for(var t in this.cache){if(this.cache[t])0===this.cache[t].listeners.listenersCount()&&e.push(t)}if(0!==e.length){for(var i=0;i<e.length;i++){var s=e[i],r=this.cache[s];this.cache[s]=null,r.stop()}this.removeUnused()}},d.prototype.rebuildFrom=function(e,t){var i=a(e,t);return i.error&&u(i.errorMessage),i.resolution};var p=s.parse("1M").inMilliseconds(0);d.prototype.createItem=function(e,t,i,a,h,d,f,v,S){var y=new g,b=o(e),w="string"!=typeof b.symbol?b.symbol:b;t=w["currency-id"]||t,i=w["unit-id"]||i;var C=w.symbol,P=w.session&&w.session!==l.Extended;if((S=w.session||S)===l.Regular&&(S=void 0),"type"in b){var T=Object.assign({},h);return h.has_empty_bars&&(T.has_empty_bars=!1),new m(y,C,t,i,a,n(b),T,d,f,S)}v&&!r()&&u("Internal error: rebuilding is requested but it is disabled."),!v&&h.has_empty_bars&&u('Misconfiguration error: attempt to request data for symbol with "has_empty_bars" flag, but "disable_resolution_rebuild" featureset is enabled');var x,I,M=this.rebuildFrom(a,h);if(!s.isTicks(a)&&(!s.isEqual(a,M)||v)){r()||u('Misconfiguration error: remove "disable_resolution_rebuild" featureset or provide '+a+" data by yourself");var L=h.has_empty_bars;T=Object.assign({},h);h.has_empty_bars&&(T.has_empty_bars=!1);var A=Math.ceil((x=s.parse(a),I=s.parse(M),x.kind()===I.kind()?x.multiplier()/I.multiplier():(x.isMonths()?x.multiplier()*p:x.inMilliseconds())/(I.isMonths()?I.multiplier()*p:I.inMilliseconds())));return d=Object.assign({},d,{countBack:d.countBack*A}),new m(y,e,t,i,M,new c(a,L),T,d,f,S)}return new _(y,C,{currency:t,unit:i,session:S},a,P,this.host,h,d)};var _=function(e,t,i,s,r,n,o,a){this.listeners=e,this.host=n;var l=this;this.host.resolve(t,i,(function(e){r&&e.regular_session&&(e.session=e.regular_session),
|
||||
l.subs=l.host.subscribe(e,s,a,(function(e){l.listeners.fire(e)}),(function(e){l.listeners.onError(e)}))}),(function(e){l.listeners.onError(e)}))};_.prototype.stop=function(){this.subs&&this.host.unsubscribe(this.subs)};var m=function(e,i,s,r,n,o,a,l,c,h){this.listeners=e,this.isRecalculated=!1,this.symbolInfo=a;var d=this;this.engine=new t({tickerid:i,currencyCode:s,unitId:r,subsessionId:h,period:n,body:o,sessionId:c,symbolInfo:a,dataRange:l,forceAlignBars:!1,recalc:function(e,t){d._recalc(t)},out:function(e,t){d._out(e,t)},nonseriesOut:function(e,t){d._nonseriesOut(e,t)},setNoMoreData:function(){d.barset&&(d.barset.endOfData=!0)},onErrorCallback:function(e){d.listeners.onError(e)}})};m.prototype.stop=function(){this.engine?this.engine.stop():console.error("Internal library error 0x1")},m.prototype._recalc=function(e){this.isRecalculated&&console.error("recalc called twice!"),this.barset||(this.barset=new h(this.symbolInfo)),e&&(this.barset.firstLoadedTimeMs=e.firstLoadedTimeMs,this.barset.endOfData=e.endOfData),this.listeners.fire(this.barset),this.isRecalculated=!0},m.prototype._nonseriesOut=function(e,t){var i=Object.assign({},t);i.nonseries=!0,i.data=t.bars,delete i.bars,i.barsetSize=this.barset?this.barset.count():0,i.lastBar=this.barset?this.barset.bar(this.barset.count()-1):null,this.listeners.fire(i,!0)},m.prototype._out=function(e,t){var i=t[0];if(!isNaN(i)){var s={time:i,open:t[1],high:t[2],low:t[3],close:t[4],volume:t[5],updatetime:t[6]},r=t[7];this.barset||(this.barset=new h(e.info));var n=t[8];if(n instanceof Array)for(var o=0;o<n.length;o++){var a=t[9],l=n[o],c={time:l,open:a,high:a,low:a,close:a,volume:0,updatetime:l};this.barset.add(c,!0,!0),this.isRecalculated&&this.listeners.fire(this.barset)}this.barset.add(s,r),this.barset.isBarClosed=r,this.isRecalculated&&this.listeners.fire(this.barset)}};var g=function(){this.listeners=[]};return g.prototype.listenersCount=function(){return this.listeners.reduce((function(e,t){return e+(t?1:0)}),0)},g.prototype.addListener=function(e,t){this.listeners.push({dataListener:e,onErrorCallback:t}),this.barset&&e(this.barset),this.errorMsg&&t(this.errorMsg)},g.prototype.removeListener=function(e){var t=this.listeners.filter((function(t){return t.dataListener===e}));if(0!==t.length){var i=this.listeners.indexOf(t[0]);delete this.listeners[i]}},g.prototype.onError=function(e){this.errorMsg=e||"unspecified error";for(var t=this.listeners,i=t.length,s=0;s<i;s++){var r=t[s];r&&r.onErrorCallback&&r.onErrorCallback(e)}},g.prototype.fire=function(e,t){t||(this.barset=e);for(var i=this.listeners,s=i.length,r=0;r<s;r++){var n=i[r];n&&n.dataListener(e)}},{setupFeed:function(t){d.instance=new d(t),e.setupFeed(d.instance)},unsubscribeUnused:function(){d.instance.removeUnused()}}}();e.exports=c},983:(e,t,i)=>{"use strict";i.d(t,{findSuitableResolutionToBuildFrom:()=>o});var s=i(29823);function r(e,t){const i=t.multiplier();for(let s=e.length-1;s>=0;s--){const r=Number(e[s]);if(i%r==0)return{error:!1,resolution:`${r}${t.letter()}`}}return{error:!0,errorMessage:n(t.value())}}
|
||||
function n(e){return`Misconfiguration error: it is trying to request ${e} but we cannot build it from lower resolution`}function o(e,t){const i=s.Interval.parse(e);if((i.isWeeks()||i.isMonths())&&t.has_weekly_and_monthly){let e=["1"];i.isWeeks()&&void 0!==t.weekly_multipliers&&(e=t.weekly_multipliers),i.isMonths()&&void 0!==t.monthly_multipliers&&(e=t.monthly_multipliers);const s=r(e,i);if(!s.error)return s}if(i.isDWM()&&(void 0===t.has_daily||t.has_daily))return i.isDays()&&void 0!==t.daily_multipliers?r(t.daily_multipliers,i):void 0===t.daily_multipliers||t.daily_multipliers.includes("1")?{error:!1,resolution:"1D"}:{error:!0,errorMessage:"Misconfiguration error: it is trying to request a resolution but symbol does not support it"};if(i.isDWM())return{error:!0,errorMessage:n(i.value())};if(i.isMinutes()&&!t.has_intraday)return{error:!0,errorMessage:"Misconfiguration error: it is trying to request intraday resolution but symbol does not support it"};if(i.isSeconds()&&!t.has_seconds)return{error:!0,errorMessage:"Misconfiguration error: it is trying to request seconds resolution but symbol does not support it"};if(i.isTicks())return!t.has_ticks||i.multiplier()>1?{error:!0,errorMessage:`Misconfiguration error: it is trying to request ${i.multiplier()} ticks resolution but symbol does not support it`}:{error:!1,resolution:"1T"};const o=i.isSeconds()?t.seconds_multipliers:t.intraday_multipliers;return void 0===o?{error:!1,resolution:i.value()}:r(o,i)}},216:function(e,t,i){"use strict";var s=i(54631).StudyError,r=i(55257),n=i(80643).inherit,o=i(68684).SessionStage,a=i(29823).Interval,l=i(65862).createDwmAligner,c=i(65862).createTimeToBarTimeAligner,h=i(19234).decodeExtendedSymbol,d=i(19234).encodeExtendedSymbolOrGetSimpleSymbolString,u=i(28930).SubsessionId,p=i(37415).PrePostMarketBarIdentifier,_=i(90388).SessionSpec,m=function(){var e,t="undefined"!=typeof window?window:i.g,g=t.PineJsCalendar?t.PineJsCalendar:i(10480),f=i(69177),v=i(11075).extrapolateBarsFrontToTime,S={};function y(e,t,i,s,r){var n=r,o=0;if(isNaN(e.get(t-1)))return{index:NaN,value:NaN};for(var a=0;a<t;++a)s(e.get(a),n)&&(o=a,n=e.get(a));return{index:o,value:n}}function b(e,t,i,s,r){this._areaRight=e,this._areaLeft=t,this._pivotType=i,this._series=s,this._currentIndex=r.new_var(0),this._currentValue=r.new_var(NaN),this._pivotIndex=r.new_var(-1),this._index=S.n(r),this._isNewBar=r.symbol.isNewBar;var n=this._currentIndex.get(1),o=this._currentValue.get(1),a=this._pivotIndex.get(1);this._index>1&&(this._currentIndex.set(n),this._currentValue.set(o),this._pivotIndex.set(a))}function w(e,t,i){this._deviation=e;var s=i.new_var(S.high(i)),r=i.new_var(S.low(i));s.get(2*t+1),r.get(2*t+1),this._pivotHigh=new b(t,t,b.HIGH,s,i),this._pivotLow=new b(t,t,b.LOW,r,i),this._lastVal=i.new_var(NaN),this._lastIndex=i.new_var(-1),this._lastType=i.new_var(),this._index=S.n(i),this._isNewBar=i.symbol.isNewBar,this._isBarClosed=i.symbol.isBarClosed;var n=this._lastIndex.get(1),o=this._lastVal.get(1),a=this._lastType.get(1);this._index>1&&this.addPivot(n,o,a),
|
||||
this.processPivot(this._pivotHigh),this.processPivot(this._pivotLow)}function C(e){this.symbol=e,this.vars=[],this.vars_index=0,this.ctx=[],this.ctx_index=0,this.minimumAdditionalDepth=null}function P(e){this.mindepth=0,this.original=NaN,this.modified=!1,this.symbol=e}function T(e){P.call(this,e)}function x(e,t,i,s,r,n,o){var l=h(e);const c="string"==typeof l.symbol?l:l.symbol;this.ticker=c.symbol,this.currencyCode=i||c["currency-id"],this.unitId=s||c["unit-id"],this.subsessionId=o||c.session;var u=c["currency-id"]!==this.currencyCode||c["unit-id"]!==this.unitId;c["currency-id"]=this.currencyCode,c["unit-id"]=this.unitId,u&&(e=d(l)),this.tickerid=e;var p=a.parse(t);this.resolution=p.letter(),this.interval=p.multiplier(),this.period=p.value(),this.index=-1,this.time=NaN,this.open=NaN,this.high=NaN,this.low=NaN,this.close=NaN,this.volume=NaN,this.updatetime=NaN,this.isNewBar=!1,this.isBarClosed=!1,this.session=new f.SessionInfo("Etc/UTC","24x7"),this.regularSubsession=null,this.preMarketSubsession=null,this.postMarketSubsession=null,this.script=r,this.isAdditionalDepthAllowed=void 0===l.type,n&&this.set_symbolinfo(n)}function I(e,t,i,s,r,n,o,a,l,c,h){this.body=n,this.symbols=[],this.runner=r,this.inputCallback=a,this.out=o,this.nonseriesOut=l,this.ctx=new C(this.add_sym(e,t,i,s,c,h)),this.init()}function M(e){this.symbols=[],this.barsets=[],this.subscription=[],this.host=e,this.isRecalculated=!1,this.isStarted=!1,this.start()}function L(e){this.runner=new M(e)}function A(e,t){this.info=e,this.bars=t||[],this.isBarClosed=!0,this.firstLoadedTimeMs=0!==this.bars.length?this.bars[0].time:1/0,this._emptyBarCount=0,this._lastBarIsEmpty=!1}function E(e,t){this.period=e,this.generateEmptyBars=!!t}function k(){}return S.max_series_default_size=10001,S.n=function(e){return e.symbol.index+1},S.nz=function(e,t){return t=t||0,isFinite(e)?e:t},S.na=function(e){return 0===arguments.length?NaN:isNaN(e)?1:0},S.isZero=function(e){return Math.abs(e)<=1e-10},S.toBool=function(e){return isFinite(e)&&!S.isZero(e)},S.eq=function(e,t){return S.isZero(e-t)},S.neq=function(e,t){return!S.eq(e,t)},S.ge=function(e,t){return S.isZero(e-t)||e>t},S.gt=function(e,t){return!S.isZero(e-t)&&e>t},S.lt=function(e,t){return!S.isZero(e-t)&&e<t},S.le=function(e,t){return S.isZero(e-t)||e<t},S.and=function(e,t){return isNaN(e)||isNaN(t)?NaN:S.isZero(e)||S.isZero(t)?0:1},S.or=function(e,t){return isNaN(e)||isNaN(t)?NaN:S.isZero(e)&&S.isZero(t)?0:1},S.not=function(e){return isNaN(e)?NaN:S.isZero(e)?1:0},S.eps=function(){return 1e-10},S.greaterOrEqual=function(e,t,i){return t-e<(i||1e-10)},S.lessOrEqual=function(e,t,i){return e-t<(i||1e-10)},S.equal=function(e,t,i){return Math.abs(e-t)<(i||1e-10)},S.greater=function(e,t,i){return e-t>(i||1e-10)},S.less=function(e,t,i){return t-e>(i||1e-10)},S.compare=function(e,t,i){return S.equal(e,t,i)?0:S.greater(e,t,i)?1:-1},S.max=Math.max,S.min=Math.min,S.pow=Math.pow,S.abs=Math.abs,S.log=Math.log,S.log10=function(e){return Math.log(e)/Math.LN10},S.sqrt=Math.sqrt,S.sign=function(e){return isNaN(e)?NaN:S.isZero(e)?0:e>0?1:-1
|
||||
},S.exp=Math.exp,S.sin=Math.sin,S.cos=Math.cos,S.tan=Math.tan,S.asin=Math.asin,S.acos=Math.acos,S.atan=Math.atan,S.floor=Math.floor,S.ceil=Math.ceil,S.round=Math.round,S.avg=function(e,t,i,s,r,n){if(2===arguments.length)return(e+t)/2;for(var o=0,a=0;a<arguments.length;a++)o+=arguments[a];return o/arguments.length},S.open=function(e){return e.symbol.open},S.high=function(e){return e.symbol.high},S.low=function(e){return e.symbol.low},S.close=function(e){return e.symbol.close},S.hl2=function(e){return(e.symbol.high+e.symbol.low)/2},S.hlc3=function(e){return(e.symbol.high+e.symbol.low+e.symbol.close)/3},S.ohlc4=function(e){return(e.symbol.open+e.symbol.high+e.symbol.low+e.symbol.close)/4},S.volume=function(e){return e.symbol.volume},S.updatetime=function(e){return e.symbol.updatetime},S.time=function(e){return e.symbol.bartime()},S.period=function(e){return e.symbol.period},S.tickerid=function(e){return e.symbol.tickerid},S.currencyCode=function(e){return e.symbol.currencyCode},S.unitId=function(e){return e.symbol.unitId},S.ticker=function(e){return e.symbol.ticker},S.interval=function(e){return e.symbol.interval},S.isdwm=function(e){return e.symbol.isdwm()},S.isintraday=function(e){return!e.symbol.isdwm()},S.isdaily=function(e){return"D"===e.symbol.resolution},S.isweekly=function(e){return"W"===e.symbol.resolution},S.ismonthly=function(e){return"M"===e.symbol.resolution},S.year=function(e){return S.timepart(e.symbol,g.YEAR,arguments[1])},S.month=function(e){return S.timepart(e.symbol,g.MONTH,arguments[1])},S.weekofyear=function(e){return S.timepart(e.symbol,g.WEEK_OF_YEAR,arguments[1])},S.dayofmonth=function(e){return S.timepart(e.symbol,g.DAY_OF_MONTH,arguments[1])},S.dayofweek=function(e){return S.timepart(e.symbol,g.DAY_OF_WEEK,arguments[1])},S.hour=function(e){return S.timepart(e.symbol,g.HOUR_OF_DAY,arguments[1])},S.minute=function(e){return S.timepart(e.symbol,g.MINUTE,arguments[1])},S.second=function(e){return S.timepart(e.symbol,g.SECOND,arguments[1])},S.add_days_considering_dst=function(e,t,i){return g.add_days_considering_dst(g.get_timezone(e),t,i)},S.selectSessionBreaks=function(e,t){if(S.isdwm(e)||void 0===e.symbol.session.timezone)return[];var i=f.newBarBuilder(e.symbol.period,e.symbol.session),s=[],r=t.length;if(i.moveTo(t[r-1]),1===r&&i.startOfBar(0)===t[0])s.push(t[0]);else{for(var n=r-2;n>=0;--n){var o=t[n];if(!(o>=i.startOfBar(0))){i.moveTo(o);var a=t[n+1];s.push(a)}}s.reverse()}return s},S.iff=function(e,t,i){return S.not(e)?i:t},S.rising=function(e,t){for(var i=1;i<t+1;++i)if(e.get(i)>e.get(0))return 0;return 1},S.falling=function(e,t){for(var i=1;i<t+1;++i)if(e.get(i)<e.get(0))return 0;return 1},S.timepart=function(e,t,i){var s=g.utc_to_cal(e.timezone,i||e.bartime());return g.get_part(s,t)},S.rsi=function(e,t){return S.isZero(t)?100:S.isZero(e)?0:100-100/(1+e/t)},S.selectPreAndPostMarketTimes=function(e,t){if(S.isdwm(e)||void 0===e.symbol.session.timezone)return{preMarket:[],postMarket:[]}
|
||||
;if(null===e.symbol.regularSubsession||null===e.symbol.preMarketSubsession||null===e.symbol.postMarketSubsession)return{preMarket:[],postMarket:[]};return new p(e.symbol.timezone,e.symbol.regularSubsession,e.symbol.preMarketSubsession,e.symbol.postMarketSubsession).getPreAndPostMarketTimes(t)},S.sum=function(e,t,i){var s=i.new_var(),r=S.nz(e.get())+S.nz(s.get(1))-S.nz(e.get(t));return s.set(r),r},S.sma=function(e,t,i){var s=S.sum(e,t,i);return S.na(e.get(t-1))?NaN:s/t},S.smma=function(e,t,i){var s=i.new_var(e),r=m.Std.sma(s,t,i),n=i.new_var(),o=(n.get(1)*(t-1)+e)/t;return n.set(m.Std.na(n.get(1))?r:o),n.get(0)},S.rma=function(e,t,i){var s=S.sum(e,t,i),r=t-1,n=e.get(r),o=i.new_var(),a=o.get(1),l=e.get(),c=S.na(n)?NaN:S.na(a)?s/t:(l+a*r)/t;return o.set(c),c},S.fixnan=function(e,t){var i=t.new_var();return isNaN(e)?i.get(1):(i.set(e),e)},S.tr=function(e,t){1===arguments.length&&(t=e,e=void 0);var i=void 0!==e&&!!e,s=t.new_var(S.close(t)),r=s.get(1);return i&&isNaN(r)&&(r=S.close(t)),S.max(S.max(S.high(t)-S.low(t),S.abs(S.high(t)-r)),S.abs(S.low(t)-r))},S.atr=function(e,t){var i=t.new_var(S.tr(t));return S.rma(i,e,t)},S.ema=function(e,t,i){var s=S.sum(e,t,i),r=i.new_var(),n=e.get(0),o=e.get(t-1),a=r.get(1),l=S.na(o)?NaN:S.na(a)?s/t:2*(n-a)/(t+1)+a;return r.set(l),l},S.wma=function(e,t,i){for(var s=0,r=t=Math.round(t);r>=0;r--){s+=(t-r)*e.get(r)}return 2*s/(t*(t+1))},S.vwma=function(e,t,i){var s=i.new_var(S.volume(i)),r=i.new_var(e.get(0)*S.volume(i));return S.sma(r,t,i)/S.sma(s,t,i)},S.swma=function(e,t){return(e.get(0)+2*e.get(1)+2*e.get(2)+e.get(3))/6},S.supertrend=function(e,t,i){var s=m.Std.atr(t,i),r=i.new_var(s).get(1),n=m.Std.hl2(i),o=n+s*e,a=n-s*e,l=m.Std.close(i),c=i.new_var(l).get(1),h=i.new_var(),d=m.Std.nz(h.get(1)),u=i.new_var(),p=m.Std.nz(u.get(1));a=S.gt(a,d)||S.lt(c,d)?a:d,h.set(a),o=S.lt(o,p)||S.gt(c,p)?o:p,u.set(o);var _=m.Std.na(),g=i.new_var(),f=g.get(1),v=-1===(_=m.Std.na(r)?1:f===p?l>o?-1:1:l<a?1:-1)?a:o;return g.set(v),[v,_]},S.lowestbars=function(e,t,i){return-y(e,t,0,(function(e,t){return S.lt(e,t)}),Number.MAX_VALUE).index},S.lowest=function(e,t,i){return y(e,t,0,(function(e,t){return S.lt(e,t)}),Number.MAX_VALUE).value},S.highestbars=function(e,t,i){return-y(e,t,0,(function(e,t){return S.gt(e,t)}),Number.MIN_VALUE).index},S.highest=function(e,t,i){return y(e,t,0,(function(e,t){return S.gt(e,t)}),Number.MIN_VALUE).value},S.cum=function(e,t){var i=t.new_var(),s=S.nz(i.get(1))+e;return i.set(s),s},S.accdist=function(e){var t=S.high(e),i=S.low(e),s=S.close(e),r=S.volume(e);return S.cum(s===t&&s===i||t===i?0:r*(2*s-i-t)/(t-i),e)},S.correlation=function(e,t,i,s){var r=S.sma(e,i,s),n=S.sma(t,i,s),o=s.new_var(e.get()*t.get());return(S.sma(o,i,s)-r*n)/Math.sqrt(S.variance2(e,r,i)*S.variance2(t,n,i))},S.stoch=function(e,t,i,s,r){var n=S.highest(t,s),o=S.lowest(i,s);return S.fixnan(100*(e.get()-o)/(n-o),r)},S.tsi=function(e,t,i,s){var r=s.new_var(S.change(e)),n=s.new_var(S.abs(S.change(e))),o=s.new_var(S.ema(r,i,s)),a=s.new_var(S.ema(n,i,s));return S.ema(o,t,s)/S.ema(a,t,s)},S.cross=function(e,t,i){
|
||||
if(isNaN(e)||isNaN(t))return!1;var s,r=i.new_var((s=e-t)<0?-1:0===s?0:1);return!isNaN(r.get(1))&&r.get(1)!==r.get()},S.linreg=function(e,t,i){for(var s=0,r=0,n=0,o=0,a=0;a<t;++a){var l=e.get(a),c=t-1-a+1;s+=c,r+=l,n+=c*c,o+=l*c}var h=(t*o-s*r)/(t*n-s*s);return r/t-h*s/t+h+h*(t-1-i)},S.sar=function(e,t,i,s){var r=s.new_var(),n=s.new_var(),o=s.new_var(),a=S.high(s),l=S.low(s),c=S.close(s),h=s.new_var(a),d=s.new_var(l),u=s.new_var(c),p=s.new_var(),_=p.get(1),m=n.get(1),g=o.get(1);n.set(m),o.set(g);var f=!1,v=d.get(1),y=d.get(2),b=h.get(1),w=h.get(2),C=u.get(),P=u.get(1);2===S.n(s)&&(S.greater(C,P)?(r.set(1),o.set(h.get()),_=v,g=h.get()):(r.set(-1),o.set(d.get()),_=b,g=d.get()),f=!0,n.set(e),m=e);var T=_+m*(g-_);return 1===r.get()?S.greater(T,d.get())&&(f=!0,r.set(-1),T=Math.max(h.get(),o.get()),o.set(d.get()),n.set(e)):S.less(T,h.get())&&(f=!0,r.set(1),T=Math.min(d.get(),o.get()),o.set(h.get()),n.set(e)),f||(1===r.get()?S.greater(h.get(),o.get())&&(o.set(h.get()),n.set(Math.min(n.get()+t,i))):S.less(d.get(),o.get())&&(o.set(d.get()),n.set(Math.min(n.get()+t,i)))),1===r.get()?(T=Math.min(T,v),S.n(s)>2&&(T=Math.min(T,y))):(T=Math.max(T,b),S.n(s)>2&&(T=Math.max(T,w))),p.set(T),T},S.alma=function(e,t,i,s){for(var r=Math.floor(i*(t-1)),n=t/s*(t/s),o=[],a=0,l=0;l<t;++l){var c=Math.exp(-1*Math.pow(l-r,2)/(2*n));a+=c,o.push(c)}for(l=0;l<t;++l)o[l]/=a;var h=0;for(l=0;l<t;++l)h+=o[l]*e.get(t-l-1);return h},S.wvap=function(e,t){return e.get()-e.get(1)},S.change=function(e){return e.get()-e.get(1)},S.roc=function(e,t){var i=e.get(t);return 100*(e.get()-i)/i},S.dev=function(e,t,i){var s=S.sma(e,t,i);return S.dev2(e,t,s)},S.dev2=function(e,t,i){for(var s=0,r=0;r<t;r++){var n=e.get(r);s+=S.abs(n-i)}return s/t},S.stdev=function(e,t,i){var s=S.variance(e,t,i);return S.sqrt(s)},S.variance=function(e,t,i){var s=S.sma(e,t,i);return S.variance2(e,s,t)},S.variance2=function(e,t,i){for(var s=0,r=0;r<i;r++){var n=e.get(r),o=S.abs(n-t);s+=o*o}return s/i},S.percentrank=function(e,t){if(S.na(e.get(t-1)))return NaN;for(var i=0,s=e.get(),r=1;r<t;r++){var n=e.get(r);S.ge(s,n)&&i++}return 100*i/t},S.createNewSessionCheck=function(e){if(void 0===e.symbol.session.timezone)return function(){return!1};var t=f.newBarBuilder(e.symbol.period,e.symbol.session);return function(e){return t.indexOfBar(e)===o.POST_SESSION&&(t.moveTo(e),!0)}},S.error=function(e){throw new s(e)},S.dmi=function(e,t,i){var s=i.new_var(S.high(i)),r=i.new_var(S.low(i)),n=S.change(s),o=-S.change(r),a=i.new_var(S.na(n)||S.na(o)?S.na():S.and(S.gt(n,o),S.gt(n,0))?n:0),l=i.new_var(S.na(o)?S.na():S.and(S.gt(o,n),S.gt(o,0))?o:0),c=S.atr(e,i),h=S.fixnan(100*S.rma(a,e,i)/c,i),d=S.fixnan(100*S.rma(l,e,i)/c,i),u=h+d;S.isZero(u)&&(u+=1);var p=Math.abs(h-d)/u*100,_=i.new_var(p),m=S.rma(_,t,i),g=i.new_var(m);return[h,d,p,m,(g.get(0)+g.get(e-1))/2]},b.LOW=0,b.HIGH=1,b.prototype.isPivotFound=function(){return-1!==this._pivotIndex.get()},b.prototype.pivotIndex=function(){return this._pivotIndex.get()},b.prototype.currentValue=function(){return this._currentValue.get()},
|
||||
b.prototype.pivotType=function(){return this._pivotType},b.prototype.reset=function(){this._currentValue.set(NaN),this._currentIndex.set(0),this._pivotIndex.set(-1)},b.prototype.isRightSideOk=function(e){return e-this._currentIndex.get()===this._areaRight},b.prototype.isViolate=function(e,t){if(e<1||isNaN(this._currentValue.get()))return!0;var i=this._series.get(this._index-e);return!!isNaN(i)||(i===this._currentValue.get()?t:this._pivotType===b.HIGH?i>this._currentValue.get():i<this._currentValue.get())},b.prototype.processPoint=function(e){this.isViolate(e,!1)&&(this._currentValue.set(this._series.get()),this._currentIndex.set(e))},b.prototype.isRestartNeeded=function(e){return e-this._currentIndex.get()>this._areaRight},b.prototype.update=function(){if(this._isNewBar&&this.isPivotFound()&&this.reset(),this.processPoint(this._index),this.isRightSideOk(this._index)){if(-1===this._pivotIndex.get()){for(var e=!0,t=0;t<this._areaLeft;++t)if(this.isViolate(this._currentIndex.get()-1-t,!0)){e=!1;break}e&&this._pivotIndex.set(this._currentIndex.get())}}else-1!==this._pivotIndex.get()&&this._pivotIndex.set(-1);if(this.isRestartNeeded(this._index)){this.reset();for(t=0;t<=this._areaRight;++t)this.processPoint(this._index-this._areaRight+t)}},w.prototype.addPivot=function(e,t,i){this._lastIndex.set(e),this._lastVal.set(t),this._lastType.set(i)},w.prototype.updatePivot=function(e,t){this._lastIndex.set(e),this._lastVal.set(t)},w.prototype.lastPrice=function(){return this._lastVal.get()},w.prototype.lastIndex=function(){return this._lastIndex.get()},w.prototype.addPoint=function(e,t,i){if(isNaN(this._lastVal.get()))this.addPivot(e,t,i);else{var s=this._lastVal.get();if(this._lastType.get()!==i)Math.abs(s-t)/t>this._deviation&&this.addPivot(e,t,i);else(i===b.HIGH?t>s:t<s)&&this.updatePivot(e,t)}},w.prototype.processPivot=function(e){e.update(),this._isBarClosed&&e.isPivotFound()&&this.addPoint(e.pivotIndex(),e.currentValue(),e.pivotType())},S.zigzag=function(e,t,i){return new w(e,t,i).lastPrice()},S.zigzagbars=function(e,t,i){var s=new w(e,t,i);return-1===s.lastIndex()?NaN:s.lastIndex()-S.n(i)},C.prototype.new_sym=function(e,t,i,s){return this.symbol.script.add_sym(e,t,i,s)},C.prototype.select_sym=function(e){this.symbol=this.symbol.script.get_sym(e)},C.prototype.is_main_symbol=function(e){return void 0!==e&&e===this.symbol.script.get_sym(0)},C.prototype.new_var=function(e){var t=this.vars;t.length<=this.vars_index&&t.push(new P(this.symbol));var i=t[this.vars_index++];return arguments.length>0&&i.set(e),i},C.prototype.new_unlimited_var=function(e){var t=this.vars;t.length<=this.vars_index&&t.push(new T(this.symbol));var i=t[this.vars_index++];return arguments.length>0&&i.set(e),i},C.prototype.new_ctx=function(){return this.ctx.length<=this.ctx_index&&this.ctx.push(new C(this.symbol)),this.ctx[this.ctx_index++]},C.prototype.prepare=function(e){this.ctx_index=0,this.vars_index=0;for(var t=0;t<this.vars.length;t++)this.vars[t].prepare(e);for(var i=0;i<this.ctx.length;i++)this.ctx[i].prepare(e)},
|
||||
C.prototype.maxAdditionalDepth=function(){if(null!==this.minimumAdditionalDepth)return this.minimumAdditionalDepth;for(var e=0,t=0;t<this.vars.length;t++){var i=this.vars[t].mindepth;!isNaN(i)&&i>e&&(e=i)}return e},C.prototype.stop=function(){this.symbol=null,this.vars=null},C.prototype.setMinimumAdditionalDepth=function(e){this.minimumAdditionalDepth=e},P.prototype.valueOf=function(){return this.get(0)},P.prototype.get=function(e){return isNaN(e)&&(e=0),e=e||0,this.hist?e>=this.hist.length?(console.error("not enough depth: "+this),NaN):this._get(e):(this.mindepth=S.max(this.mindepth,e),NaN)},P.prototype._get=function(e){var t=this.hist_pos-e;return t<0&&(t+=this.hist.length),this.hist[t]},P.prototype.set=function(e){this.hist&&(this.hist[this.hist_pos]=e,this.modified=!0)},P.prototype.prepare=function(e){e===this.symbol&&(e.isNewBar?(this.original=this.get(0),!this.modified&&this.hist||this.add_hist()):this.set(this.original),this.modified=!1)},P.prototype.add_hist=function(){if(!this.hist){var e=S.na(this.mindepth)?S.max_series_default_size:S.max(this.mindepth+1,1);e=Math.round(e);for(var t=new Array(e),i=0;i<e;i++)t[i]=NaN;this.hist=t,this.hist_pos=-1}this.hist_pos=Math.min(this.hist_pos+1,this.hist.length),this.hist_pos===this.hist.length&&(this.hist_pos=this.hist.length-1,this.hist.shift(),this.hist.push(NaN)),this.hist[this.hist_pos]=this.original},P.prototype.adopt=function(e,t,i){this.hist||(this.mindepth=NaN);var s=t.get(),r=e.indexOf(s);if(0!==i){var n=t.get(1);if(!S.na(n))r=r===e.indexOf(n)?-1:r}return r<0?NaN:this._get(r)},P.prototype.indexOf=function(e){if(!this.hist)return this.mindepth=NaN,-1;if(S.na(e))return-1;var t=this.hist.length,i=this.symbol.index+1,s=Math.min(t,i),n=r.upperbound_int(this.hist,e,0,s);return 0===n?-1:s-n},n(T,P),T.prototype.add_hist=function(){if(this.hist||(this.hist=new Float64Array(2e3),this.hist_pos=-1),this.hist_pos=this.hist_pos+1,this.hist_pos===this.hist.length){var e=new Float64Array(2*this.hist.length);e.set(this.hist),this.hist=e}this.hist[this.hist_pos]=this.original},x.prototype.set_symbolinfo=function(e){if(e||console.error("WARN: symbolinfo isn't defined for "+this.tickerid),this.info=e,this.minTick=e.minmov/e.pricescale,this.currencyCode=e.currency_code,this.unitId=e.unit_id,this.subsessionId=e.subsession_id,this.timezone=g.get_timezone(e.timezone),this.session.init(e.timezone,e.session,e.session_holidays,e.corrections),void 0!==e.subsessions){const t=e.subsessions.find(e=>e.id===u.Regular),i=e.subsessions.find(e=>e.id===u.PreMarket),s=e.subsessions.find(e=>e.id===u.PostMarket);void 0!==t&&(this.regularSubsession=new _(e.timezone,t.session,e.session_holidays,t["session-correction"])),void 0!==i&&(this.preMarketSubsession=new _(e.timezone,i.session,e.session_holidays,i["session-correction"])),void 0!==s&&(this.postMarketSubsession=new _(e.timezone,s.session,e.session_holidays,s["session-correction"]))}},x.prototype.isdwm=function(){return""!==this.resolution&&"S"!==this.resolution&&"T"!==this.resolution},x.prototype.enable_dwm_aligning=function(e,t){
|
||||
this.dwm_aligner=f.newBarBuilder(this.period,e,t)},x.prototype.bartime=function(){var e=this.time;if(!this.isdwm()||isNaN(e))return e;var t=g.utc_to_cal(this.timezone,e);return this.session.spec.correctTradingDay(t),g.cal_to_utc(this.timezone,t)},x.prototype.lastbar=function(e){if(!isNaN(e.time)){var t=e.time;this.dwm_aligner&&(this.dwm_aligner.moveTo(t),t=this.dwm_aligner.startOfBar(0));var i=this.time!==t;i&&this.index>=0&&!this.isBarClosed&&(this.isNewBar=!1,this.isBarClosed=!0,this.script.calc(this)),this.time=t,this.open=e.open,this.high=e.high,this.low=e.low,this.close=e.close,this.volume=e.volume,this.updatetime=e.updatetime,this.isNewBar=i,this.isBarClosed=e.isBarClosed,this.isLastBar=e.isLastBar,this.isNewBar&&(this.index++,this.isFirstBar=0===this.index),this.script.calc(this)}},I.prototype.calc=function(e){var t=this.ctx,i=this.body;t.prepare(e);var s=i.main(t,this.inputCallback,e);if(s&&"composite"===s.type)for(let e=0;e<s.data.length;++e)this._processResult(s.data[e]);else this._processResult(s)},I.prototype._processResult=function(e){var t=this.ctx,i=this;this.out&&e&&(!isNaN(t.symbol.time)||e.nonseries)&&(e.nonseries?("projection"===e.type&&(e.projectionTime=t.symbol.time),this.nonseriesOut(t.symbol,e)):e.bars?e.bars.forEach((function(e){i.out(t.symbol,e)})):this.out(t.symbol,e))},I.prototype.init=function(){var e=this.ctx,t=this.body;t.init&&t.init(e,this.inputCallback),t.main(e,this.inputCallback)},I.prototype.add_sym=function(e,t,i,s,r,n){var o=this.runner.add_sym(e,t,i,s,this,r);return this.symbols.push(o),o.isdwm()&&this.symbols.length>1&&o.enable_dwm_aligning(this.symbols[0].session,o.session),o},I.prototype.maxAdditionalDepth=function(){return this.symbols[0].isAdditionalDepthAllowed?this.ctx.maxAdditionalDepth():0},I.prototype.stop=function(){this.symbols=null,this.ctx.stop(),this.ctx=null},I.prototype.get_sym=function(e){return this.symbols[e]},M.prototype.add_sym=function(e,t,i,s,r,n,o){var a=new x(e,t,i,s,r,n);return this.symbols.push(a),a},M.prototype.get_sym=function(e){return this.symbols[e]},M.prototype.out=function(e,t){if(this.nonseriesUpdate){var i=Object.assign({},this.nonseriesUpdate);t.splice(0,0,e.time),i.lastBar=t,this.host.nonseriesOut(e,i)}else this.host.out(e,t)},M.prototype.start=function(){this.isStarted=!0;var e=this.host;this._script=new I(e.tickerid,e.period,e.currencyCode,e.unitId,this,e.body,this.out.bind(this),e.input,e.nonseriesOut,e.symbolInfo,e.subsessionId);var t=this,i=[],s=this.symbols,r=Object.assign({},e.dataRange,{countBack:e.dataRange.countBack+t._script.maxAdditionalDepth()}),n=s[0];function o(t,s,r){i.push(M.feed.subscribe(t.tickerid,t.currencyCode,t.unitId,t.period,r,e.onErrorCallback,e.symbolInfo,e.sessionId,s,e.forceAlignBars,t.subsessionId))}function h(i,s){"series"===(s.nonseries?"nonseries":"series")?t.update(i,s):s.lastBar?(t.nonseriesUpdate=s,s.lastBar.isLastBar=!0,t.symbols[0].lastbar(s.lastBar),t.nonseriesUpdate=null):e.nonseriesOut(p,s)}function d(){return r}o(n,d,(function(e){!e.nonseries&&Number.isFinite(e.firstLoadedTimeMs)&&function(e){
|
||||
function i(i,s){var r=c(i,s)(e),n=l(i,s);return null!==n&&(r=n.timeToExchangeTradingDay(r)),{to:r,countBack:t._script.maxAdditionalDepth()}}for(var r=1;r<s.length;r++){var d=s[r],u=d.period;a.isEqual(u,n.period)||o(d,i.bind(null,u),h.bind(null,r))}}(e.firstLoadedTimeMs),h(0,e)}));for(var u=1;u<s.length;u++){var p=s[u];a.isEqual(p.period,n.period)&&o(p,d,h.bind(null,u))}this.subscription=i},M.prototype.stop=function(){var e=this.subscription;if(e||this._script){for(var t=0;t<e.length;t++)M.feed.unsubscribe(e[t]);this.subscription=null,this._script.stop(),this._script=null,this.symbols=null,this.isStarted=!1}else console.warn("Recurring script engine stop happened.")},M.prototype.update=function(e,t){if(t){var i=this.symbols[e];if(this.isRecalculated){var s=t.bar(t.count()-1);s.isBarClosed=t.isLastBarClosed(),s.isLastBar=!0,i.lastbar(s)}else this.barsets[e]||(this.barsets[e]=t,i.set_symbolinfo(t.symbolinfo()),this.recalc())}else console.error("Unexpected barset = null")},M.prototype.recalc=function(){for(var e=this.symbols,t=0;t<e.length;t++)if(!this.barsets[t])return;try{for(var i=e.length-1;i>=0;i--)for(var s=e[i],r=this.barsets[i],n=r.count(),o=0;o<n;o++){var a=r.bar(o);a.isLastBar=o===n-1,a.isBarClosed=!a.isLastBar||r.isLastBarClosed(),s.lastbar(a)}this.isRecalculated=!0,this.barsets[0]&&this.barsets[0].endOfData&&this.host.setNoMoreData(),this.host.recalc(this,{endOfData:this.barsets[0].endOfData,firstLoadedTimeMs:this.barsets[0].firstLoadedTimeMs,emptyBarCount:this.barsets[0].emptyBarCount()})}catch(e){if(!e.studyError)throw e;this.host.onErrorCallback(e.message)}},M.feed={subscribe:function(e,t,i,s,r){console.error("must be initialized with setupFeed")},unsubscribe:function(e){console.error("must be initialized with setupFeed")}},L.prototype.stop=function(){this.runner.stop()},L.prototype.isStarted=function(){return this.runner.isStarted},A.prototype.symbolinfo=function(){return this.info},A.prototype.isLastBarClosed=function(){return this.isBarClosed},A.prototype.setLastBarClosed=function(e){this.isBarClosed=e},A.prototype.bar=function(e){return this.bars[e]},A.prototype.count=function(){return this.bars.length},A.prototype.emptyBarCount=function(){return this._emptyBarCount},A.prototype.add=function(e,t,i){void 0===i&&(i=!1);var s=e,r=this.bars,n=r.length,o=s.time,a=0===n?NaN:r[n-1].time;0===n||a<o?(r.push(s),i&&(this._emptyBarCount+=1,this._lastBarIsEmpty=!0)):a===o?(i!==this._lastBarIsEmpty&&(this._emptyBarCount+=i?1:-1,this._lastBarIsEmpty=i),r[n-1]=s):console.error("time order violation, prev: "+new Date(a).toUTCString()+", cur: "+new Date(o).toUTCString()),this.isBarClosed=!!t},E.prototype.init=function(e){this.bb=f.newBarBuilder(this.period,e.symbol.session),this.bbEmptyBars=this.generateEmptyBars?f.newBarBuilder(this.period,e.symbol.session):void 0,e.setMinimumAdditionalDepth(0)},E.prototype.extrapolate=function(e,t){return isNaN(e)||isNaN(t)?void 0:v(this.bbEmptyBars,e,t,Number.MAX_SAFE_INTEGER,!0).times},E.prototype.main=function(e){
|
||||
var t=e.symbol.time,i=this.bb.alignTime(t),s=e.new_var(i),r=S.na(i),n=s.get(1),o=S.na(n)?1:S.neq(i,n),a=e.new_var(),l=e.new_var(),c=e.new_var(),h=e.new_var(),d=a.get(1),u=l.get(1),p=c.get(1),_=h.get(1),m=r?NaN:o?S.open(e):d,g=r?NaN:o?S.high(e):S.max(S.high(e),u),f=r?NaN:o?S.low(e):S.min(S.low(e),p),v=r?NaN:S.close(e),y=r?NaN:o?S.volume(e):S.volume(e)+_,b=r?NaN:t,w=e.symbol.isBarClosed&&this.bb.isLastBar(0,t),C=this.generateEmptyBars&&o?this.extrapolate(n,i):void 0,P=e.new_var(S.close(e)).get(1),T=C instanceof Array?P:NaN;return a.set(m),l.set(g),c.set(f),h.set(y),[i,m,g,f,v,y,b,w,C,T]},k.prototype.main=function(e){return[S.open(e),S.high(e),S.low(e),S.close(e),S.volume(e),S.updatetime(e)]},{Std:S,Series:P,Symbol:x,SymbolInfo:function(e,t){this.timezone=e||"America/New_York",this.session=t||"0000-0000"},StudyEngine:L,BarSet:A,OHLCV:k,BarBuilder:E,setupFeed:function(e){M.feed=e},getVolumeProfileResolutionForPeriod:function(t,i,s,r){return void 0!==e?e(t,i,s,r):t},overwriteVolumeProfileResolutionForPeriodGetter:function(t){e=t}}}();e.exports=m},15495:(e,t,i)=>{"use strict";const s=i(45112).getHexColorByName;var r=i(216);i(27595);var n=i(99294).pivotPointsStandardStudyItem,o=i(62839).volumeProfileVisibleRangeStudyItem,a=i(5748).volumeProfileFixedRangeVbPStudyItem,l=i(5748).volumeProfileFixedRangeBSStudyItem,c=i(65754).spreadStudyItem,h=i(82366).ratioStudyItem,d=i(13463).regressionTrendStudyItem;const u=s("color-ripe-red-400"),p=s("color-minty-green-400");JSServer.studyLibrary=JSServer.studyLibrary.concat([{name:"Compare",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!0,defaults:{styles:{compare:{linestyle:0,linewidth:2,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#9C27B0"}},inputs:{source:"close",symbol:""}},plots:[{id:"compare",type:"line"}],styles:{compare:{title:"Plot",histogramBase:0}},description:"Compare",shortDescription:"Compare",is_price_study:!0,inputs:[{defval:"close",id:"source",name:"Source",options:["open","high","low","close","hl2","hlc3","ohlc4"],type:"text"},{id:"symbol",name:"Symbol",type:"symbol",isHidden:!0}],id:"Compare@tv-basicstudies-1",format:{type:"inherit"}},constructor:function(){this.init=function(e,t){this._context=e,this._context.new_sym(t(1),r.Std.period(this._context))},this.main=function(e,t){this._context=e;var i=this._context.new_unlimited_var(this._context.symbol.time);this._context.select_sym(1);var s=this._context.new_unlimited_var(this._context.symbol.time),n=r.Std[t(0)](this._context),o=this._context.new_unlimited_var(n);return this._context.select_sym(0),[o.adopt(s,i,0)]}}},{name:"Overlay",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!0,defaults:{styles:{},inputs:{symbol:""}},plots:[{id:"open",type:"line"},{id:"high",type:"line"},{id:"low",type:"line"},{id:"close",type:"line"}],styles:{open:{title:"Open"},high:{title:"High"},low:{title:"Low"},close:{title:"Close"}},description:"Overlay",shortDescription:"Overlay",is_price_study:!1,inputs:[{id:"symbol",name:"symbol",defval:"",type:"symbol",isHidden:!0}],
|
||||
id:"Overlay@tv-basicstudies-1",format:{type:"price",precision:4}},constructor:function(){this.init=function(e,t){this._context=e,this._context.new_sym(t(0),r.Std.period(this._context))},this.main=function(e,t){this._context=e;var i=this._context.new_unlimited_var(this._context.symbol.time);this._context.select_sym(1);var s=this._context.new_unlimited_var(this._context.symbol.time),n=this._context.new_unlimited_var(r.Std.open(this._context)),o=this._context.new_unlimited_var(r.Std.high(this._context)),a=this._context.new_unlimited_var(r.Std.low(this._context)),l=this._context.new_unlimited_var(r.Std.close(this._context));return this._context.select_sym(0),[n.adopt(s,i,1),o.adopt(s,i,1),a.adopt(s,i,1),l.adopt(s,i,1)]}}},{name:"Volume",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{vol:{linestyle:0,linewidth:1,plottype:5,trackPrice:!1,transparency:50,visible:!0,color:"#000080"},vol_ma:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1,color:"#2196F3"},smoothedMA:{linestyle:0,linewidth:1,plottype:0,trackPrice:!1,transparency:0,visible:!1,color:"#2196F3"}},palettes:{volumePalette:{colors:{0:{color:u,width:1,style:0},1:{color:p,width:1,style:0}}}},inputs:{showMA:!1,length:20,col_prev_close:!1,symbol:"",smoothingLine:"SMA",smoothingLength:9}},plots:[{id:"vol",type:"line"},{id:"volumePalette",palette:"volumePalette",target:"vol",type:"colorer"},{id:"vol_ma",type:"line"},{id:"smoothedMA",type:"line"}],styles:{vol:{title:"Volume",histogramBase:0},vol_ma:{title:"Volume MA",histogramBase:0},smoothedMA:{title:"Smoothed MA",histogramBase:0}},description:"Volume",shortDescription:"Volume",is_price_study:!1,palettes:{volumePalette:{colors:{0:{name:"Falling"},1:{name:"Growing"}}}},inputs:[{id:"symbol",name:"Other Symbol",defval:"",type:"symbol",optional:!0,isHidden:!1},{id:"showMA",name:"show MA",defval:!1,type:"bool",isHidden:!0},{id:"length",name:"MA Length",defval:20,type:"integer",min:1,max:2e3},{defval:!1,id:"col_prev_close",name:"Color based on previous close",type:"bool"},{id:"smoothingLine",name:"Smoothing Line",defval:"SMA",type:"text",options:["SMA","EMA","WMA"]},{id:"smoothingLength",name:"Smoothing Length",defval:9,type:"integer",min:1,max:1e4}],id:"Volume@tv-basicstudies-1",format:{type:"volume"}},constructor:function(){this.init=function(e,t){this._context=e,""!==t(0)&&this._context.new_sym(t(0),r.Std.period(this._context))},this.f_0=function(e,t){return r.Std.gt(e,t)?0:1},this.main=function(e,t){this._context=e,this._input=t;var i=r.Std.volume(this._context),s=r.Std.open(this._context),n=r.Std.close(this._context),o=this._context.new_var(this._context.symbol.time),a=this._input(4),l=this._input(5);if(this._context.setMinimumAdditionalDepth(this._input(2)+l),""!==this._input(0)){this._context.select_sym(1);var c=this._context.new_var(this._context.symbol.time),h=this._context.new_var(r.Std.volume(this._context)),d=this._context.new_var(r.Std.open(this._context)),u=this._context.new_var(r.Std.close(this._context));i=h.adopt(c,o,1),
|
||||
s=d.adopt(c,o,1),n=u.adopt(c,o,1),this._context.select_sym(0)}var p,_,m=this._context.new_var(i),g=r.Std.sma(m,this._input(2),this._context),f=this._context.new_var(g),v=this._context.new_var(n);return p=v.get(1)&&this._input(3)?this.f_0(v.get(1),n):this.f_0(s,n),"EMA"===a?_=r.Std.ema(f,l,this._context):"WMA"===a?_=r.Std.wma(f,l,this._context):"SMA"===a&&(_=r.Std.sma(f,l,this._context)),[i,p,g,_]}}},{name:"ZigZag",metainfo:{_metainfoVersion:52,isTVScript:!1,isTVScriptStub:!1,is_hidden_study:!1,defaults:{styles:{plot_0:{linestyle:0,linewidth:2,plottype:0,trackPrice:!1,transparency:0,visible:!0,color:"#2196F3"}},inputs:{in_0:5,in_1:10}},plots:[{id:"plot_0",type:"line"},{id:"plot_1",target:"plot_0",type:"dataoffset"}],styles:{plot_0:{title:"Plot",histogramBase:0,joinPoints:!1}},description:"Zig Zag",shortDescription:"ZigZag",is_price_study:!0,classId:"ScriptWithDataOffset",inputs:[{id:"in_0",name:"deviation",defval:5,type:"float",min:.001,max:100},{id:"in_1",name:"depth",defval:10,type:"integer",min:2,max:1e3}],id:"ZigZag@tv-basicstudies-1",format:{type:"inherit"}},constructor:function(){this.main=function(e,t){this._context=e,this._input=t;var i=this._input(0),s=this._input(1),n=i/100,o=Math.ceil(s/2);return[r.Std.zigzag(n,o,this._context),r.Std.zigzagbars(n,o,this._context)]}}},{name:"Sessions",metainfo:{_metainfoVersion:52,defaults:{graphics:{vertlines:{sessBreaks:{color:"#4985e7",style:2,visible:!1,width:1}},backgrounds:{preMarket:{color:"#FF9800",transparency:92,visible:!0},postMarket:{color:"#2196F3",transparency:92,visible:!0}}},linkedToSeries:!0},description:"Sessions",graphics:{vertlines:{sessBreaks:{name:"Session Break",halign:"left"}},backgrounds:{preMarket:{name:"Pre market"},postMarket:{name:"Post market"}}},id:"Sessions@tv-basicstudies-1",inputs:[],is_hidden_study:!0,is_price_study:!0,name:"Sessions@tv-basicstudies",palettes:{},plots:[],shortDescription:"Sessions",format:{type:"inherit"}},constructor:function(){function e(e,t){return{id:e,index:e,extendBottom:!0,extendTop:!0}}function t(e){return{id:e.start,start:e.start,stop:e.stop}}this.init=function(){this._times=[]},this._getVerticalLineData=function(t){return r.Std.selectSessionBreaks(t,this._times).map(e)},this._getPreAndPostMarketBackgroundsData=function(e){const i=r.Std.selectPreAndPostMarketTimes(e,this._times);return{preMarket:i.preMarket.map(t),postMarket:i.postMarket.map(t)}},this.main=function(e,t){if(r.Std.isdwm(e))return null;var i=r.Std.time(e);if(isNaN(i))return null;var s=this._times.length;if(0!==s&&this._times[s-1]===i||this._times.push(i),!e.symbol.isLastBar||!e.symbol.isNewBar)return null;var n=this._getVerticalLineData(e),o=this._getPreAndPostMarketBackgroundsData(e);return 0===n.length&&0===o.preMarket.length&&0===o.postMarket?null:{nonseries:!0,type:"study_graphics",data:{graphicsCmds:{create:{vertlines:[{styleId:"sessBreaks",data:n}],backgrounds:[{styleId:"preMarket",data:o.preMarket},{styleId:"postMarket",data:o.postMarket}]},erase:[{action:"all"}]}}}}}},{name:"SuperTrend",metainfo:{_metainfoVersion:52,isTVScript:!1,
|
||||
File diff suppressed because one or more lines are too long
4
charting_library/charting_library.d.ts
vendored
4
charting_library/charting_library.d.ts
vendored
@@ -2485,6 +2485,10 @@ export interface IPaneApi {
|
||||
setHeight(height: number): void;
|
||||
moveTo(paneIndex: number): void;
|
||||
paneIndex(): number;
|
||||
/** Collapse the current pane */
|
||||
collapse(): void;
|
||||
/** Restore the size of a previously collapsed pane */
|
||||
restore(): void;
|
||||
}
|
||||
export interface IPositionLineAdapter {
|
||||
remove(): void;
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"private": true,
|
||||
"description": "CL v23.040 (internal id 689d7ee0 @ 2023-01-17T06:08:02.188Z)",
|
||||
"description": "CL v23.041 (internal id 1c4a7b40 @ 2023-01-18T06:07:23.411Z)",
|
||||
"type": "module",
|
||||
"main": "charting_library.cjs.js",
|
||||
"module": "charting_library.esm.js",
|
||||
|
||||
Reference in New Issue
Block a user