indicators-all.src.js 429 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666
  1. /**
  2. * @license Highstock JS v9.0.1 (2021-02-16)
  3. *
  4. * All technical indicators for Highstock
  5. *
  6. * (c) 2010-2021 Pawel Fus
  7. *
  8. * License: www.highcharts.com/license
  9. */
  10. 'use strict';
  11. (function (factory) {
  12. if (typeof module === 'object' && module.exports) {
  13. factory['default'] = factory;
  14. module.exports = factory;
  15. } else if (typeof define === 'function' && define.amd) {
  16. define('highcharts/indicators/indicators-all', ['highcharts', 'highcharts/modules/stock'], function (Highcharts) {
  17. factory(Highcharts);
  18. factory.Highcharts = Highcharts;
  19. return factory;
  20. });
  21. } else {
  22. factory(typeof Highcharts !== 'undefined' ? Highcharts : undefined);
  23. }
  24. }(function (Highcharts) {
  25. var _modules = Highcharts ? Highcharts._modules : {};
  26. function _registerModule(obj, path, args, fn) {
  27. if (!obj.hasOwnProperty(path)) {
  28. obj[path] = fn.apply(null, args);
  29. }
  30. }
  31. _registerModule(_modules, 'Mixins/IndicatorRequired.js', [_modules['Core/Utilities.js']], function (U) {
  32. /**
  33. *
  34. * (c) 2010-2021 Daniel Studencki
  35. *
  36. * License: www.highcharts.com/license
  37. *
  38. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  39. *
  40. * */
  41. var error = U.error;
  42. /* eslint-disable no-invalid-this, valid-jsdoc */
  43. var requiredIndicatorMixin = {
  44. /**
  45. * Check whether given indicator is loaded,
  46. else throw error.
  47. * @private
  48. * @param {Highcharts.Indicator} indicator
  49. * Indicator constructor function.
  50. * @param {string} requiredIndicator
  51. * Required indicator type.
  52. * @param {string} type
  53. * Type of indicator where function was called (parent).
  54. * @param {Highcharts.IndicatorCallbackFunction} callback
  55. * Callback which is triggered if the given indicator is loaded.
  56. * Takes indicator as an argument.
  57. * @param {string} errMessage
  58. * Error message that will be logged in console.
  59. * @return {boolean}
  60. * Returns false when there is no required indicator loaded.
  61. */
  62. isParentLoaded: function (indicator,
  63. requiredIndicator,
  64. type,
  65. callback,
  66. errMessage) {
  67. if (indicator) {
  68. return callback ? callback(indicator) : true;
  69. }
  70. error(errMessage || this.generateMessage(type, requiredIndicator));
  71. return false;
  72. },
  73. /**
  74. * @private
  75. * @param {string} indicatorType
  76. * Indicator type
  77. * @param {string} required
  78. * Required indicator
  79. * @return {string}
  80. * Error message
  81. */
  82. generateMessage: function (indicatorType, required) {
  83. return 'Error: "' + indicatorType +
  84. '" indicator type requires "' + required +
  85. '" indicator loaded before. Please read docs: ' +
  86. 'https://api.highcharts.com/highstock/plotOptions.' +
  87. indicatorType;
  88. }
  89. };
  90. return requiredIndicatorMixin;
  91. });
  92. _registerModule(_modules, 'Stock/Indicators/SMA/SMAComposition.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  93. /* *
  94. *
  95. * License: www.highcharts.com/license
  96. *
  97. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  98. *
  99. * */
  100. var Series = SeriesRegistry.series,
  101. ohlcProto = SeriesRegistry.seriesTypes.ohlc.prototype;
  102. var addEvent = U.addEvent,
  103. extend = U.extend;
  104. /* *
  105. *
  106. * Composition
  107. *
  108. * */
  109. addEvent(Series, 'init', function (eventOptions) {
  110. // eslint-disable-next-line no-invalid-this
  111. var series = this,
  112. options = eventOptions.options;
  113. if (options.useOhlcData &&
  114. options.id !== 'highcharts-navigator-series') {
  115. extend(series, {
  116. pointValKey: ohlcProto.pointValKey,
  117. keys: ohlcProto.keys,
  118. pointArrayMap: ohlcProto.pointArrayMap,
  119. toYData: ohlcProto.toYData
  120. });
  121. }
  122. });
  123. addEvent(Series, 'afterSetOptions', function (e) {
  124. var options = e.options,
  125. dataGrouping = options.dataGrouping;
  126. if (dataGrouping &&
  127. options.useOhlcData &&
  128. options.id !== 'highcharts-navigator-series') {
  129. dataGrouping.approximation = 'ohlc';
  130. }
  131. });
  132. });
  133. _registerModule(_modules, 'Stock/Indicators/SMA/SMAIndicator.js', [_modules['Mixins/IndicatorRequired.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (RequiredIndicatorMixin, SeriesRegistry, U) {
  134. /* *
  135. *
  136. * License: www.highcharts.com/license
  137. *
  138. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  139. *
  140. * */
  141. var __extends = (this && this.__extends) || (function () {
  142. var extendStatics = function (d,
  143. b) {
  144. extendStatics = Object.setPrototypeOf ||
  145. ({ __proto__: [] } instanceof Array && function (d,
  146. b) { d.__proto__ = b; }) ||
  147. function (d,
  148. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  149. return extendStatics(d, b);
  150. };
  151. return function (d, b) {
  152. extendStatics(d, b);
  153. function __() { this.constructor = d; }
  154. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  155. };
  156. })();
  157. var LineSeries = SeriesRegistry.seriesTypes.line;
  158. var addEvent = U.addEvent,
  159. error = U.error,
  160. extend = U.extend,
  161. isArray = U.isArray,
  162. merge = U.merge,
  163. pick = U.pick,
  164. splat = U.splat;
  165. var generateMessage = RequiredIndicatorMixin.generateMessage;
  166. /* *
  167. *
  168. * Class
  169. *
  170. * */
  171. /**
  172. * The SMA series type.
  173. *
  174. * @private
  175. */
  176. var SMAIndicator = /** @class */ (function (_super) {
  177. __extends(SMAIndicator, _super);
  178. function SMAIndicator() {
  179. /* *
  180. *
  181. * Static Properties
  182. *
  183. * */
  184. var _this = _super !== null && _super.apply(this,
  185. arguments) || this;
  186. /* *
  187. *
  188. * Properties
  189. *
  190. * */
  191. _this.data = void 0;
  192. _this.dataEventsToUnbind = void 0;
  193. _this.linkedParent = void 0;
  194. _this.options = void 0;
  195. _this.points = void 0;
  196. return _this;
  197. /* eslint-enable valid-jsdoc */
  198. }
  199. /* *
  200. *
  201. * Functions
  202. *
  203. * */
  204. /* eslint-disable valid-jsdoc */
  205. /**
  206. * @private
  207. */
  208. SMAIndicator.prototype.destroy = function () {
  209. this.dataEventsToUnbind.forEach(function (unbinder) {
  210. unbinder();
  211. });
  212. _super.prototype.destroy.apply(this, arguments);
  213. };
  214. /**
  215. * @private
  216. */
  217. SMAIndicator.prototype.getName = function () {
  218. var name = this.name,
  219. params = [];
  220. if (!name) {
  221. (this.nameComponents || []).forEach(function (component, index) {
  222. params.push(this.options.params[component] +
  223. pick(this.nameSuffixes[index], ''));
  224. }, this);
  225. name = (this.nameBase || this.type.toUpperCase()) +
  226. (this.nameComponents ? ' (' + params.join(', ') + ')' : '');
  227. }
  228. return name;
  229. };
  230. /**
  231. * @private
  232. */
  233. SMAIndicator.prototype.getValues = function (series, params) {
  234. var period = params.period,
  235. xVal = series.xData,
  236. yVal = series.yData,
  237. yValLen = yVal.length,
  238. range = 0,
  239. sum = 0,
  240. SMA = [],
  241. xData = [],
  242. yData = [],
  243. index = -1,
  244. i,
  245. SMAPoint;
  246. if (xVal.length < period) {
  247. return;
  248. }
  249. // Switch index for OHLC / Candlestick / Arearange
  250. if (isArray(yVal[0])) {
  251. index = params.index ? params.index : 0;
  252. }
  253. // Accumulate first N-points
  254. while (range < period - 1) {
  255. sum += index < 0 ? yVal[range] : yVal[range][index];
  256. range++;
  257. }
  258. // Calculate value one-by-one for each period in visible data
  259. for (i = range; i < yValLen; i++) {
  260. sum += index < 0 ? yVal[i] : yVal[i][index];
  261. SMAPoint = [xVal[i], sum / period];
  262. SMA.push(SMAPoint);
  263. xData.push(SMAPoint[0]);
  264. yData.push(SMAPoint[1]);
  265. sum -= (index < 0 ?
  266. yVal[i - range] :
  267. yVal[i - range][index]);
  268. }
  269. return {
  270. values: SMA,
  271. xData: xData,
  272. yData: yData
  273. };
  274. };
  275. /**
  276. * @private
  277. */
  278. SMAIndicator.prototype.init = function (chart, options) {
  279. var indicator = this,
  280. requiredIndicators = indicator.requireIndicators();
  281. // Check whether all required indicators are loaded.
  282. if (!requiredIndicators.allLoaded) {
  283. return error(generateMessage(indicator.type, requiredIndicators.needed));
  284. }
  285. _super.prototype.init.call(indicator, chart, options);
  286. // Make sure we find series which is a base for an indicator
  287. chart.linkSeries();
  288. indicator.dataEventsToUnbind = [];
  289. /**
  290. * @private
  291. * @return {void}
  292. */
  293. function recalculateValues() {
  294. var oldData = indicator.points || [],
  295. oldDataLength = (indicator.xData || []).length,
  296. processedData = (indicator.getValues(indicator.linkedParent,
  297. indicator.options.params) || {
  298. values: [],
  299. xData: [],
  300. yData: []
  301. }),
  302. croppedDataValues = [],
  303. overwriteData = true,
  304. oldFirstPointIndex,
  305. oldLastPointIndex,
  306. croppedData,
  307. min,
  308. max,
  309. i;
  310. // We need to update points to reflect changes in all,
  311. // x and y's, values. However, do it only for non-grouped
  312. // data - grouping does it for us (#8572)
  313. if (oldDataLength &&
  314. !indicator.hasGroupedData &&
  315. indicator.visible &&
  316. indicator.points) {
  317. // When data is cropped update only avaliable points (#9493)
  318. if (indicator.cropped) {
  319. if (indicator.xAxis) {
  320. min = indicator.xAxis.min;
  321. max = indicator.xAxis.max;
  322. }
  323. croppedData = indicator.cropData(processedData.xData, processedData.yData, min, max);
  324. for (i = 0; i < croppedData.xData.length; i++) {
  325. // (#10774)
  326. croppedDataValues.push([
  327. croppedData.xData[i]
  328. ].concat(splat(croppedData.yData[i])));
  329. }
  330. oldFirstPointIndex = processedData.xData.indexOf(indicator.xData[0]);
  331. oldLastPointIndex = processedData.xData.indexOf(indicator.xData[indicator.xData.length - 1]);
  332. // Check if indicator points should be shifted (#8572)
  333. if (oldFirstPointIndex === -1 &&
  334. oldLastPointIndex === processedData.xData.length - 2) {
  335. if (croppedDataValues[0][0] === oldData[0].x) {
  336. croppedDataValues.shift();
  337. }
  338. }
  339. indicator.updateData(croppedDataValues);
  340. // Omit addPoint() and removePoint() cases
  341. }
  342. else if (processedData.xData.length !== oldDataLength - 1 &&
  343. processedData.xData.length !== oldDataLength + 1) {
  344. overwriteData = false;
  345. indicator.updateData(processedData.values);
  346. }
  347. }
  348. if (overwriteData) {
  349. indicator.xData = processedData.xData;
  350. indicator.yData = processedData.yData;
  351. indicator.options.data = processedData.values;
  352. }
  353. // Removal of processedXData property is required because on
  354. // first translate processedXData array is empty
  355. if (indicator.bindTo.series === false) {
  356. delete indicator.processedXData;
  357. indicator.isDirty = true;
  358. indicator.redraw();
  359. }
  360. indicator.isDirtyData = false;
  361. }
  362. if (!indicator.linkedParent) {
  363. return error('Series ' +
  364. indicator.options.linkedTo +
  365. ' not found! Check `linkedTo`.', false, chart);
  366. }
  367. indicator.dataEventsToUnbind.push(addEvent(indicator.bindTo.series ?
  368. indicator.linkedParent :
  369. indicator.linkedParent.xAxis, indicator.bindTo.eventName, recalculateValues));
  370. if (indicator.calculateOn === 'init') {
  371. recalculateValues();
  372. }
  373. else {
  374. var unbinder = addEvent(indicator.chart,
  375. indicator.calculateOn,
  376. function () {
  377. recalculateValues();
  378. // Call this just once, on init
  379. unbinder();
  380. });
  381. }
  382. // return indicator;
  383. };
  384. /**
  385. * @private
  386. */
  387. SMAIndicator.prototype.processData = function () {
  388. var series = this,
  389. compareToMain = series.options.compareToMain,
  390. linkedParent = series.linkedParent;
  391. _super.prototype.processData.apply(series, arguments);
  392. if (linkedParent && linkedParent.compareValue && compareToMain) {
  393. series.compareValue = linkedParent.compareValue;
  394. }
  395. return;
  396. };
  397. /**
  398. * @private
  399. */
  400. SMAIndicator.prototype.requireIndicators = function () {
  401. var obj = {
  402. allLoaded: true
  403. };
  404. // Check whether all required indicators are loaded, else return
  405. // the object with missing indicator's name.
  406. this.requiredIndicators.forEach(function (indicator) {
  407. if (SeriesRegistry.seriesTypes[indicator]) {
  408. SeriesRegistry.seriesTypes[indicator].prototype.requireIndicators();
  409. }
  410. else {
  411. obj.allLoaded = false;
  412. obj.needed = indicator;
  413. }
  414. });
  415. return obj;
  416. };
  417. /**
  418. * The parameter allows setting line series type and use OHLC indicators.
  419. * Data in OHLC format is required.
  420. *
  421. * @sample {highstock} stock/indicators/use-ohlc-data
  422. * Plot line on Y axis
  423. *
  424. * @type {boolean}
  425. * @product highstock
  426. * @apioption plotOptions.line.useOhlcData
  427. */
  428. /**
  429. * Simple moving average indicator (SMA). This series requires `linkedTo`
  430. * option to be set.
  431. *
  432. * @sample stock/indicators/sma
  433. * Simple moving average indicator
  434. *
  435. * @extends plotOptions.line
  436. * @since 6.0.0
  437. * @excluding allAreas, colorAxis, dragDrop, joinBy, keys,
  438. * navigatorOptions, pointInterval, pointIntervalUnit,
  439. * pointPlacement, pointRange, pointStart, showInNavigator,
  440. * stacking, useOhlcData
  441. * @product highstock
  442. * @requires stock/indicators/indicators
  443. * @optionparent plotOptions.sma
  444. */
  445. SMAIndicator.defaultOptions = merge(LineSeries.defaultOptions, {
  446. /**
  447. * The name of the series as shown in the legend, tooltip etc. If not
  448. * set, it will be based on a technical indicator type and default
  449. * params.
  450. *
  451. * @type {string}
  452. */
  453. name: void 0,
  454. tooltip: {
  455. /**
  456. * Number of decimals in indicator series.
  457. */
  458. valueDecimals: 4
  459. },
  460. /**
  461. * The main series ID that indicator will be based on. Required for this
  462. * indicator.
  463. *
  464. * @type {string}
  465. */
  466. linkedTo: void 0,
  467. /**
  468. * Whether to compare indicator to the main series values
  469. * or indicator values.
  470. *
  471. * @sample {highstock} stock/plotoptions/series-comparetomain/
  472. * Difference between comparing SMA values to the main series
  473. * and its own values.
  474. *
  475. * @type {boolean}
  476. */
  477. compareToMain: false,
  478. /**
  479. * Paramters used in calculation of regression series' points.
  480. */
  481. params: {
  482. /**
  483. * The point index which indicator calculations will base. For
  484. * example using OHLC data, index=2 means the indicator will be
  485. * calculated using Low values.
  486. */
  487. index: 0,
  488. /**
  489. * The base period for indicator calculations. This is the number of
  490. * data points which are taken into account for the indicator
  491. * calculations.
  492. */
  493. period: 14
  494. }
  495. });
  496. return SMAIndicator;
  497. }(LineSeries));
  498. extend(SMAIndicator.prototype, {
  499. bindTo: {
  500. series: true,
  501. eventName: 'updatedData'
  502. },
  503. calculateOn: 'init',
  504. hasDerivedData: true,
  505. nameComponents: ['period'],
  506. nameSuffixes: [],
  507. // Defines on which other indicators is this indicator based on.
  508. requiredIndicators: [],
  509. useCommonDataGrouping: true
  510. });
  511. SeriesRegistry.registerSeriesType('sma', SMAIndicator);
  512. /* *
  513. *
  514. * Default Export
  515. *
  516. * */
  517. /* *
  518. *
  519. * API Options
  520. *
  521. * */
  522. /**
  523. * A `SMA` series. If the [type](#series.sma.type) option is not specified, it
  524. * is inherited from [chart.type](#chart.type).
  525. *
  526. * @extends series,plotOptions.sma
  527. * @since 6.0.0
  528. * @product highstock
  529. * @excluding dataParser, dataURL, useOhlcData
  530. * @requires stock/indicators/indicators
  531. * @apioption series.sma
  532. */
  533. ''; // adds doclet above to the transpiled file
  534. return SMAIndicator;
  535. });
  536. _registerModule(_modules, 'Stock/Indicators/AD/ADIndicator.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  537. /* *
  538. *
  539. * License: www.highcharts.com/license
  540. *
  541. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  542. * */
  543. var __extends = (this && this.__extends) || (function () {
  544. var extendStatics = function (d,
  545. b) {
  546. extendStatics = Object.setPrototypeOf ||
  547. ({ __proto__: [] } instanceof Array && function (d,
  548. b) { d.__proto__ = b; }) ||
  549. function (d,
  550. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  551. return extendStatics(d, b);
  552. };
  553. return function (d, b) {
  554. extendStatics(d, b);
  555. function __() { this.constructor = d; }
  556. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  557. };
  558. })();
  559. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  560. var error = U.error,
  561. extend = U.extend,
  562. merge = U.merge;
  563. /**
  564. * The AD series type.
  565. *
  566. * @private
  567. * @class
  568. * @name Highcharts.seriesTypes.ad
  569. *
  570. * @augments Highcharts.Series
  571. */
  572. var ADIndicator = /** @class */ (function (_super) {
  573. __extends(ADIndicator, _super);
  574. function ADIndicator() {
  575. /* *
  576. *
  577. * Static Properties
  578. *
  579. * */
  580. var _this = _super !== null && _super.apply(this,
  581. arguments) || this;
  582. /* *
  583. *
  584. * Properties
  585. *
  586. * */
  587. _this.data = void 0;
  588. _this.options = void 0;
  589. _this.points = void 0;
  590. return _this;
  591. }
  592. /* *
  593. *
  594. * Static Functions
  595. *
  596. * */
  597. ADIndicator.populateAverage = function (xVal, yVal, yValVolume, i, _period) {
  598. var high = yVal[i][1],
  599. low = yVal[i][2],
  600. close = yVal[i][3],
  601. volume = yValVolume[i],
  602. adY = close === high && close === low || high === low ?
  603. 0 :
  604. ((2 * close - low - high) / (high - low)) * volume,
  605. adX = xVal[i];
  606. return [adX, adY];
  607. };
  608. /* *
  609. *
  610. * Functions
  611. *
  612. * */
  613. ADIndicator.prototype.getValues = function (series, params) {
  614. var period = params.period,
  615. xVal = series.xData,
  616. yVal = series.yData,
  617. volumeSeriesID = params.volumeSeriesID,
  618. volumeSeries = series.chart.get(volumeSeriesID),
  619. yValVolume = volumeSeries && volumeSeries.yData,
  620. yValLen = yVal ? yVal.length : 0,
  621. AD = [],
  622. xData = [],
  623. yData = [],
  624. len,
  625. i,
  626. ADPoint;
  627. if (xVal.length <= period &&
  628. yValLen &&
  629. yVal[0].length !== 4) {
  630. return;
  631. }
  632. if (!volumeSeries) {
  633. error('Series ' +
  634. volumeSeriesID +
  635. ' not found! Check `volumeSeriesID`.', true, series.chart);
  636. return;
  637. }
  638. // i = period <-- skip first N-points
  639. // Calculate value one-by-one for each period in visible data
  640. for (i = period; i < yValLen; i++) {
  641. len = AD.length;
  642. ADPoint = ADIndicator.populateAverage(xVal, yVal, yValVolume, i, period);
  643. if (len > 0) {
  644. ADPoint[1] += AD[len - 1][1];
  645. }
  646. AD.push(ADPoint);
  647. xData.push(ADPoint[0]);
  648. yData.push(ADPoint[1]);
  649. }
  650. return {
  651. values: AD,
  652. xData: xData,
  653. yData: yData
  654. };
  655. };
  656. /**
  657. * Accumulation Distribution (AD). This series requires `linkedTo` option to
  658. * be set.
  659. *
  660. * @sample stock/indicators/accumulation-distribution
  661. * Accumulation/Distribution indicator
  662. *
  663. * @extends plotOptions.sma
  664. * @since 6.0.0
  665. * @product highstock
  666. * @requires stock/indicators/indicators
  667. * @requires stock/indicators/accumulation-distribution
  668. * @optionparent plotOptions.ad
  669. */
  670. ADIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  671. params: {
  672. /**
  673. * The id of volume series which is mandatory.
  674. * For example using OHLC data, volumeSeriesID='volume' means
  675. * the indicator will be calculated using OHLC and volume values.
  676. *
  677. * @since 6.0.0
  678. */
  679. volumeSeriesID: 'volume'
  680. }
  681. });
  682. return ADIndicator;
  683. }(SMAIndicator));
  684. extend(ADIndicator.prototype, {
  685. nameComponents: false,
  686. nameBase: 'Accumulation/Distribution'
  687. });
  688. SeriesRegistry.registerSeriesType('ad', ADIndicator);
  689. /* *
  690. *
  691. * Default Export
  692. *
  693. * */
  694. /* *
  695. *
  696. * API Options
  697. *
  698. * */
  699. /**
  700. * A `AD` series. If the [type](#series.ad.type) option is not
  701. * specified, it is inherited from [chart.type](#chart.type).
  702. *
  703. * @extends series,plotOptions.ad
  704. * @since 6.0.0
  705. * @excluding dataParser, dataURL
  706. * @product highstock
  707. * @requires stock/indicators/indicators
  708. * @requires stock/indicators/accumulation-distribution
  709. * @apioption series.ad
  710. */
  711. ''; // add doclet above to transpiled file
  712. return ADIndicator;
  713. });
  714. _registerModule(_modules, 'Stock/Indicators/AO/AOIndicator.js', [_modules['Core/Globals.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (H, SeriesRegistry, U) {
  715. /* *
  716. *
  717. * License: www.highcharts.com/license
  718. *
  719. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  720. *
  721. * */
  722. var __extends = (this && this.__extends) || (function () {
  723. var extendStatics = function (d,
  724. b) {
  725. extendStatics = Object.setPrototypeOf ||
  726. ({ __proto__: [] } instanceof Array && function (d,
  727. b) { d.__proto__ = b; }) ||
  728. function (d,
  729. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  730. return extendStatics(d, b);
  731. };
  732. return function (d, b) {
  733. extendStatics(d, b);
  734. function __() { this.constructor = d; }
  735. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  736. };
  737. })();
  738. var noop = H.noop;
  739. var _a = SeriesRegistry.seriesTypes,
  740. SMAIndicator = _a.sma,
  741. ColumnSeries = _a.column;
  742. var extend = U.extend,
  743. merge = U.merge,
  744. correctFloat = U.correctFloat,
  745. isArray = U.isArray;
  746. /* *
  747. *
  748. * Class
  749. *
  750. * */
  751. /**
  752. * The AO series type
  753. *
  754. * @private
  755. * @class
  756. * @name Highcharts.seriesTypes.ao
  757. *
  758. * @augments Highcharts.Series
  759. */
  760. var AOIndicator = /** @class */ (function (_super) {
  761. __extends(AOIndicator, _super);
  762. function AOIndicator() {
  763. var _this = _super !== null && _super.apply(this,
  764. arguments) || this;
  765. /**
  766. *
  767. * Properties
  768. *
  769. */
  770. _this.data = void 0;
  771. _this.options = void 0;
  772. _this.points = void 0;
  773. return _this;
  774. }
  775. /**
  776. *
  777. * Functions
  778. *
  779. */
  780. AOIndicator.prototype.drawGraph = function () {
  781. var indicator = this,
  782. options = indicator.options,
  783. points = indicator.points,
  784. userColor = indicator.userOptions.color,
  785. positiveColor = options.greaterBarColor,
  786. negativeColor = options.lowerBarColor,
  787. firstPoint = points[0],
  788. i;
  789. if (!userColor && firstPoint) {
  790. firstPoint.color = positiveColor;
  791. for (i = 1; i < points.length; i++) {
  792. if (points[i].y > points[i - 1].y) {
  793. points[i].color = positiveColor;
  794. }
  795. else if (points[i].y < points[i - 1].y) {
  796. points[i].color = negativeColor;
  797. }
  798. else {
  799. points[i].color = points[i - 1].color;
  800. }
  801. }
  802. }
  803. };
  804. AOIndicator.prototype.getValues = function (series) {
  805. var shortPeriod = 5,
  806. longPeriod = 34,
  807. xVal = series.xData || [],
  808. yVal = series.yData || [],
  809. yValLen = yVal.length,
  810. AO = [], // 0- date, 1- Awesome Oscillator
  811. xData = [],
  812. yData = [],
  813. high = 1,
  814. low = 2,
  815. shortSum = 0,
  816. longSum = 0,
  817. shortSMA, // Shorter Period SMA
  818. longSMA, // Longer Period SMA
  819. awesome,
  820. shortLastIndex,
  821. longLastIndex,
  822. price,
  823. i,
  824. j;
  825. if (xVal.length <= longPeriod ||
  826. !isArray(yVal[0]) ||
  827. yVal[0].length !== 4) {
  828. return;
  829. }
  830. for (i = 0; i < longPeriod - 1; i++) {
  831. price = (yVal[i][high] + yVal[i][low]) / 2;
  832. if (i >= longPeriod - shortPeriod) {
  833. shortSum = correctFloat(shortSum + price);
  834. }
  835. longSum = correctFloat(longSum + price);
  836. }
  837. for (j = longPeriod - 1; j < yValLen; j++) {
  838. price = (yVal[j][high] + yVal[j][low]) / 2;
  839. shortSum = correctFloat(shortSum + price);
  840. longSum = correctFloat(longSum + price);
  841. shortSMA = shortSum / shortPeriod;
  842. longSMA = longSum / longPeriod;
  843. awesome = correctFloat(shortSMA - longSMA);
  844. AO.push([xVal[j], awesome]);
  845. xData.push(xVal[j]);
  846. yData.push(awesome);
  847. shortLastIndex = j + 1 - shortPeriod;
  848. longLastIndex = j + 1 - longPeriod;
  849. shortSum = correctFloat(shortSum -
  850. (yVal[shortLastIndex][high] +
  851. yVal[shortLastIndex][low]) / 2);
  852. longSum = correctFloat(longSum -
  853. (yVal[longLastIndex][high] +
  854. yVal[longLastIndex][low]) / 2);
  855. }
  856. return {
  857. values: AO,
  858. xData: xData,
  859. yData: yData
  860. };
  861. };
  862. /**
  863. * Awesome Oscillator. This series requires the `linkedTo` option to
  864. * be set and should be loaded after the `stock/indicators/indicators.js`
  865. *
  866. * @sample {highstock} stock/indicators/ao
  867. * Awesome
  868. *
  869. * @extends plotOptions.sma
  870. * @since 7.0.0
  871. * @product highstock
  872. * @excluding allAreas, colorAxis, joinBy, keys, navigatorOptions,
  873. * params, pointInterval, pointIntervalUnit, pointPlacement,
  874. * pointRange, pointStart, showInNavigator, stacking
  875. * @requires stock/indicators/indicators
  876. * @requires stock/indicators/ao
  877. * @optionparent plotOptions.ao
  878. */
  879. AOIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  880. /**
  881. * Color of the Awesome oscillator series bar that is greater than the
  882. * previous one. Note that if a `color` is defined, the `color`
  883. * takes precedence and the `greaterBarColor` is ignored.
  884. *
  885. * @sample {highstock} stock/indicators/ao/
  886. * greaterBarColor
  887. *
  888. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  889. * @since 7.0.0
  890. */
  891. greaterBarColor: '#06B535',
  892. /**
  893. * Color of the Awesome oscillator series bar that is lower than the
  894. * previous one. Note that if a `color` is defined, the `color`
  895. * takes precedence and the `lowerBarColor` is ignored.
  896. *
  897. * @sample {highstock} stock/indicators/ao/
  898. * lowerBarColor
  899. *
  900. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  901. * @since 7.0.0
  902. */
  903. lowerBarColor: '#F21313',
  904. threshold: 0,
  905. groupPadding: 0.2,
  906. pointPadding: 0.2,
  907. crisp: false,
  908. states: {
  909. hover: {
  910. halo: {
  911. size: 0
  912. }
  913. }
  914. }
  915. });
  916. return AOIndicator;
  917. }(SMAIndicator));
  918. extend(AOIndicator.prototype, {
  919. nameBase: 'AO',
  920. nameComponents: false,
  921. // Columns support:
  922. markerAttribs: noop,
  923. getColumnMetrics: ColumnSeries.prototype.getColumnMetrics,
  924. crispCol: ColumnSeries.prototype.crispCol,
  925. translate: ColumnSeries.prototype.translate,
  926. drawPoints: ColumnSeries.prototype.drawPoints
  927. });
  928. SeriesRegistry.registerSeriesType('ao', AOIndicator);
  929. /* *
  930. *
  931. * Default Export
  932. *
  933. * */
  934. /**
  935. * An `AO` series. If the [type](#series.ao.type)
  936. * option is not specified, it is inherited from [chart.type](#chart.type).
  937. *
  938. * @extends series,plotOptions.ao
  939. * @since 7.0.0
  940. * @product highstock
  941. * @excluding allAreas, colorAxis, dataParser, dataURL, joinBy, keys,
  942. * navigatorOptions, pointInterval, pointIntervalUnit,
  943. * pointPlacement, pointRange, pointStart, showInNavigator, stacking
  944. * @requires stock/indicators/indicators
  945. * @requires stock/indicators/ao
  946. * @apioption series.ao
  947. */
  948. ''; // for including the above in the doclets
  949. return AOIndicator;
  950. });
  951. _registerModule(_modules, 'Mixins/MultipleLines.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  952. /**
  953. *
  954. * (c) 2010-2021 Wojciech Chmiel
  955. *
  956. * License: www.highcharts.com/license
  957. *
  958. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  959. *
  960. * */
  961. var defined = U.defined,
  962. error = U.error,
  963. merge = U.merge;
  964. var SMA = H.seriesTypes.sma;
  965. /**
  966. * Mixin useful for all indicators that have more than one line.
  967. * Merge it with your implementation where you will provide
  968. * getValues method appropriate to your indicator and pointArrayMap,
  969. * pointValKey, linesApiNames properites. Notice that pointArrayMap
  970. * should be consistent with amount of lines calculated in getValues method.
  971. *
  972. * @private
  973. * @mixin multipleLinesMixin
  974. */
  975. var multipleLinesMixin = {
  976. /* eslint-disable valid-jsdoc */
  977. /**
  978. * Lines ids. Required to plot appropriate amount of lines.
  979. * Notice that pointArrayMap should have more elements than
  980. * linesApiNames, because it contains main line and additional lines ids.
  981. * Also it should be consistent with amount of lines calculated in
  982. * getValues method from your implementation.
  983. *
  984. * @private
  985. * @name multipleLinesMixin.pointArrayMap
  986. * @type {Array<string>}
  987. */
  988. pointArrayMap: ['top', 'bottom'],
  989. /**
  990. * Main line id.
  991. *
  992. * @private
  993. * @name multipleLinesMixin.pointValKey
  994. * @type {string}
  995. */
  996. pointValKey: 'top',
  997. /**
  998. * Additional lines DOCS names. Elements of linesApiNames array should
  999. * be consistent with DOCS line names defined in your implementation.
  1000. * Notice that linesApiNames should have decreased amount of elements
  1001. * relative to pointArrayMap (without pointValKey).
  1002. *
  1003. * @private
  1004. * @name multipleLinesMixin.linesApiNames
  1005. * @type {Array<string>}
  1006. */
  1007. linesApiNames: ['bottomLine'],
  1008. /**
  1009. * Create translatedLines Collection based on pointArrayMap.
  1010. *
  1011. * @private
  1012. * @function multipleLinesMixin.getTranslatedLinesNames
  1013. * @param {string} [excludedValue]
  1014. * Main line id
  1015. * @return {Array<string>}
  1016. * Returns translated lines names without excluded value.
  1017. */
  1018. getTranslatedLinesNames: function (excludedValue) {
  1019. var translatedLines = [];
  1020. (this.pointArrayMap || []).forEach(function (propertyName) {
  1021. if (propertyName !== excludedValue) {
  1022. translatedLines.push('plot' +
  1023. propertyName.charAt(0).toUpperCase() +
  1024. propertyName.slice(1));
  1025. }
  1026. });
  1027. return translatedLines;
  1028. },
  1029. /**
  1030. * @private
  1031. * @function multipleLinesMixin.toYData
  1032. * @param {Highcharts.Point} point
  1033. * Indicator point
  1034. * @return {Array<number>}
  1035. * Returns point Y value for all lines
  1036. */
  1037. toYData: function (point) {
  1038. var pointColl = [];
  1039. (this.pointArrayMap || []).forEach(function (propertyName) {
  1040. pointColl.push(point[propertyName]);
  1041. });
  1042. return pointColl;
  1043. },
  1044. /**
  1045. * Add lines plot pixel values.
  1046. *
  1047. * @private
  1048. * @function multipleLinesMixin.translate
  1049. * @return {void}
  1050. */
  1051. translate: function () {
  1052. var indicator = this,
  1053. pointArrayMap = indicator.pointArrayMap,
  1054. LinesNames = [],
  1055. value;
  1056. LinesNames = indicator.getTranslatedLinesNames();
  1057. SMA.prototype.translate.apply(indicator, arguments);
  1058. indicator.points.forEach(function (point) {
  1059. pointArrayMap.forEach(function (propertyName, i) {
  1060. value = point[propertyName];
  1061. if (value !== null) {
  1062. point[LinesNames[i]] = indicator.yAxis.toPixels(value, true);
  1063. }
  1064. });
  1065. });
  1066. },
  1067. /**
  1068. * Draw main and additional lines.
  1069. *
  1070. * @private
  1071. * @function multipleLinesMixin.drawGraph
  1072. * @return {void}
  1073. */
  1074. drawGraph: function () {
  1075. var indicator = this,
  1076. pointValKey = indicator.pointValKey,
  1077. linesApiNames = indicator.linesApiNames,
  1078. mainLinePoints = indicator.points,
  1079. pointsLength = mainLinePoints.length,
  1080. mainLineOptions = indicator.options,
  1081. mainLinePath = indicator.graph,
  1082. gappedExtend = {
  1083. options: {
  1084. gapSize: mainLineOptions.gapSize
  1085. }
  1086. },
  1087. // additional lines point place holders:
  1088. secondaryLines = [],
  1089. secondaryLinesNames = indicator.getTranslatedLinesNames(pointValKey),
  1090. point;
  1091. // Generate points for additional lines:
  1092. secondaryLinesNames.forEach(function (plotLine, index) {
  1093. // create additional lines point place holders
  1094. secondaryLines[index] = [];
  1095. while (pointsLength--) {
  1096. point = mainLinePoints[pointsLength];
  1097. secondaryLines[index].push({
  1098. x: point.x,
  1099. plotX: point.plotX,
  1100. plotY: point[plotLine],
  1101. isNull: !defined(point[plotLine])
  1102. });
  1103. }
  1104. pointsLength = mainLinePoints.length;
  1105. });
  1106. // Modify options and generate additional lines:
  1107. linesApiNames.forEach(function (lineName, i) {
  1108. if (secondaryLines[i]) {
  1109. indicator.points = secondaryLines[i];
  1110. if (mainLineOptions[lineName]) {
  1111. indicator.options = merge(mainLineOptions[lineName].styles, gappedExtend);
  1112. }
  1113. else {
  1114. error('Error: "There is no ' + lineName +
  1115. ' in DOCS options declared. Check if linesApiNames' +
  1116. ' are consistent with your DOCS line names."' +
  1117. ' at mixin/multiple-line.js:34');
  1118. }
  1119. indicator.graph = indicator['graph' + lineName];
  1120. SMA.prototype.drawGraph.call(indicator);
  1121. // Now save lines:
  1122. indicator['graph' + lineName] = indicator.graph;
  1123. }
  1124. else {
  1125. error('Error: "' + lineName + ' doesn\'t have equivalent ' +
  1126. 'in pointArrayMap. To many elements in linesApiNames ' +
  1127. 'relative to pointArrayMap."');
  1128. }
  1129. });
  1130. // Restore options and draw a main line:
  1131. indicator.points = mainLinePoints;
  1132. indicator.options = mainLineOptions;
  1133. indicator.graph = mainLinePath;
  1134. SMA.prototype.drawGraph.call(indicator);
  1135. }
  1136. };
  1137. return multipleLinesMixin;
  1138. });
  1139. _registerModule(_modules, 'Stock/Indicators/Aroon/AroonIndicator.js', [_modules['Mixins/MultipleLines.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (MultipleLinesMixin, SeriesRegistry, U) {
  1140. /* *
  1141. *
  1142. * License: www.highcharts.com/license
  1143. *
  1144. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1145. *
  1146. * */
  1147. var __extends = (this && this.__extends) || (function () {
  1148. var extendStatics = function (d,
  1149. b) {
  1150. extendStatics = Object.setPrototypeOf ||
  1151. ({ __proto__: [] } instanceof Array && function (d,
  1152. b) { d.__proto__ = b; }) ||
  1153. function (d,
  1154. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1155. return extendStatics(d, b);
  1156. };
  1157. return function (d, b) {
  1158. extendStatics(d, b);
  1159. function __() { this.constructor = d; }
  1160. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1161. };
  1162. })();
  1163. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  1164. var extend = U.extend,
  1165. merge = U.merge,
  1166. pick = U.pick;
  1167. /* eslint-disable valid-jsdoc */
  1168. // Utils
  1169. // Index of element with extreme value from array (min or max)
  1170. /**
  1171. * @private
  1172. */
  1173. function getExtremeIndexInArray(arr, extreme) {
  1174. var extremeValue = arr[0],
  1175. valueIndex = 0,
  1176. i;
  1177. for (i = 1; i < arr.length; i++) {
  1178. if (extreme === 'max' && arr[i] >= extremeValue ||
  1179. extreme === 'min' && arr[i] <= extremeValue) {
  1180. extremeValue = arr[i];
  1181. valueIndex = i;
  1182. }
  1183. }
  1184. return valueIndex;
  1185. }
  1186. /* eslint-enable valid-jsdoc */
  1187. /* *
  1188. *
  1189. * Class
  1190. *
  1191. * */
  1192. /**
  1193. * The Aroon series type.
  1194. *
  1195. * @private
  1196. * @class
  1197. * @name Highcharts.seriesTypes.aroon
  1198. *
  1199. * @augments Highcharts.Series
  1200. */
  1201. var AroonIndicator = /** @class */ (function (_super) {
  1202. __extends(AroonIndicator, _super);
  1203. function AroonIndicator() {
  1204. var _this = _super !== null && _super.apply(this,
  1205. arguments) || this;
  1206. /* *
  1207. *
  1208. * Properties
  1209. *
  1210. * */
  1211. _this.data = void 0;
  1212. _this.options = void 0;
  1213. _this.points = void 0;
  1214. return _this;
  1215. }
  1216. /* *
  1217. *
  1218. * Functions
  1219. *
  1220. * */
  1221. AroonIndicator.prototype.getValues = function (series, params) {
  1222. var period = params.period,
  1223. xVal = series.xData,
  1224. yVal = series.yData,
  1225. yValLen = yVal ? yVal.length : 0,
  1226. // 0- date, 1- Aroon Up, 2- Aroon Down
  1227. AR = [],
  1228. xData = [],
  1229. yData = [],
  1230. slicedY,
  1231. low = 2,
  1232. high = 1,
  1233. aroonUp,
  1234. aroonDown,
  1235. xLow,
  1236. xHigh,
  1237. i;
  1238. // For a N-period, we start from N-1 point, to calculate Nth point
  1239. // That is why we later need to comprehend slice() elements list
  1240. // with (+1)
  1241. for (i = period - 1; i < yValLen; i++) {
  1242. slicedY = yVal.slice(i - period + 1, i + 2);
  1243. xLow = getExtremeIndexInArray(slicedY.map(function (elem) {
  1244. return pick(elem[low], elem);
  1245. }), 'min');
  1246. xHigh = getExtremeIndexInArray(slicedY.map(function (elem) {
  1247. return pick(elem[high], elem);
  1248. }), 'max');
  1249. aroonUp = (xHigh / period) * 100;
  1250. aroonDown = (xLow / period) * 100;
  1251. if (xVal[i + 1]) {
  1252. AR.push([xVal[i + 1], aroonUp, aroonDown]);
  1253. xData.push(xVal[i + 1]);
  1254. yData.push([aroonUp, aroonDown]);
  1255. }
  1256. }
  1257. return {
  1258. values: AR,
  1259. xData: xData,
  1260. yData: yData
  1261. };
  1262. };
  1263. /**
  1264. * Aroon. This series requires the `linkedTo` option to be
  1265. * set and should be loaded after the `stock/indicators/indicators.js`.
  1266. *
  1267. * @sample {highstock} stock/indicators/aroon
  1268. * Aroon
  1269. *
  1270. * @extends plotOptions.sma
  1271. * @since 7.0.0
  1272. * @product highstock
  1273. * @excluding allAreas, colorAxis, compare, compareBase, joinBy, keys,
  1274. * navigatorOptions, pointInterval, pointIntervalUnit,
  1275. * pointPlacement, pointRange, pointStart, showInNavigator,
  1276. * stacking
  1277. * @requires stock/indicators/indicators
  1278. * @requires stock/indicators/aroon
  1279. * @optionparent plotOptions.aroon
  1280. */
  1281. AroonIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  1282. /**
  1283. * Paramters used in calculation of aroon series points.
  1284. *
  1285. * @excluding periods, index
  1286. */
  1287. params: {
  1288. /**
  1289. * Period for Aroon indicator
  1290. */
  1291. period: 25
  1292. },
  1293. marker: {
  1294. enabled: false
  1295. },
  1296. tooltip: {
  1297. pointFormat: '<span style="color:{point.color}">\u25CF</span><b> {series.name}</b><br/>Aroon Up: {point.y}<br/>Aroon Down: {point.aroonDown}<br/>'
  1298. },
  1299. /**
  1300. * aroonDown line options.
  1301. */
  1302. aroonDown: {
  1303. /**
  1304. * Styles for an aroonDown line.
  1305. */
  1306. styles: {
  1307. /**
  1308. * Pixel width of the line.
  1309. */
  1310. lineWidth: 1,
  1311. /**
  1312. * Color of the line. If not set, it's inherited from
  1313. * [plotOptions.aroon.color](#plotOptions.aroon.color).
  1314. *
  1315. * @type {Highcharts.ColorString}
  1316. */
  1317. lineColor: void 0
  1318. }
  1319. },
  1320. dataGrouping: {
  1321. approximation: 'averages'
  1322. }
  1323. });
  1324. return AroonIndicator;
  1325. }(SMAIndicator));
  1326. extend(AroonIndicator.prototype, {
  1327. linesApiNames: ['aroonDown'],
  1328. nameBase: 'Aroon',
  1329. pointArrayMap: ['y', 'aroonDown'],
  1330. pointValKey: 'y',
  1331. drawGraph: MultipleLinesMixin.drawGraph,
  1332. getTranslatedLinesNames: MultipleLinesMixin.getTranslatedLinesNames,
  1333. toYData: MultipleLinesMixin.toYData,
  1334. translate: MultipleLinesMixin.translate
  1335. });
  1336. SeriesRegistry.registerSeriesType('aroon', AroonIndicator);
  1337. /* *
  1338. *
  1339. * Default Export
  1340. *
  1341. * */
  1342. /**
  1343. * A Aroon indicator. If the [type](#series.aroon.type) option is not
  1344. * specified, it is inherited from [chart.type](#chart.type).
  1345. *
  1346. * @extends series,plotOptions.aroon
  1347. * @since 7.0.0
  1348. * @product highstock
  1349. * @excluding allAreas, colorAxis, compare, compareBase, dataParser, dataURL,
  1350. * joinBy, keys, navigatorOptions, pointInterval, pointIntervalUnit,
  1351. * pointPlacement, pointRange, pointStart, showInNavigator, stacking
  1352. * @requires stock/indicators/indicators
  1353. * @requires stock/indicators/aroon
  1354. * @apioption series.aroon
  1355. */
  1356. ''; // to avoid removal of the above jsdoc
  1357. return AroonIndicator;
  1358. });
  1359. _registerModule(_modules, 'Stock/Indicators/AroonOscillator/AroonOscillatorIndicator.js', [_modules['Mixins/MultipleLines.js'], _modules['Mixins/IndicatorRequired.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (multipleLinesMixin, requiredIndicator, SeriesRegistry, U) {
  1360. /* *
  1361. *
  1362. * License: www.highcharts.com/license
  1363. *
  1364. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1365. *
  1366. * */
  1367. var __extends = (this && this.__extends) || (function () {
  1368. var extendStatics = function (d,
  1369. b) {
  1370. extendStatics = Object.setPrototypeOf ||
  1371. ({ __proto__: [] } instanceof Array && function (d,
  1372. b) { d.__proto__ = b; }) ||
  1373. function (d,
  1374. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1375. return extendStatics(d, b);
  1376. };
  1377. return function (d, b) {
  1378. extendStatics(d, b);
  1379. function __() { this.constructor = d; }
  1380. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1381. };
  1382. })();
  1383. var AroonIndicator = SeriesRegistry.seriesTypes.aroon;
  1384. var extend = U.extend,
  1385. merge = U.merge;
  1386. var AROON = SeriesRegistry.seriesTypes.aroon;
  1387. /* *
  1388. *
  1389. * Class
  1390. *
  1391. * */
  1392. /**
  1393. * The Aroon Oscillator series type.
  1394. *
  1395. * @private
  1396. * @class
  1397. * @name Highcharts.seriesTypes.aroonoscillator
  1398. *
  1399. * @augments Highcharts.Series
  1400. */
  1401. var AroonOscillatorIndicator = /** @class */ (function (_super) {
  1402. __extends(AroonOscillatorIndicator, _super);
  1403. function AroonOscillatorIndicator() {
  1404. var _this = _super !== null && _super.apply(this,
  1405. arguments) || this;
  1406. /* *
  1407. *
  1408. * Properties
  1409. *
  1410. * */
  1411. _this.data = void 0;
  1412. _this.options = void 0;
  1413. _this.points = void 0;
  1414. return _this;
  1415. }
  1416. /* *
  1417. *
  1418. * Functions
  1419. *
  1420. * */
  1421. AroonOscillatorIndicator.prototype.getValues = function (series, params) {
  1422. // 0- date, 1- Aroon Oscillator
  1423. var ARO = [],
  1424. xData = [],
  1425. yData = [],
  1426. aroon,
  1427. aroonUp,
  1428. aroonDown,
  1429. oscillator,
  1430. i;
  1431. aroon = AROON.prototype.getValues.call(this, series, params);
  1432. for (i = 0; i < aroon.yData.length; i++) {
  1433. aroonUp = aroon.yData[i][0];
  1434. aroonDown = aroon.yData[i][1];
  1435. oscillator = aroonUp - aroonDown;
  1436. ARO.push([aroon.xData[i], oscillator]);
  1437. xData.push(aroon.xData[i]);
  1438. yData.push(oscillator);
  1439. }
  1440. return {
  1441. values: ARO,
  1442. xData: xData,
  1443. yData: yData
  1444. };
  1445. };
  1446. AroonOscillatorIndicator.prototype.init = function () {
  1447. var args = arguments,
  1448. ctx = this;
  1449. requiredIndicator.isParentLoaded(AROON, 'aroon', ctx.type, function (indicator) {
  1450. indicator.prototype.init.apply(ctx, args);
  1451. return;
  1452. });
  1453. };
  1454. /**
  1455. * Aroon Oscillator. This series requires the `linkedTo` option to be set
  1456. * and should be loaded after the `stock/indicators/indicators.js` and
  1457. * `stock/indicators/aroon.js`.
  1458. *
  1459. * @sample {highstock} stock/indicators/aroon-oscillator
  1460. * Aroon Oscillator
  1461. *
  1462. * @extends plotOptions.aroon
  1463. * @since 7.0.0
  1464. * @product highstock
  1465. * @excluding allAreas, aroonDown, colorAxis, compare, compareBase,
  1466. * joinBy, keys, navigatorOptions, pointInterval,
  1467. * pointIntervalUnit, pointPlacement, pointRange, pointStart,
  1468. * showInNavigator, stacking
  1469. * @requires stock/indicators/indicators
  1470. * @requires stock/indicators/aroon
  1471. * @requires stock/indicators/aroon-oscillator
  1472. * @optionparent plotOptions.aroonoscillator
  1473. */
  1474. AroonOscillatorIndicator.defaultOptions = merge(AroonIndicator.defaultOptions, {
  1475. /**
  1476. * Paramters used in calculation of aroon oscillator series points.
  1477. *
  1478. * @excluding periods, index
  1479. */
  1480. params: {
  1481. /**
  1482. * Period for Aroon Oscillator
  1483. *
  1484. * @since 7.0.0
  1485. * @product highstock
  1486. */
  1487. period: 25
  1488. },
  1489. tooltip: {
  1490. pointFormat: '<span style="color:{point.color}">\u25CF</span><b> {series.name}</b>: {point.y}'
  1491. }
  1492. });
  1493. return AroonOscillatorIndicator;
  1494. }(AroonIndicator));
  1495. extend(AroonOscillatorIndicator.prototype, merge(multipleLinesMixin, {
  1496. nameBase: 'Aroon Oscillator',
  1497. pointArrayMap: ['y'],
  1498. pointValKey: 'y',
  1499. linesApiNames: []
  1500. }));
  1501. SeriesRegistry.registerSeriesType('aroonoscillator', AroonOscillatorIndicator);
  1502. /* *
  1503. *
  1504. * Default Export
  1505. *
  1506. * */
  1507. /**
  1508. * An `Aroon Oscillator` series. If the [type](#series.aroonoscillator.type)
  1509. * option is not specified, it is inherited from [chart.type](#chart.type).
  1510. *
  1511. * @extends series,plotOptions.aroonoscillator
  1512. * @since 7.0.0
  1513. * @product highstock
  1514. * @excluding allAreas, aroonDown, colorAxis, compare, compareBase, dataParser,
  1515. * dataURL, joinBy, keys, navigatorOptions, pointInterval,
  1516. * pointIntervalUnit, pointPlacement, pointRange, pointStart,
  1517. * showInNavigator, stacking
  1518. * @requires stock/indicators/indicators
  1519. * @requires stock/indicators/aroon
  1520. * @requires stock/indicators/aroon-oscillator
  1521. * @apioption series.aroonoscillator
  1522. */
  1523. ''; // adds doclet above to the transpiled file
  1524. return AroonOscillatorIndicator;
  1525. });
  1526. _registerModule(_modules, 'Stock/Indicators/ATR/ATRIndicator.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  1527. /* *
  1528. *
  1529. * License: www.highcharts.com/license
  1530. *
  1531. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1532. *
  1533. * */
  1534. var __extends = (this && this.__extends) || (function () {
  1535. var extendStatics = function (d,
  1536. b) {
  1537. extendStatics = Object.setPrototypeOf ||
  1538. ({ __proto__: [] } instanceof Array && function (d,
  1539. b) { d.__proto__ = b; }) ||
  1540. function (d,
  1541. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1542. return extendStatics(d, b);
  1543. };
  1544. return function (d, b) {
  1545. extendStatics(d, b);
  1546. function __() { this.constructor = d; }
  1547. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1548. };
  1549. })();
  1550. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  1551. var isArray = U.isArray,
  1552. merge = U.merge;
  1553. /* eslint-disable valid-jsdoc */
  1554. // Utils:
  1555. /**
  1556. * @private
  1557. */
  1558. function accumulateAverage(points, xVal, yVal, i) {
  1559. var xValue = xVal[i],
  1560. yValue = yVal[i];
  1561. points.push([xValue, yValue]);
  1562. }
  1563. /**
  1564. * @private
  1565. */
  1566. function getTR(currentPoint, prevPoint) {
  1567. var pointY = currentPoint, prevY = prevPoint, HL = pointY[1] - pointY[2], HCp = typeof prevY === 'undefined' ? 0 : Math.abs(pointY[1] - prevY[3]), LCp = typeof prevY === 'undefined' ? 0 : Math.abs(pointY[2] - prevY[3]), TR = Math.max(HL, HCp, LCp);
  1568. return TR;
  1569. }
  1570. /**
  1571. * @private
  1572. */
  1573. function populateAverage(points, xVal, yVal, i, period, prevATR) {
  1574. var x = xVal[i - 1],
  1575. TR = getTR(yVal[i - 1],
  1576. yVal[i - 2]),
  1577. y;
  1578. y = (((prevATR * (period - 1)) + TR) / period);
  1579. return [x, y];
  1580. }
  1581. /* eslint-enable valid-jsdoc */
  1582. /* *
  1583. *
  1584. * Class
  1585. *
  1586. * */
  1587. /**
  1588. * The ATR series type.
  1589. *
  1590. * @private
  1591. * @class
  1592. * @name Highcharts.seriesTypes.atr
  1593. *
  1594. * @augments Highcharts.Series
  1595. */
  1596. var ATRIndicator = /** @class */ (function (_super) {
  1597. __extends(ATRIndicator, _super);
  1598. function ATRIndicator() {
  1599. var _this = _super !== null && _super.apply(this,
  1600. arguments) || this;
  1601. /* *
  1602. *
  1603. * Properties
  1604. *
  1605. * */
  1606. _this.data = void 0;
  1607. _this.points = void 0;
  1608. _this.options = void 0;
  1609. return _this;
  1610. }
  1611. /* *
  1612. *
  1613. * Functions
  1614. *
  1615. * */
  1616. ATRIndicator.prototype.getValues = function (series, params) {
  1617. var period = params.period,
  1618. xVal = series.xData,
  1619. yVal = series.yData,
  1620. yValLen = yVal ? yVal.length : 0,
  1621. xValue = xVal[0],
  1622. yValue = yVal[0],
  1623. range = 1,
  1624. prevATR = 0,
  1625. TR = 0,
  1626. ATR = [],
  1627. xData = [],
  1628. yData = [],
  1629. point,
  1630. i,
  1631. points;
  1632. points = [[xValue, yValue]];
  1633. if ((xVal.length <= period) ||
  1634. !isArray(yVal[0]) ||
  1635. yVal[0].length !== 4) {
  1636. return;
  1637. }
  1638. for (i = 1; i <= yValLen; i++) {
  1639. accumulateAverage(points, xVal, yVal, i);
  1640. if (period < range) {
  1641. point = populateAverage(points, xVal, yVal, i, period, prevATR);
  1642. prevATR = point[1];
  1643. ATR.push(point);
  1644. xData.push(point[0]);
  1645. yData.push(point[1]);
  1646. }
  1647. else if (period === range) {
  1648. prevATR = TR / (i - 1);
  1649. ATR.push([xVal[i - 1], prevATR]);
  1650. xData.push(xVal[i - 1]);
  1651. yData.push(prevATR);
  1652. range++;
  1653. }
  1654. else {
  1655. TR += getTR(yVal[i - 1], yVal[i - 2]);
  1656. range++;
  1657. }
  1658. }
  1659. return {
  1660. values: ATR,
  1661. xData: xData,
  1662. yData: yData
  1663. };
  1664. };
  1665. /**
  1666. * Average true range indicator (ATR). This series requires `linkedTo`
  1667. * option to be set.
  1668. *
  1669. * @sample stock/indicators/atr
  1670. * ATR indicator
  1671. *
  1672. * @extends plotOptions.sma
  1673. * @since 6.0.0
  1674. * @product highstock
  1675. * @requires stock/indicators/indicators
  1676. * @requires stock/indicators/atr
  1677. * @optionparent plotOptions.atr
  1678. */
  1679. ATRIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  1680. params: {
  1681. period: 14
  1682. }
  1683. });
  1684. return ATRIndicator;
  1685. }(SMAIndicator));
  1686. SeriesRegistry.registerSeriesType('atr', ATRIndicator);
  1687. /* *
  1688. *
  1689. * Default Export
  1690. *
  1691. * */
  1692. /**
  1693. * A `ATR` series. If the [type](#series.atr.type) option is not specified, it
  1694. * is inherited from [chart.type](#chart.type).
  1695. *
  1696. * @extends series,plotOptions.atr
  1697. * @since 6.0.0
  1698. * @product highstock
  1699. * @excluding dataParser, dataURL
  1700. * @requires stock/indicators/indicators
  1701. * @requires stock/indicators/atr
  1702. * @apioption series.atr
  1703. */
  1704. ''; // to include the above in the js output
  1705. return ATRIndicator;
  1706. });
  1707. _registerModule(_modules, 'Stock/Indicators/BB/BBIndicator.js', [_modules['Mixins/MultipleLines.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (MultipleLinesMixin, SeriesRegistry, U) {
  1708. /**
  1709. *
  1710. * License: www.highcharts.com/license
  1711. *
  1712. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1713. *
  1714. * */
  1715. var __extends = (this && this.__extends) || (function () {
  1716. var extendStatics = function (d,
  1717. b) {
  1718. extendStatics = Object.setPrototypeOf ||
  1719. ({ __proto__: [] } instanceof Array && function (d,
  1720. b) { d.__proto__ = b; }) ||
  1721. function (d,
  1722. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1723. return extendStatics(d, b);
  1724. };
  1725. return function (d, b) {
  1726. extendStatics(d, b);
  1727. function __() { this.constructor = d; }
  1728. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1729. };
  1730. })();
  1731. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  1732. var extend = U.extend,
  1733. isArray = U.isArray,
  1734. merge = U.merge;
  1735. /* eslint-disable valid-jsdoc */
  1736. // Utils:
  1737. /**
  1738. * @private
  1739. */
  1740. function getStandardDeviation(arr, index, isOHLC, mean) {
  1741. var variance = 0,
  1742. arrLen = arr.length,
  1743. std = 0,
  1744. i = 0,
  1745. value;
  1746. for (; i < arrLen; i++) {
  1747. value = (isOHLC ? arr[i][index] : arr[i]) - mean;
  1748. variance += value * value;
  1749. }
  1750. variance = variance / (arrLen - 1);
  1751. std = Math.sqrt(variance);
  1752. return std;
  1753. }
  1754. /* eslint-enable valid-jsdoc */
  1755. /**
  1756. * Bollinger Bands series type.
  1757. *
  1758. * @private
  1759. * @class
  1760. * @name Highcharts.seriesTypes.bb
  1761. *
  1762. * @augments Highcharts.Series
  1763. */
  1764. var BBIndicator = /** @class */ (function (_super) {
  1765. __extends(BBIndicator, _super);
  1766. function BBIndicator() {
  1767. var _this = _super !== null && _super.apply(this,
  1768. arguments) || this;
  1769. /* *
  1770. *
  1771. * Prototype Properties
  1772. *
  1773. * */
  1774. _this.data = void 0;
  1775. _this.options = void 0;
  1776. _this.points = void 0;
  1777. return _this;
  1778. }
  1779. BBIndicator.prototype.init = function () {
  1780. SeriesRegistry.seriesTypes.sma.prototype.init.apply(this, arguments);
  1781. // Set default color for lines:
  1782. this.options = merge({
  1783. topLine: {
  1784. styles: {
  1785. lineColor: this.color
  1786. }
  1787. },
  1788. bottomLine: {
  1789. styles: {
  1790. lineColor: this.color
  1791. }
  1792. }
  1793. }, this.options);
  1794. };
  1795. BBIndicator.prototype.getValues = function (series, params) {
  1796. var period = params.period,
  1797. standardDeviation = params.standardDeviation,
  1798. xVal = series.xData,
  1799. yVal = series.yData,
  1800. yValLen = yVal ? yVal.length : 0,
  1801. // 0- date, 1-middle line, 2-top line, 3-bottom line
  1802. BB = [],
  1803. // middle line, top line and bottom line
  1804. ML,
  1805. TL,
  1806. BL,
  1807. date,
  1808. xData = [],
  1809. yData = [],
  1810. slicedX,
  1811. slicedY,
  1812. stdDev,
  1813. isOHLC,
  1814. point,
  1815. i;
  1816. if (xVal.length < period) {
  1817. return;
  1818. }
  1819. isOHLC = isArray(yVal[0]);
  1820. for (i = period; i <= yValLen; i++) {
  1821. slicedX = xVal.slice(i - period, i);
  1822. slicedY = yVal.slice(i - period, i);
  1823. point = SeriesRegistry.seriesTypes.sma.prototype.getValues.call(this, {
  1824. xData: slicedX,
  1825. yData: slicedY
  1826. }, params);
  1827. date = point.xData[0];
  1828. ML = point.yData[0];
  1829. stdDev = getStandardDeviation(slicedY, params.index, isOHLC, ML);
  1830. TL = ML + standardDeviation * stdDev;
  1831. BL = ML - standardDeviation * stdDev;
  1832. BB.push([date, TL, ML, BL]);
  1833. xData.push(date);
  1834. yData.push([TL, ML, BL]);
  1835. }
  1836. return {
  1837. values: BB,
  1838. xData: xData,
  1839. yData: yData
  1840. };
  1841. };
  1842. /**
  1843. * Bollinger bands (BB). This series requires the `linkedTo` option to be
  1844. * set and should be loaded after the `stock/indicators/indicators.js` file.
  1845. *
  1846. * @sample stock/indicators/bollinger-bands
  1847. * Bollinger bands
  1848. *
  1849. * @extends plotOptions.sma
  1850. * @since 6.0.0
  1851. * @product highstock
  1852. * @requires stock/indicators/indicators
  1853. * @requires stock/indicators/bollinger-bands
  1854. * @optionparent plotOptions.bb
  1855. */
  1856. BBIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  1857. params: {
  1858. period: 20,
  1859. /**
  1860. * Standard deviation for top and bottom bands.
  1861. */
  1862. standardDeviation: 2,
  1863. index: 3
  1864. },
  1865. /**
  1866. * Bottom line options.
  1867. */
  1868. bottomLine: {
  1869. /**
  1870. * Styles for a bottom line.
  1871. */
  1872. styles: {
  1873. /**
  1874. * Pixel width of the line.
  1875. */
  1876. lineWidth: 1,
  1877. /**
  1878. * Color of the line. If not set, it's inherited from
  1879. * [plotOptions.bb.color](#plotOptions.bb.color).
  1880. *
  1881. * @type {Highcharts.ColorString}
  1882. */
  1883. lineColor: void 0
  1884. }
  1885. },
  1886. /**
  1887. * Top line options.
  1888. *
  1889. * @extends plotOptions.bb.bottomLine
  1890. */
  1891. topLine: {
  1892. styles: {
  1893. lineWidth: 1,
  1894. /**
  1895. * @type {Highcharts.ColorString}
  1896. */
  1897. lineColor: void 0
  1898. }
  1899. },
  1900. tooltip: {
  1901. pointFormat: '<span style="color:{point.color}">\u25CF</span><b> {series.name}</b><br/>Top: {point.top}<br/>Middle: {point.middle}<br/>Bottom: {point.bottom}<br/>'
  1902. },
  1903. marker: {
  1904. enabled: false
  1905. },
  1906. dataGrouping: {
  1907. approximation: 'averages'
  1908. }
  1909. });
  1910. return BBIndicator;
  1911. }(SMAIndicator));
  1912. extend(BBIndicator.prototype, {
  1913. pointArrayMap: ['top', 'middle', 'bottom'],
  1914. pointValKey: 'middle',
  1915. nameComponents: ['period', 'standardDeviation'],
  1916. linesApiNames: ['topLine', 'bottomLine'],
  1917. drawGraph: MultipleLinesMixin.drawGraph,
  1918. getTranslatedLinesNames: MultipleLinesMixin.getTranslatedLinesNames,
  1919. translate: MultipleLinesMixin.translate,
  1920. toYData: MultipleLinesMixin.toYData
  1921. });
  1922. SeriesRegistry.registerSeriesType('bb', BBIndicator);
  1923. /* *
  1924. *
  1925. * Default Export
  1926. *
  1927. * */
  1928. /**
  1929. * A bollinger bands indicator. If the [type](#series.bb.type) option is not
  1930. * specified, it is inherited from [chart.type](#chart.type).
  1931. *
  1932. * @extends series,plotOptions.bb
  1933. * @since 6.0.0
  1934. * @excluding dataParser, dataURL
  1935. * @product highstock
  1936. * @requires stock/indicators/indicators
  1937. * @requires stock/indicators/bollinger-bands
  1938. * @apioption series.bb
  1939. */
  1940. ''; // to include the above in the js output
  1941. return BBIndicator;
  1942. });
  1943. _registerModule(_modules, 'Stock/Indicators/CCI/CCIIndicator.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  1944. /* *
  1945. *
  1946. * License: www.highcharts.com/license
  1947. *
  1948. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  1949. * */
  1950. var __extends = (this && this.__extends) || (function () {
  1951. var extendStatics = function (d,
  1952. b) {
  1953. extendStatics = Object.setPrototypeOf ||
  1954. ({ __proto__: [] } instanceof Array && function (d,
  1955. b) { d.__proto__ = b; }) ||
  1956. function (d,
  1957. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  1958. return extendStatics(d, b);
  1959. };
  1960. return function (d, b) {
  1961. extendStatics(d, b);
  1962. function __() { this.constructor = d; }
  1963. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  1964. };
  1965. })();
  1966. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  1967. var isArray = U.isArray,
  1968. merge = U.merge;
  1969. /* eslint-disable valid-jsdoc */
  1970. // Utils:
  1971. /**
  1972. * @private
  1973. */
  1974. function sumArray(array) {
  1975. return array.reduce(function (prev, cur) {
  1976. return prev + cur;
  1977. }, 0);
  1978. }
  1979. /**
  1980. * @private
  1981. */
  1982. function meanDeviation(arr, sma) {
  1983. var len = arr.length,
  1984. sum = 0,
  1985. i;
  1986. for (i = 0; i < len; i++) {
  1987. sum += Math.abs(sma - (arr[i]));
  1988. }
  1989. return sum;
  1990. }
  1991. /* eslint-enable valid-jsdoc */
  1992. /* *
  1993. *
  1994. * Class
  1995. *
  1996. * */
  1997. /**
  1998. * The CCI series type.
  1999. *
  2000. * @private
  2001. * @class
  2002. * @name Highcharts.seriesTypes.cci
  2003. *
  2004. * @augments Highcharts.Series
  2005. */
  2006. var CCIIndicator = /** @class */ (function (_super) {
  2007. __extends(CCIIndicator, _super);
  2008. function CCIIndicator() {
  2009. var _this = _super !== null && _super.apply(this,
  2010. arguments) || this;
  2011. /* *
  2012. *
  2013. * Properties
  2014. *
  2015. * */
  2016. _this.data = void 0;
  2017. _this.points = void 0;
  2018. _this.options = void 0;
  2019. return _this;
  2020. }
  2021. /* *
  2022. *
  2023. * Functions
  2024. *
  2025. * */
  2026. CCIIndicator.prototype.getValues = function (series, params) {
  2027. var period = params.period,
  2028. xVal = series.xData,
  2029. yVal = series.yData,
  2030. yValLen = yVal ? yVal.length : 0,
  2031. TP = [],
  2032. periodTP = [],
  2033. range = 1,
  2034. CCI = [],
  2035. xData = [],
  2036. yData = [],
  2037. CCIPoint,
  2038. p,
  2039. len,
  2040. smaTP,
  2041. TPtemp,
  2042. meanDev,
  2043. i;
  2044. // CCI requires close value
  2045. if (xVal.length <= period ||
  2046. !isArray(yVal[0]) ||
  2047. yVal[0].length !== 4) {
  2048. return;
  2049. }
  2050. // accumulate first N-points
  2051. while (range < period) {
  2052. p = yVal[range - 1];
  2053. TP.push((p[1] + p[2] + p[3]) / 3);
  2054. range++;
  2055. }
  2056. for (i = period; i <= yValLen; i++) {
  2057. p = yVal[i - 1];
  2058. TPtemp = (p[1] + p[2] + p[3]) / 3;
  2059. len = TP.push(TPtemp);
  2060. periodTP = TP.slice(len - period);
  2061. smaTP = sumArray(periodTP) / period;
  2062. meanDev = meanDeviation(periodTP, smaTP) / period;
  2063. CCIPoint = ((TPtemp - smaTP) / (0.015 * meanDev));
  2064. CCI.push([xVal[i - 1], CCIPoint]);
  2065. xData.push(xVal[i - 1]);
  2066. yData.push(CCIPoint);
  2067. }
  2068. return {
  2069. values: CCI,
  2070. xData: xData,
  2071. yData: yData
  2072. };
  2073. };
  2074. /**
  2075. * Commodity Channel Index (CCI). This series requires `linkedTo` option to
  2076. * be set.
  2077. *
  2078. * @sample stock/indicators/cci
  2079. * CCI indicator
  2080. *
  2081. * @extends plotOptions.sma
  2082. * @since 6.0.0
  2083. * @product highstock
  2084. * @requires stock/indicators/indicators
  2085. * @requires stock/indicators/cci
  2086. * @optionparent plotOptions.cci
  2087. */
  2088. CCIIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  2089. params: {
  2090. period: 14
  2091. }
  2092. });
  2093. return CCIIndicator;
  2094. }(SMAIndicator));
  2095. SeriesRegistry.registerSeriesType('cci', CCIIndicator);
  2096. /* *
  2097. *
  2098. * Default Export
  2099. *
  2100. * */
  2101. /**
  2102. * A `CCI` series. If the [type](#series.cci.type) option is not
  2103. * specified, it is inherited from [chart.type](#chart.type).
  2104. *
  2105. * @extends series,plotOptions.cci
  2106. * @since 6.0.0
  2107. * @excluding dataParser, dataURL
  2108. * @product highstock
  2109. * @requires stock/indicators/indicators
  2110. * @requires stock/indicators/cci
  2111. * @apioption series.cci
  2112. */
  2113. ''; // to include the above in the js output
  2114. return CCIIndicator;
  2115. });
  2116. _registerModule(_modules, 'Stock/Indicators/CMF/CMFIndicator.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  2117. /* *
  2118. *
  2119. * (c) 2010-2021 Highsoft AS
  2120. *
  2121. * Author: Sebastian Domas
  2122. *
  2123. * Chaikin Money Flow indicator for Highstock
  2124. *
  2125. * License: www.highcharts.com/license
  2126. *
  2127. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2128. *
  2129. * */
  2130. var __extends = (this && this.__extends) || (function () {
  2131. var extendStatics = function (d,
  2132. b) {
  2133. extendStatics = Object.setPrototypeOf ||
  2134. ({ __proto__: [] } instanceof Array && function (d,
  2135. b) { d.__proto__ = b; }) ||
  2136. function (d,
  2137. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2138. return extendStatics(d, b);
  2139. };
  2140. return function (d, b) {
  2141. extendStatics(d, b);
  2142. function __() { this.constructor = d; }
  2143. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2144. };
  2145. })();
  2146. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  2147. var merge = U.merge;
  2148. /**
  2149. * The CMF series type.
  2150. *
  2151. * @private
  2152. * @class
  2153. * @name Highcharts.seriesTypes.cmf
  2154. *
  2155. * @augments Highcharts.Series
  2156. */
  2157. var CMFIndicator = /** @class */ (function (_super) {
  2158. __extends(CMFIndicator, _super);
  2159. function CMFIndicator() {
  2160. var _this = _super !== null && _super.apply(this,
  2161. arguments) || this;
  2162. /* *
  2163. *
  2164. * Properties
  2165. *
  2166. * */
  2167. _this.data = void 0;
  2168. _this.options = void 0;
  2169. _this.points = void 0;
  2170. _this.volumeSeries = void 0;
  2171. _this.linkedParent = void 0;
  2172. _this.yData = void 0;
  2173. _this.nameBase = 'Chaikin Money Flow';
  2174. return _this;
  2175. }
  2176. /**
  2177. * Checks if the series and volumeSeries are accessible, number of
  2178. * points.x is longer than period, is series has OHLC data
  2179. * @private
  2180. * @param {Highcharts.CMFIndicator} this indicator to use.
  2181. * @return {boolean} True if series is valid and can be computed,
  2182. * otherwise false.
  2183. */
  2184. CMFIndicator.prototype.isValid = function () {
  2185. var chart = this.chart,
  2186. options = this.options,
  2187. series = this.linkedParent,
  2188. volumeSeries = (this.volumeSeries ||
  2189. (this.volumeSeries =
  2190. chart.get(options.params.volumeSeriesID))),
  2191. isSeriesOHLC = (series &&
  2192. series.yData &&
  2193. series.yData[0].length === 4);
  2194. /**
  2195. * @private
  2196. * @param {Highcharts.Series} serie to check length validity on.
  2197. * @return {boolean|undefined} true if length is valid.
  2198. */
  2199. function isLengthValid(serie) {
  2200. return serie.xData &&
  2201. serie.xData.length >= options.params.period;
  2202. }
  2203. return !!(series &&
  2204. volumeSeries &&
  2205. isLengthValid(series) &&
  2206. isLengthValid(volumeSeries) && isSeriesOHLC);
  2207. };
  2208. /**
  2209. * Returns indicator's data.
  2210. * @private
  2211. * @param {Highcharts.CMFIndicator} this indicator to use.
  2212. * @param {Highcharts.Series} series to calculate values from
  2213. * @param {Highcharts.CMFIndicatorParamsOptions} params to pass
  2214. * @return {boolean|Highcharts.IndicatorNullableValuesObject} Returns false if the
  2215. * indicator is not valid, otherwise returns Values object.
  2216. */
  2217. CMFIndicator.prototype.getValues = function (series, params) {
  2218. if (!this.isValid()) {
  2219. return;
  2220. }
  2221. return this.getMoneyFlow(series.xData, series.yData, this.volumeSeries.yData, params.period);
  2222. };
  2223. /**
  2224. * @private
  2225. * @param {Array<number>} xData - x timestamp values
  2226. * @param {Array<number>} seriesYData - yData of basic series
  2227. * @param {Array<number>} volumeSeriesYData - yData of volume series
  2228. * @param {number} period - indicator's param
  2229. * @return {Highcharts.IndicatorNullableValuesObject} object containing computed money
  2230. * flow data
  2231. */
  2232. CMFIndicator.prototype.getMoneyFlow = function (xData, seriesYData, volumeSeriesYData, period) {
  2233. var len = seriesYData.length,
  2234. moneyFlowVolume = [],
  2235. sumVolume = 0,
  2236. sumMoneyFlowVolume = 0,
  2237. moneyFlowXData = [],
  2238. moneyFlowYData = [],
  2239. values = [],
  2240. i,
  2241. point,
  2242. nullIndex = -1;
  2243. /**
  2244. * Calculates money flow volume, changes i, nullIndex vars from
  2245. * upper scope!
  2246. * @private
  2247. * @param {Array<number>} ohlc - OHLC point
  2248. * @param {number} volume - Volume point's y value
  2249. * @return {number|null} - volume * moneyFlowMultiplier
  2250. **/
  2251. function getMoneyFlowVolume(ohlc, volume) {
  2252. var high = ohlc[1],
  2253. low = ohlc[2],
  2254. close = ohlc[3],
  2255. isValid = volume !== null &&
  2256. high !== null &&
  2257. low !== null &&
  2258. close !== null &&
  2259. high !== low;
  2260. /**
  2261. * @private
  2262. * @param {number} h - High value
  2263. * @param {number} l - Low value
  2264. * @param {number} c - Close value
  2265. * @return {number} calculated multiplier for the point
  2266. **/
  2267. function getMoneyFlowMultiplier(h, l, c) {
  2268. return ((c - l) - (h - c)) / (h - l);
  2269. }
  2270. return isValid ?
  2271. getMoneyFlowMultiplier(high, low, close) * volume :
  2272. ((nullIndex = i), null);
  2273. }
  2274. if (period > 0 && period <= len) {
  2275. for (i = 0; i < period; i++) {
  2276. moneyFlowVolume[i] = getMoneyFlowVolume(seriesYData[i], volumeSeriesYData[i]);
  2277. sumVolume += volumeSeriesYData[i];
  2278. sumMoneyFlowVolume += moneyFlowVolume[i];
  2279. }
  2280. moneyFlowXData.push(xData[i - 1]);
  2281. moneyFlowYData.push(i - nullIndex >= period && sumVolume !== 0 ?
  2282. sumMoneyFlowVolume / sumVolume :
  2283. null);
  2284. values.push([moneyFlowXData[0], moneyFlowYData[0]]);
  2285. for (; i < len; i++) {
  2286. moneyFlowVolume[i] = getMoneyFlowVolume(seriesYData[i], volumeSeriesYData[i]);
  2287. sumVolume -= volumeSeriesYData[i - period];
  2288. sumVolume += volumeSeriesYData[i];
  2289. sumMoneyFlowVolume -= moneyFlowVolume[i - period];
  2290. sumMoneyFlowVolume += moneyFlowVolume[i];
  2291. point = [
  2292. xData[i],
  2293. i - nullIndex >= period ?
  2294. sumMoneyFlowVolume / sumVolume :
  2295. null
  2296. ];
  2297. moneyFlowXData.push(point[0]);
  2298. moneyFlowYData.push(point[1]);
  2299. values.push([point[0], point[1]]);
  2300. }
  2301. }
  2302. return {
  2303. values: values,
  2304. xData: moneyFlowXData,
  2305. yData: moneyFlowYData
  2306. };
  2307. };
  2308. /**
  2309. * Chaikin Money Flow indicator (cmf).
  2310. *
  2311. * @sample stock/indicators/cmf/
  2312. * Chaikin Money Flow indicator
  2313. *
  2314. * @extends plotOptions.sma
  2315. * @since 6.0.0
  2316. * @excluding animationLimit
  2317. * @product highstock
  2318. * @requires stock/indicators/indicators
  2319. * @requires stock/indicators/cmf
  2320. * @optionparent plotOptions.cmf
  2321. */
  2322. CMFIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  2323. params: {
  2324. period: 14,
  2325. /**
  2326. * The id of another series to use its data as volume data for the
  2327. * indiator calculation.
  2328. */
  2329. volumeSeriesID: 'volume'
  2330. }
  2331. });
  2332. return CMFIndicator;
  2333. }(SMAIndicator));
  2334. SeriesRegistry.registerSeriesType('cmf', CMFIndicator);
  2335. /* *
  2336. *
  2337. * Default Export
  2338. *
  2339. * */
  2340. /**
  2341. * A `CMF` series. If the [type](#series.cmf.type) option is not
  2342. * specified, it is inherited from [chart.type](#chart.type).
  2343. *
  2344. * @extends series,plotOptions.cmf
  2345. * @since 6.0.0
  2346. * @product highstock
  2347. * @excluding dataParser, dataURL
  2348. * @requires stock/indicators/indicators
  2349. * @requires stock/indicators/cmf
  2350. * @apioption series.cmf
  2351. */
  2352. ''; // adds doclet above to the transpiled file
  2353. return CMFIndicator;
  2354. });
  2355. _registerModule(_modules, 'Stock/Indicators/DPO/DPOIndicator.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  2356. /* *
  2357. *
  2358. * License: www.highcharts.com/license
  2359. *
  2360. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2361. *
  2362. * */
  2363. var __extends = (this && this.__extends) || (function () {
  2364. var extendStatics = function (d,
  2365. b) {
  2366. extendStatics = Object.setPrototypeOf ||
  2367. ({ __proto__: [] } instanceof Array && function (d,
  2368. b) { d.__proto__ = b; }) ||
  2369. function (d,
  2370. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2371. return extendStatics(d, b);
  2372. };
  2373. return function (d, b) {
  2374. extendStatics(d, b);
  2375. function __() { this.constructor = d; }
  2376. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2377. };
  2378. })();
  2379. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  2380. var extend = U.extend,
  2381. merge = U.merge,
  2382. correctFloat = U.correctFloat,
  2383. pick = U.pick;
  2384. /* eslint-disable valid-jsdoc */
  2385. // Utils:
  2386. /**
  2387. * @private
  2388. */
  2389. function accumulatePoints(sum, yVal, i, index, subtract) {
  2390. var price = pick(yVal[i][index],
  2391. yVal[i]);
  2392. if (subtract) {
  2393. return correctFloat(sum - price);
  2394. }
  2395. return correctFloat(sum + price);
  2396. }
  2397. /* *
  2398. *
  2399. * Class
  2400. *
  2401. * */
  2402. /**
  2403. * The DPO series type.
  2404. *
  2405. * @private
  2406. * @class
  2407. * @name Highcharts.seriesTypes.dpo
  2408. *
  2409. * @augments Highcharts.Series
  2410. */
  2411. var DPOIndicator = /** @class */ (function (_super) {
  2412. __extends(DPOIndicator, _super);
  2413. function DPOIndicator() {
  2414. var _this = _super !== null && _super.apply(this,
  2415. arguments) || this;
  2416. /* *
  2417. *
  2418. * Properties
  2419. *
  2420. * */
  2421. _this.options = void 0;
  2422. _this.data = void 0;
  2423. _this.points = void 0;
  2424. return _this;
  2425. }
  2426. /* *
  2427. *
  2428. * Functions
  2429. *
  2430. * */
  2431. /**
  2432. * @lends Highcharts.Series#
  2433. */
  2434. DPOIndicator.prototype.getValues = function (series, params) {
  2435. var period = params.period,
  2436. index = params.index,
  2437. offset = Math.floor(period / 2 + 1),
  2438. range = period + offset,
  2439. xVal = series.xData || [],
  2440. yVal = series.yData || [],
  2441. yValLen = yVal.length,
  2442. // 0- date, 1- Detrended Price Oscillator
  2443. DPO = [],
  2444. xData = [],
  2445. yData = [],
  2446. sum = 0,
  2447. oscillator,
  2448. periodIndex,
  2449. rangeIndex,
  2450. price,
  2451. i,
  2452. j;
  2453. if (xVal.length <= range) {
  2454. return;
  2455. }
  2456. // Accumulate first N-points for SMA
  2457. for (i = 0; i < period - 1; i++) {
  2458. sum = accumulatePoints(sum, yVal, i, index);
  2459. }
  2460. // Detrended Price Oscillator formula:
  2461. // DPO = Price - Simple moving average [from (n / 2 + 1) days ago]
  2462. for (j = 0; j <= yValLen - range; j++) {
  2463. periodIndex = j + period - 1;
  2464. rangeIndex = j + range - 1;
  2465. // adding the last period point
  2466. sum = accumulatePoints(sum, yVal, periodIndex, index);
  2467. price = pick(yVal[rangeIndex][index], yVal[rangeIndex]);
  2468. oscillator = price - sum / period;
  2469. // substracting the first period point
  2470. sum = accumulatePoints(sum, yVal, j, index, true);
  2471. DPO.push([xVal[rangeIndex], oscillator]);
  2472. xData.push(xVal[rangeIndex]);
  2473. yData.push(oscillator);
  2474. }
  2475. return {
  2476. values: DPO,
  2477. xData: xData,
  2478. yData: yData
  2479. };
  2480. };
  2481. /**
  2482. * Detrended Price Oscillator. This series requires the `linkedTo` option to
  2483. * be set and should be loaded after the `stock/indicators/indicators.js`.
  2484. *
  2485. * @sample {highstock} stock/indicators/dpo
  2486. * Detrended Price Oscillator
  2487. *
  2488. * @extends plotOptions.sma
  2489. * @since 7.0.0
  2490. * @product highstock
  2491. * @excluding allAreas, colorAxis, compare, compareBase, joinBy, keys,
  2492. * navigatorOptions, pointInterval, pointIntervalUnit,
  2493. * pointPlacement, pointRange, pointStart, showInNavigator,
  2494. * stacking
  2495. * @requires stock/indicators/indicators
  2496. * @requires stock/indicators/dpo
  2497. * @optionparent plotOptions.dpo
  2498. */
  2499. DPOIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  2500. /**
  2501. * Parameters used in calculation of Detrended Price Oscillator series
  2502. * points.
  2503. */
  2504. params: {
  2505. /**
  2506. * Period for Detrended Price Oscillator
  2507. */
  2508. period: 21
  2509. }
  2510. });
  2511. return DPOIndicator;
  2512. }(SMAIndicator));
  2513. extend(DPOIndicator.prototype, {
  2514. nameBase: 'DPO'
  2515. });
  2516. SeriesRegistry.registerSeriesType('dpo', DPOIndicator);
  2517. /* *
  2518. *
  2519. * Default Export
  2520. *
  2521. * */
  2522. /**
  2523. * A Detrended Price Oscillator. If the [type](#series.dpo.type) option is not
  2524. * specified, it is inherited from [chart.type](#chart.type).
  2525. *
  2526. * @extends series,plotOptions.dpo
  2527. * @since 7.0.0
  2528. * @product highstock
  2529. * @excluding allAreas, colorAxis, compare, compareBase, dataParser, dataURL,
  2530. * joinBy, keys, navigatorOptions, pointInterval, pointIntervalUnit,
  2531. * pointPlacement, pointRange, pointStart, showInNavigator, stacking
  2532. * @requires stock/indicators/indicators
  2533. * @requires stock/indicators/dpo
  2534. * @apioption series.dpo
  2535. */
  2536. ''; // to include the above in the js output'
  2537. return DPOIndicator;
  2538. });
  2539. _registerModule(_modules, 'Stock/Indicators/EMA/EMAIndicator.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  2540. /* *
  2541. *
  2542. * License: www.highcharts.com/license
  2543. *
  2544. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2545. *
  2546. * */
  2547. var __extends = (this && this.__extends) || (function () {
  2548. var extendStatics = function (d,
  2549. b) {
  2550. extendStatics = Object.setPrototypeOf ||
  2551. ({ __proto__: [] } instanceof Array && function (d,
  2552. b) { d.__proto__ = b; }) ||
  2553. function (d,
  2554. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2555. return extendStatics(d, b);
  2556. };
  2557. return function (d, b) {
  2558. extendStatics(d, b);
  2559. function __() { this.constructor = d; }
  2560. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2561. };
  2562. })();
  2563. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  2564. var correctFloat = U.correctFloat,
  2565. isArray = U.isArray,
  2566. merge = U.merge;
  2567. /* *
  2568. *
  2569. * Class
  2570. *
  2571. * */
  2572. /**
  2573. * The EMA series type.
  2574. *
  2575. * @private
  2576. * @class
  2577. * @name Highcharts.seriesTypes.ema
  2578. *
  2579. * @augments Highcharts.Series
  2580. */
  2581. var EMAIndicator = /** @class */ (function (_super) {
  2582. __extends(EMAIndicator, _super);
  2583. function EMAIndicator() {
  2584. var _this = _super !== null && _super.apply(this,
  2585. arguments) || this;
  2586. /* *
  2587. *
  2588. * Properties
  2589. *
  2590. * */
  2591. _this.data = void 0;
  2592. _this.options = void 0;
  2593. _this.points = void 0;
  2594. return _this;
  2595. }
  2596. /* *
  2597. *
  2598. * Functions
  2599. *
  2600. * */
  2601. EMAIndicator.prototype.accumulatePeriodPoints = function (period, index, yVal) {
  2602. var sum = 0,
  2603. i = 0,
  2604. y = 0;
  2605. while (i < period) {
  2606. y = index < 0 ? yVal[i] : yVal[i][index];
  2607. sum = sum + y;
  2608. i++;
  2609. }
  2610. return sum;
  2611. };
  2612. EMAIndicator.prototype.calculateEma = function (xVal, yVal, i, EMApercent, calEMA, index, SMA) {
  2613. var x = xVal[i - 1],
  2614. yValue = index < 0 ?
  2615. yVal[i - 1] :
  2616. yVal[i - 1][index],
  2617. y;
  2618. y = typeof calEMA === 'undefined' ?
  2619. SMA : correctFloat((yValue * EMApercent) +
  2620. (calEMA * (1 - EMApercent)));
  2621. return [x, y];
  2622. };
  2623. EMAIndicator.prototype.getValues = function (series, params) {
  2624. var period = params.period,
  2625. xVal = series.xData,
  2626. yVal = series.yData,
  2627. yValLen = yVal ? yVal.length : 0,
  2628. EMApercent = 2 / (period + 1),
  2629. sum = 0,
  2630. EMA = [],
  2631. xData = [],
  2632. yData = [],
  2633. index = -1,
  2634. SMA = 0,
  2635. calEMA,
  2636. EMAPoint,
  2637. i;
  2638. // Check period, if bigger than points length, skip
  2639. if (yValLen < period) {
  2640. return;
  2641. }
  2642. // Switch index for OHLC / Candlestick / Arearange
  2643. if (isArray(yVal[0])) {
  2644. index = params.index ? params.index : 0;
  2645. }
  2646. // Accumulate first N-points
  2647. sum = this.accumulatePeriodPoints(period, index, yVal);
  2648. // first point
  2649. SMA = sum / period;
  2650. // Calculate value one-by-one for each period in visible data
  2651. for (i = period; i < yValLen + 1; i++) {
  2652. EMAPoint = this.calculateEma(xVal, yVal, i, EMApercent, calEMA, index, SMA);
  2653. EMA.push(EMAPoint);
  2654. xData.push(EMAPoint[0]);
  2655. yData.push(EMAPoint[1]);
  2656. calEMA = EMAPoint[1];
  2657. }
  2658. return {
  2659. values: EMA,
  2660. xData: xData,
  2661. yData: yData
  2662. };
  2663. };
  2664. /**
  2665. * Exponential moving average indicator (EMA). This series requires the
  2666. * `linkedTo` option to be set.
  2667. *
  2668. * @sample stock/indicators/ema
  2669. * Exponential moving average indicator
  2670. *
  2671. * @extends plotOptions.sma
  2672. * @since 6.0.0
  2673. * @product highstock
  2674. * @requires stock/indicators/indicators
  2675. * @requires stock/indicators/ema
  2676. * @optionparent plotOptions.ema
  2677. */
  2678. EMAIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  2679. params: {
  2680. /**
  2681. * The point index which indicator calculations will base. For
  2682. * example using OHLC data, index=2 means the indicator will be
  2683. * calculated using Low values.
  2684. *
  2685. * By default index value used to be set to 0. Since Highstock 7
  2686. * by default index is set to 3 which means that the ema
  2687. * indicator will be calculated using Close values.
  2688. */
  2689. index: 3,
  2690. period: 9 // @merge 14 in v6.2
  2691. }
  2692. });
  2693. return EMAIndicator;
  2694. }(SMAIndicator));
  2695. SeriesRegistry.registerSeriesType('ema', EMAIndicator);
  2696. /* *
  2697. *
  2698. * Default Export
  2699. *
  2700. * */
  2701. /**
  2702. * A `EMA` series. If the [type](#series.ema.type) option is not
  2703. * specified, it is inherited from [chart.type](#chart.type).
  2704. *
  2705. * @extends series,plotOptions.ema
  2706. * @since 6.0.0
  2707. * @product highstock
  2708. * @excluding dataParser, dataURL
  2709. * @requires stock/indicators/indicators
  2710. * @requires stock/indicators/ema
  2711. * @apioption series.ema
  2712. */
  2713. ''; // adds doclet above to the transpiled file
  2714. return EMAIndicator;
  2715. });
  2716. _registerModule(_modules, 'Stock/Indicators/Chaikin/ChaikinIndicator.js', [_modules['Mixins/IndicatorRequired.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (RequiredIndicatorMixin, SeriesRegistry, U) {
  2717. /* *
  2718. *
  2719. * License: www.highcharts.com/license
  2720. *
  2721. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2722. *
  2723. * */
  2724. var __extends = (this && this.__extends) || (function () {
  2725. var extendStatics = function (d,
  2726. b) {
  2727. extendStatics = Object.setPrototypeOf ||
  2728. ({ __proto__: [] } instanceof Array && function (d,
  2729. b) { d.__proto__ = b; }) ||
  2730. function (d,
  2731. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2732. return extendStatics(d, b);
  2733. };
  2734. return function (d, b) {
  2735. extendStatics(d, b);
  2736. function __() { this.constructor = d; }
  2737. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2738. };
  2739. })();
  2740. var _a = SeriesRegistry.seriesTypes,
  2741. AD = _a.ad,
  2742. EMAIndicator = _a.ema;
  2743. var correctFloat = U.correctFloat,
  2744. extend = U.extend,
  2745. merge = U.merge,
  2746. error = U.error;
  2747. /* *
  2748. *
  2749. * Class
  2750. *
  2751. * */
  2752. /**
  2753. * The Chaikin series type.
  2754. *
  2755. * @private
  2756. * @class
  2757. * @name Highcharts.seriesTypes.chaikin
  2758. *
  2759. * @augments Highcharts.Series
  2760. */
  2761. var ChaikinIndicator = /** @class */ (function (_super) {
  2762. __extends(ChaikinIndicator, _super);
  2763. function ChaikinIndicator() {
  2764. var _this = _super !== null && _super.apply(this,
  2765. arguments) || this;
  2766. /* *
  2767. *
  2768. * Properties
  2769. *
  2770. * */
  2771. _this.data = void 0;
  2772. _this.options = void 0;
  2773. _this.points = void 0;
  2774. return _this;
  2775. }
  2776. /* *
  2777. *
  2778. * Functions
  2779. *
  2780. * */
  2781. ChaikinIndicator.prototype.init = function () {
  2782. var args = arguments,
  2783. ctx = this;
  2784. RequiredIndicatorMixin.isParentLoaded(EMAIndicator, 'ema', ctx.type, function (indicator) {
  2785. indicator.prototype.init.apply(ctx, args);
  2786. return;
  2787. });
  2788. };
  2789. ChaikinIndicator.prototype.getValues = function (series, params) {
  2790. var periods = params.periods,
  2791. period = params.period,
  2792. // Accumulation Distribution Line data
  2793. ADL,
  2794. // 0- date, 1- Chaikin Oscillator
  2795. CHA = [],
  2796. xData = [],
  2797. yData = [],
  2798. periodsOffset,
  2799. // Shorter Period EMA
  2800. SPE,
  2801. // Longer Period EMA
  2802. LPE,
  2803. oscillator,
  2804. i;
  2805. // Check if periods are correct
  2806. if (periods.length !== 2 || periods[1] <= periods[0]) {
  2807. error('Error: "Chaikin requires two periods. Notice, first ' +
  2808. 'period should be lower than the second one."');
  2809. return;
  2810. }
  2811. ADL = AD.prototype.getValues.call(this, series, {
  2812. volumeSeriesID: params.volumeSeriesID,
  2813. period: period
  2814. });
  2815. // Check if adl is calculated properly, if not skip
  2816. if (!ADL) {
  2817. return;
  2818. }
  2819. SPE = EMAIndicator.prototype.getValues.call(this, ADL, {
  2820. period: periods[0]
  2821. });
  2822. LPE = EMAIndicator.prototype.getValues.call(this, ADL, {
  2823. period: periods[1]
  2824. });
  2825. // Check if ema is calculated properly, if not skip
  2826. if (!SPE || !LPE) {
  2827. return;
  2828. }
  2829. periodsOffset = periods[1] - periods[0];
  2830. for (i = 0; i < LPE.yData.length; i++) {
  2831. oscillator = correctFloat(SPE.yData[i + periodsOffset] -
  2832. LPE.yData[i]);
  2833. CHA.push([LPE.xData[i], oscillator]);
  2834. xData.push(LPE.xData[i]);
  2835. yData.push(oscillator);
  2836. }
  2837. return {
  2838. values: CHA,
  2839. xData: xData,
  2840. yData: yData
  2841. };
  2842. };
  2843. /**
  2844. * Chaikin Oscillator. This series requires the `linkedTo` option to
  2845. * be set and should be loaded after the `stock/indicators/indicators.js`
  2846. * and `stock/indicators/ema.js`.
  2847. *
  2848. * @sample {highstock} stock/indicators/chaikin
  2849. * Chaikin Oscillator
  2850. *
  2851. * @extends plotOptions.ema
  2852. * @since 7.0.0
  2853. * @product highstock
  2854. * @excluding allAreas, colorAxis, joinBy, keys, navigatorOptions,
  2855. * pointInterval, pointIntervalUnit, pointPlacement,
  2856. * pointRange, pointStart, showInNavigator, stacking
  2857. * @requires stock/indicators/indicators
  2858. * @requires stock/indicators/ema
  2859. * @requires stock/indicators/chaikin
  2860. * @optionparent plotOptions.chaikin
  2861. */
  2862. ChaikinIndicator.defaultOptions = merge(EMAIndicator.defaultOptions, {
  2863. /**
  2864. * Paramters used in calculation of Chaikin Oscillator
  2865. * series points.
  2866. *
  2867. * @excluding index, period
  2868. */
  2869. params: {
  2870. /**
  2871. * The id of volume series which is mandatory.
  2872. * For example using OHLC data, volumeSeriesID='volume' means
  2873. * the indicator will be calculated using OHLC and volume values.
  2874. */
  2875. volumeSeriesID: 'volume',
  2876. /**
  2877. * Periods for Chaikin Oscillator calculations.
  2878. *
  2879. * @type {Array<number>}
  2880. * @default [3, 10]
  2881. */
  2882. periods: [3, 10]
  2883. }
  2884. });
  2885. return ChaikinIndicator;
  2886. }(EMAIndicator));
  2887. extend(ChaikinIndicator.prototype, {
  2888. nameBase: 'Chaikin Osc',
  2889. nameComponents: ['periods']
  2890. });
  2891. SeriesRegistry.registerSeriesType('chaikin', ChaikinIndicator);
  2892. /* *
  2893. *
  2894. * Default Export
  2895. *
  2896. * */
  2897. /**
  2898. * A `Chaikin Oscillator` series. If the [type](#series.chaikin.type)
  2899. * option is not specified, it is inherited from [chart.type](#chart.type).
  2900. *
  2901. * @extends series,plotOptions.chaikin
  2902. * @since 7.0.0
  2903. * @product highstock
  2904. * @excluding allAreas, colorAxis, dataParser, dataURL, joinBy, keys,
  2905. * navigatorOptions, pointInterval, pointIntervalUnit,
  2906. * pointPlacement, pointRange, pointStart, stacking, showInNavigator
  2907. * @requires stock/indicators/indicators
  2908. * @requires stock/indicators/ema
  2909. * @requires stock/indicators/chaikin
  2910. * @apioption series.chaikin
  2911. */
  2912. ''; // to include the above in the js output
  2913. return ChaikinIndicator;
  2914. });
  2915. _registerModule(_modules, 'Stock/Indicators/DEMA/DEMAIndicator.js', [_modules['Mixins/IndicatorRequired.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (RequiredIndicatorMixin, SeriesRegistry, U) {
  2916. /* *
  2917. *
  2918. * License: www.highcharts.com/license
  2919. *
  2920. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2921. *
  2922. * */
  2923. var __extends = (this && this.__extends) || (function () {
  2924. var extendStatics = function (d,
  2925. b) {
  2926. extendStatics = Object.setPrototypeOf ||
  2927. ({ __proto__: [] } instanceof Array && function (d,
  2928. b) { d.__proto__ = b; }) ||
  2929. function (d,
  2930. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  2931. return extendStatics(d, b);
  2932. };
  2933. return function (d, b) {
  2934. extendStatics(d, b);
  2935. function __() { this.constructor = d; }
  2936. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  2937. };
  2938. })();
  2939. var EMAIndicator = SeriesRegistry.seriesTypes.ema;
  2940. var correctFloat = U.correctFloat,
  2941. isArray = U.isArray,
  2942. merge = U.merge;
  2943. /**
  2944. * The DEMA series Type
  2945. *
  2946. * @private
  2947. * @class
  2948. * @name Highcharts.seriesTypes.dema
  2949. *
  2950. * @augments Highcharts.Series
  2951. */
  2952. var DEMAIndicator = /** @class */ (function (_super) {
  2953. __extends(DEMAIndicator, _super);
  2954. function DEMAIndicator() {
  2955. var _this = _super !== null && _super.apply(this,
  2956. arguments) || this;
  2957. _this.EMApercent = void 0;
  2958. _this.data = void 0;
  2959. _this.options = void 0;
  2960. _this.points = void 0;
  2961. return _this;
  2962. }
  2963. DEMAIndicator.prototype.init = function () {
  2964. var args = arguments,
  2965. ctx = this;
  2966. RequiredIndicatorMixin.isParentLoaded(EMAIndicator, 'ema', ctx.type, function (indicator) {
  2967. indicator.prototype.init.apply(ctx, args);
  2968. return;
  2969. });
  2970. };
  2971. DEMAIndicator.prototype.getEMA = function (yVal, prevEMA, SMA, index, i, xVal) {
  2972. return EMAIndicator.prototype.calculateEma(xVal || [], yVal, typeof i === 'undefined' ? 1 : i, this.EMApercent, prevEMA, typeof index === 'undefined' ? -1 : index, SMA);
  2973. };
  2974. DEMAIndicator.prototype.getValues = function (series, params) {
  2975. var period = params.period,
  2976. doubledPeriod = 2 * period,
  2977. xVal = series.xData,
  2978. yVal = series.yData,
  2979. yValLen = yVal ? yVal.length : 0,
  2980. index = -1,
  2981. accumulatePeriodPoints = 0,
  2982. SMA = 0,
  2983. DEMA = [],
  2984. xDataDema = [],
  2985. yDataDema = [],
  2986. EMA = 0,
  2987. // EMA(EMA)
  2988. EMAlevel2,
  2989. // EMA of previous point
  2990. prevEMA,
  2991. prevEMAlevel2,
  2992. // EMA values array
  2993. EMAvalues = [],
  2994. i,
  2995. DEMAPoint;
  2996. this.EMApercent = (2 / (period + 1));
  2997. // Check period, if bigger than EMA points length, skip
  2998. if (yValLen < 2 * period - 1) {
  2999. return;
  3000. }
  3001. // Switch index for OHLC / Candlestick / Arearange
  3002. if (isArray(yVal[0])) {
  3003. index = params.index ? params.index : 0;
  3004. }
  3005. // Accumulate first N-points
  3006. accumulatePeriodPoints =
  3007. EMAIndicator.prototype.accumulatePeriodPoints(period, index, yVal);
  3008. // first point
  3009. SMA = accumulatePeriodPoints / period;
  3010. accumulatePeriodPoints = 0;
  3011. // Calculate value one-by-one for each period in visible data
  3012. for (i = period; i < yValLen + 2; i++) {
  3013. if (i < yValLen + 1) {
  3014. EMA = this.getEMA(yVal, prevEMA, SMA, index, i)[1];
  3015. EMAvalues.push(EMA);
  3016. }
  3017. prevEMA = EMA;
  3018. // Summing first period points for EMA(EMA)
  3019. if (i < doubledPeriod) {
  3020. accumulatePeriodPoints += EMA;
  3021. }
  3022. else {
  3023. // Calculate DEMA
  3024. // First DEMA point
  3025. if (i === doubledPeriod) {
  3026. SMA = accumulatePeriodPoints / period;
  3027. }
  3028. EMA = EMAvalues[i - period - 1];
  3029. EMAlevel2 = this.getEMA([EMA], prevEMAlevel2, SMA)[1];
  3030. DEMAPoint = [
  3031. xVal[i - 2],
  3032. correctFloat(2 * EMA - EMAlevel2)
  3033. ];
  3034. DEMA.push(DEMAPoint);
  3035. xDataDema.push(DEMAPoint[0]);
  3036. yDataDema.push(DEMAPoint[1]);
  3037. prevEMAlevel2 = EMAlevel2;
  3038. }
  3039. }
  3040. return {
  3041. values: DEMA,
  3042. xData: xDataDema,
  3043. yData: yDataDema
  3044. };
  3045. };
  3046. /**
  3047. * Double exponential moving average (DEMA) indicator. This series requires
  3048. * `linkedTo` option to be set and should be loaded after the
  3049. * `stock/indicators/indicators.js` and `stock/indicators/ema.js`.
  3050. *
  3051. * @sample {highstock} stock/indicators/dema
  3052. * DEMA indicator
  3053. *
  3054. * @extends plotOptions.ema
  3055. * @since 7.0.0
  3056. * @product highstock
  3057. * @excluding allAreas, colorAxis, compare, compareBase, joinBy, keys,
  3058. * navigatorOptions, pointInterval, pointIntervalUnit,
  3059. * pointPlacement, pointRange, pointStart, showInNavigator,
  3060. * stacking
  3061. * @requires stock/indicators/indicators
  3062. * @requires stock/indicators/ema
  3063. * @requires stock/indicators/dema
  3064. * @optionparent plotOptions.dema
  3065. */
  3066. DEMAIndicator.defaultOptions = merge(EMAIndicator.defaultOptions);
  3067. return DEMAIndicator;
  3068. }(EMAIndicator));
  3069. SeriesRegistry.registerSeriesType('dema', DEMAIndicator);
  3070. /* *
  3071. *
  3072. * Default Export
  3073. *
  3074. * */
  3075. /**
  3076. * A `DEMA` series. If the [type](#series.ema.type) option is not
  3077. * specified, it is inherited from [chart.type](#chart.type).
  3078. *
  3079. * @extends series,plotOptions.ema
  3080. * @since 7.0.0
  3081. * @product highstock
  3082. * @excluding allAreas, colorAxis, compare, compareBase, dataParser, dataURL,
  3083. * joinBy, keys, navigatorOptions, pointInterval, pointIntervalUnit,
  3084. * pointPlacement, pointRange, pointStart, showInNavigator, stacking
  3085. * @requires stock/indicators/indicators
  3086. * @requires stock/indicators/ema
  3087. * @requires stock/indicators/dema
  3088. * @apioption series.dema
  3089. */
  3090. ''; // adds doclet above to the transpiled file
  3091. return DEMAIndicator;
  3092. });
  3093. _registerModule(_modules, 'Stock/Indicators/TEMA/TEMAIndicator.js', [_modules['Mixins/IndicatorRequired.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (RequiredIndicatorMixin, SeriesRegistry, U) {
  3094. /* *
  3095. *
  3096. * License: www.highcharts.com/license
  3097. *
  3098. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3099. *
  3100. * */
  3101. var __extends = (this && this.__extends) || (function () {
  3102. var extendStatics = function (d,
  3103. b) {
  3104. extendStatics = Object.setPrototypeOf ||
  3105. ({ __proto__: [] } instanceof Array && function (d,
  3106. b) { d.__proto__ = b; }) ||
  3107. function (d,
  3108. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3109. return extendStatics(d, b);
  3110. };
  3111. return function (d, b) {
  3112. extendStatics(d, b);
  3113. function __() { this.constructor = d; }
  3114. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3115. };
  3116. })();
  3117. var EMAIndicator = SeriesRegistry.seriesTypes.ema;
  3118. var correctFloat = U.correctFloat,
  3119. isArray = U.isArray,
  3120. merge = U.merge;
  3121. /**
  3122. * The TEMA series type.
  3123. *
  3124. * @private
  3125. * @class
  3126. * @name Highcharts.seriesTypes.tema
  3127. *
  3128. * @augments Highcharts.Series
  3129. */
  3130. var TEMAIndicator = /** @class */ (function (_super) {
  3131. __extends(TEMAIndicator, _super);
  3132. function TEMAIndicator() {
  3133. var _this = _super !== null && _super.apply(this,
  3134. arguments) || this;
  3135. _this.EMApercent = void 0;
  3136. _this.data = void 0;
  3137. _this.options = void 0;
  3138. _this.points = void 0;
  3139. return _this;
  3140. }
  3141. TEMAIndicator.prototype.init = function () {
  3142. var args = arguments,
  3143. ctx = this;
  3144. RequiredIndicatorMixin.isParentLoaded(EMAIndicator, 'ema', ctx.type, function (indicator) {
  3145. indicator.prototype.init.apply(ctx, args);
  3146. return;
  3147. });
  3148. };
  3149. TEMAIndicator.prototype.getEMA = function (yVal, prevEMA, SMA, index, i, xVal) {
  3150. return EMAIndicator.prototype.calculateEma(xVal || [], yVal, typeof i === 'undefined' ? 1 : i, this.EMApercent, prevEMA, typeof index === 'undefined' ? -1 : index, SMA);
  3151. };
  3152. TEMAIndicator.prototype.getTemaPoint = function (xVal, tripledPeriod, EMAlevels, i) {
  3153. var TEMAPoint = [
  3154. xVal[i - 3],
  3155. correctFloat(3 * EMAlevels.level1 -
  3156. 3 * EMAlevels.level2 + EMAlevels.level3)
  3157. ];
  3158. return TEMAPoint;
  3159. };
  3160. TEMAIndicator.prototype.getValues = function (series, params) {
  3161. var period = params.period,
  3162. doubledPeriod = 2 * period,
  3163. tripledPeriod = 3 * period,
  3164. xVal = series.xData,
  3165. yVal = series.yData,
  3166. yValLen = yVal ? yVal.length : 0,
  3167. index = -1,
  3168. accumulatePeriodPoints = 0,
  3169. SMA = 0,
  3170. TEMA = [],
  3171. xDataTema = [],
  3172. yDataTema = [],
  3173. // EMA of previous point
  3174. prevEMA,
  3175. prevEMAlevel2,
  3176. // EMA values array
  3177. EMAvalues = [],
  3178. EMAlevel2values = [],
  3179. i,
  3180. TEMAPoint,
  3181. // This object contains all EMA EMAlevels calculated like below
  3182. // EMA = level1
  3183. // EMA(EMA) = level2,
  3184. // EMA(EMA(EMA)) = level3,
  3185. EMAlevels = {};
  3186. this.EMApercent = (2 / (period + 1));
  3187. // Check period, if bigger than EMA points length, skip
  3188. if (yValLen < 3 * period - 2) {
  3189. return;
  3190. }
  3191. // Switch index for OHLC / Candlestick / Arearange
  3192. if (isArray(yVal[0])) {
  3193. index = params.index ? params.index : 0;
  3194. }
  3195. // Accumulate first N-points
  3196. accumulatePeriodPoints =
  3197. EMAIndicator.prototype.accumulatePeriodPoints(period, index, yVal);
  3198. // first point
  3199. SMA = accumulatePeriodPoints / period;
  3200. accumulatePeriodPoints = 0;
  3201. // Calculate value one-by-one for each period in visible data
  3202. for (i = period; i < yValLen + 3; i++) {
  3203. if (i < yValLen + 1) {
  3204. EMAlevels.level1 = this.getEMA(yVal, prevEMA, SMA, index, i)[1];
  3205. EMAvalues.push(EMAlevels.level1);
  3206. }
  3207. prevEMA = EMAlevels.level1;
  3208. // Summing first period points for ema(ema)
  3209. if (i < doubledPeriod) {
  3210. accumulatePeriodPoints += EMAlevels.level1;
  3211. }
  3212. else {
  3213. // Calculate dema
  3214. // First dema point
  3215. if (i === doubledPeriod) {
  3216. SMA = accumulatePeriodPoints / period;
  3217. accumulatePeriodPoints = 0;
  3218. }
  3219. EMAlevels.level1 = EMAvalues[i - period - 1];
  3220. EMAlevels.level2 = this.getEMA([EMAlevels.level1], prevEMAlevel2, SMA)[1];
  3221. EMAlevel2values.push(EMAlevels.level2);
  3222. prevEMAlevel2 = EMAlevels.level2;
  3223. // Summing first period points for ema(ema(ema))
  3224. if (i < tripledPeriod) {
  3225. accumulatePeriodPoints += EMAlevels.level2;
  3226. }
  3227. else {
  3228. // Calculate tema
  3229. // First tema point
  3230. if (i === tripledPeriod) {
  3231. SMA = accumulatePeriodPoints / period;
  3232. }
  3233. if (i === yValLen + 1) {
  3234. // Calculate the last ema and emaEMA points
  3235. EMAlevels.level1 = EMAvalues[i - period - 1];
  3236. EMAlevels.level2 = this.getEMA([EMAlevels.level1], prevEMAlevel2, SMA)[1];
  3237. EMAlevel2values.push(EMAlevels.level2);
  3238. }
  3239. EMAlevels.level1 = EMAvalues[i - period - 2];
  3240. EMAlevels.level2 = EMAlevel2values[i - 2 * period - 1];
  3241. EMAlevels.level3 = this.getEMA([EMAlevels.level2], EMAlevels.prevLevel3, SMA)[1];
  3242. TEMAPoint = this.getTemaPoint(xVal, tripledPeriod, EMAlevels, i);
  3243. // Make sure that point exists (for TRIX oscillator)
  3244. if (TEMAPoint) {
  3245. TEMA.push(TEMAPoint);
  3246. xDataTema.push(TEMAPoint[0]);
  3247. yDataTema.push(TEMAPoint[1]);
  3248. }
  3249. EMAlevels.prevLevel3 = EMAlevels.level3;
  3250. }
  3251. }
  3252. }
  3253. return {
  3254. values: TEMA,
  3255. xData: xDataTema,
  3256. yData: yDataTema
  3257. };
  3258. };
  3259. /**
  3260. * Triple exponential moving average (TEMA) indicator. This series requires
  3261. * `linkedTo` option to be set and should be loaded after the
  3262. * `stock/indicators/indicators.js` and `stock/indicators/ema.js`.
  3263. *
  3264. * @sample {highstock} stock/indicators/tema
  3265. * TEMA indicator
  3266. *
  3267. * @extends plotOptions.ema
  3268. * @since 7.0.0
  3269. * @product highstock
  3270. * @excluding allAreas, colorAxis, compare, compareBase, joinBy, keys,
  3271. * navigatorOptions, pointInterval, pointIntervalUnit,
  3272. * pointPlacement, pointRange, pointStart, showInNavigator,
  3273. * stacking
  3274. * @requires stock/indicators/indicators
  3275. * @requires stock/indicators/ema
  3276. * @requires stock/indicators/tema
  3277. * @optionparent plotOptions.tema
  3278. */
  3279. TEMAIndicator.defaultOptions = merge(EMAIndicator.defaultOptions);
  3280. return TEMAIndicator;
  3281. }(EMAIndicator));
  3282. SeriesRegistry.registerSeriesType('tema', TEMAIndicator);
  3283. /* *
  3284. *
  3285. * Default Export
  3286. *
  3287. * */
  3288. /**
  3289. * A `TEMA` series. If the [type](#series.ema.type) option is not
  3290. * specified, it is inherited from [chart.type](#chart.type).
  3291. *
  3292. * @extends series,plotOptions.ema
  3293. * @since 7.0.0
  3294. * @product highstock
  3295. * @excluding allAreas, colorAxis, compare, compareBase, dataParser, dataURL,
  3296. * joinBy, keys, navigatorOptions, pointInterval, pointIntervalUnit,
  3297. * pointPlacement, pointRange, pointStart, showInNavigator, stacking
  3298. * @requires stock/indicators/indicators
  3299. * @requires stock/indicators/ema
  3300. * @requires stock/indicators/tema
  3301. * @apioption series.tema
  3302. */
  3303. ''; // to include the above in the js output
  3304. return TEMAIndicator;
  3305. });
  3306. _registerModule(_modules, 'Stock/Indicators/TRIX/TRIXIndicator.js', [_modules['Mixins/IndicatorRequired.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (RequiredIndicatorMixin, SeriesRegistry, U) {
  3307. /* *
  3308. *
  3309. * License: www.highcharts.com/license
  3310. *
  3311. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3312. *
  3313. * */
  3314. var __extends = (this && this.__extends) || (function () {
  3315. var extendStatics = function (d,
  3316. b) {
  3317. extendStatics = Object.setPrototypeOf ||
  3318. ({ __proto__: [] } instanceof Array && function (d,
  3319. b) { d.__proto__ = b; }) ||
  3320. function (d,
  3321. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3322. return extendStatics(d, b);
  3323. };
  3324. return function (d, b) {
  3325. extendStatics(d, b);
  3326. function __() { this.constructor = d; }
  3327. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3328. };
  3329. })();
  3330. var TEMAIndicator = SeriesRegistry.seriesTypes.tema;
  3331. var correctFloat = U.correctFloat,
  3332. merge = U.merge;
  3333. /**
  3334. * The TRIX series type.
  3335. *
  3336. * @private
  3337. * @class
  3338. * @name Highcharts.seriesTypes.trix
  3339. *
  3340. * @augments Highcharts.Series
  3341. */
  3342. var TRIXIndicator = /** @class */ (function (_super) {
  3343. __extends(TRIXIndicator, _super);
  3344. function TRIXIndicator() {
  3345. var _this = _super !== null && _super.apply(this,
  3346. arguments) || this;
  3347. _this.data = void 0;
  3348. _this.options = void 0;
  3349. _this.points = void 0;
  3350. return _this;
  3351. }
  3352. TRIXIndicator.prototype.init = function () {
  3353. var args = arguments,
  3354. ctx = this;
  3355. RequiredIndicatorMixin.isParentLoaded(SeriesRegistry.seriesTypes.tema, 'tema', ctx.type, function (indicator) {
  3356. indicator.prototype.init.apply(ctx, args);
  3357. return;
  3358. });
  3359. };
  3360. // TRIX is calculated using TEMA so we just extend getTemaPoint method.
  3361. TRIXIndicator.prototype.getTemaPoint = function (xVal, tripledPeriod, EMAlevels, i) {
  3362. if (i > tripledPeriod) {
  3363. var TRIXPoint = [
  3364. xVal[i - 3],
  3365. EMAlevels.prevLevel3 !== 0 ?
  3366. correctFloat(EMAlevels.level3 - EMAlevels.prevLevel3) /
  3367. EMAlevels.prevLevel3 * 100 : null
  3368. ];
  3369. }
  3370. return TRIXPoint;
  3371. };
  3372. /**
  3373. * Triple exponential average (TRIX) oscillator. This series requires
  3374. * `linkedTo` option to be set.
  3375. *
  3376. * Requires https://code.highcharts.com/stock/indicators/ema.js
  3377. * and https://code.highcharts.com/stock/indicators/tema.js.
  3378. *
  3379. * @sample {highstock} stock/indicators/trix
  3380. * TRIX indicator
  3381. *
  3382. * @extends plotOptions.tema
  3383. * @since 7.0.0
  3384. * @product highstock
  3385. * @excluding allAreas, colorAxis, compare, compareBase, joinBy, keys,
  3386. * navigatorOptions, pointInterval, pointIntervalUnit,
  3387. * pointPlacement, pointRange, pointStart, showInNavigator,
  3388. * stacking
  3389. * @optionparent plotOptions.trix
  3390. */
  3391. TRIXIndicator.defaultOptions = merge(TEMAIndicator.defaultOptions);
  3392. return TRIXIndicator;
  3393. }(TEMAIndicator));
  3394. SeriesRegistry.registerSeriesType('trix', TRIXIndicator);
  3395. /* *
  3396. *
  3397. * Default Export
  3398. *
  3399. * */
  3400. /**
  3401. * A `TRIX` series. If the [type](#series.tema.type) option is not specified, it
  3402. * is inherited from [chart.type](#chart.type).
  3403. *
  3404. * @extends series,plotOptions.tema
  3405. * @since 7.0.0
  3406. * @product highstock
  3407. * @excluding allAreas, colorAxis, compare, compareBase, dataParser, dataURL,
  3408. * joinBy, keys, navigatorOptions, pointInterval, pointIntervalUnit,
  3409. * pointPlacement, pointRange, pointStart, showInNavigator, stacking
  3410. * @apioption series.trix
  3411. */
  3412. ''; // to include the above in the js output
  3413. return TRIXIndicator;
  3414. });
  3415. _registerModule(_modules, 'Stock/Indicators/APO/APOIndicator.js', [_modules['Mixins/IndicatorRequired.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (RequiredIndicatorMixin, SeriesRegistry, U) {
  3416. /* *
  3417. *
  3418. * License: www.highcharts.com/license
  3419. *
  3420. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3421. *
  3422. * */
  3423. var __extends = (this && this.__extends) || (function () {
  3424. var extendStatics = function (d,
  3425. b) {
  3426. extendStatics = Object.setPrototypeOf ||
  3427. ({ __proto__: [] } instanceof Array && function (d,
  3428. b) { d.__proto__ = b; }) ||
  3429. function (d,
  3430. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3431. return extendStatics(d, b);
  3432. };
  3433. return function (d, b) {
  3434. extendStatics(d, b);
  3435. function __() { this.constructor = d; }
  3436. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3437. };
  3438. })();
  3439. var EMAIndicator = SeriesRegistry.seriesTypes.ema;
  3440. var extend = U.extend,
  3441. merge = U.merge,
  3442. error = U.error;
  3443. /* *
  3444. *
  3445. * Class
  3446. *
  3447. * */
  3448. /**
  3449. * The APO series type.
  3450. *
  3451. * @private
  3452. * @class
  3453. * @name Highcharts.seriesTypes.apo
  3454. *
  3455. * @augments Highcharts.Series
  3456. */
  3457. var APOIndicator = /** @class */ (function (_super) {
  3458. __extends(APOIndicator, _super);
  3459. function APOIndicator() {
  3460. var _this = _super !== null && _super.apply(this,
  3461. arguments) || this;
  3462. /* *
  3463. *
  3464. * Properties
  3465. *
  3466. * */
  3467. _this.data = void 0;
  3468. _this.options = void 0;
  3469. _this.points = void 0;
  3470. return _this;
  3471. }
  3472. /* *
  3473. *
  3474. * Functions
  3475. *
  3476. * */
  3477. APOIndicator.prototype.getValues = function (series, params) {
  3478. var periods = params.periods,
  3479. index = params.index,
  3480. // 0- date, 1- Absolute price oscillator
  3481. APO = [],
  3482. xData = [],
  3483. yData = [],
  3484. periodsOffset,
  3485. // Shorter Period EMA
  3486. SPE,
  3487. // Longer Period EMA
  3488. LPE,
  3489. oscillator,
  3490. i;
  3491. // Check if periods are correct
  3492. if (periods.length !== 2 || periods[1] <= periods[0]) {
  3493. error('Error: "APO requires two periods. Notice, first period ' +
  3494. 'should be lower than the second one."');
  3495. return;
  3496. }
  3497. SPE = EMAIndicator.prototype.getValues.call(this, series, {
  3498. index: index,
  3499. period: periods[0]
  3500. });
  3501. LPE = EMAIndicator.prototype.getValues.call(this, series, {
  3502. index: index,
  3503. period: periods[1]
  3504. });
  3505. // Check if ema is calculated properly, if not skip
  3506. if (!SPE || !LPE) {
  3507. return;
  3508. }
  3509. periodsOffset = periods[1] - periods[0];
  3510. for (i = 0; i < LPE.yData.length; i++) {
  3511. oscillator = (SPE.yData[i + periodsOffset] -
  3512. LPE.yData[i]);
  3513. APO.push([LPE.xData[i], oscillator]);
  3514. xData.push(LPE.xData[i]);
  3515. yData.push(oscillator);
  3516. }
  3517. return {
  3518. values: APO,
  3519. xData: xData,
  3520. yData: yData
  3521. };
  3522. };
  3523. APOIndicator.prototype.init = function () {
  3524. var args = arguments,
  3525. ctx = this;
  3526. RequiredIndicatorMixin.isParentLoaded(EMAIndicator, 'ema', ctx.type, function (indicator) {
  3527. indicator.prototype.init.apply(ctx, args);
  3528. return;
  3529. });
  3530. };
  3531. /**
  3532. * Absolute Price Oscillator. This series requires the `linkedTo` option to
  3533. * be set and should be loaded after the `stock/indicators/indicators.js`
  3534. * and `stock/indicators/ema.js`.
  3535. *
  3536. * @sample {highstock} stock/indicators/apo
  3537. * Absolute Price Oscillator
  3538. *
  3539. * @extends plotOptions.ema
  3540. * @since 7.0.0
  3541. * @product highstock
  3542. * @excluding allAreas, colorAxis, joinBy, keys, navigatorOptions,
  3543. * pointInterval, pointIntervalUnit, pointPlacement,
  3544. * pointRange, pointStart, showInNavigator, stacking
  3545. * @requires stock/indicators/indicators
  3546. * @requires stock/indicators/ema
  3547. * @requires stock/indicators/apo
  3548. * @optionparent plotOptions.apo
  3549. */
  3550. APOIndicator.defaultOptions = merge(EMAIndicator.defaultOptions, {
  3551. /**
  3552. * Paramters used in calculation of Absolute Price Oscillator
  3553. * series points.
  3554. *
  3555. * @excluding period
  3556. */
  3557. params: {
  3558. /**
  3559. * Periods for Absolute Price Oscillator calculations.
  3560. *
  3561. * @type {Array<number>}
  3562. * @default [10, 20]
  3563. * @since 7.0.0
  3564. */
  3565. periods: [10, 20]
  3566. }
  3567. });
  3568. return APOIndicator;
  3569. }(EMAIndicator));
  3570. extend(APOIndicator.prototype, {
  3571. nameBase: 'APO',
  3572. nameComponents: ['periods']
  3573. });
  3574. SeriesRegistry.registerSeriesType('apo', APOIndicator);
  3575. /* *
  3576. *
  3577. * Default Export
  3578. *
  3579. * */
  3580. /**
  3581. * An `Absolute Price Oscillator` series. If the [type](#series.apo.type) option
  3582. * is not specified, it is inherited from [chart.type](#chart.type).
  3583. *
  3584. * @extends series,plotOptions.apo
  3585. * @since 7.0.0
  3586. * @product highstock
  3587. * @excluding allAreas, colorAxis, dataParser, dataURL, joinBy, keys,
  3588. * navigatorOptions, pointInterval, pointIntervalUnit,
  3589. * pointPlacement, pointRange, pointStart, showInNavigator, stacking
  3590. * @requires stock/indicators/indicators
  3591. * @requires stock/indicators/ema
  3592. * @requires stock/indicators/apo
  3593. * @apioption series.apo
  3594. */
  3595. ''; // to include the above in the js output
  3596. return APOIndicator;
  3597. });
  3598. _registerModule(_modules, 'Stock/Indicators/IKH/IKHIndicator.js', [_modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (Color, H, SeriesRegistry, U) {
  3599. /* *
  3600. *
  3601. * License: www.highcharts.com/license
  3602. *
  3603. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3604. *
  3605. * */
  3606. var __extends = (this && this.__extends) || (function () {
  3607. var extendStatics = function (d,
  3608. b) {
  3609. extendStatics = Object.setPrototypeOf ||
  3610. ({ __proto__: [] } instanceof Array && function (d,
  3611. b) { d.__proto__ = b; }) ||
  3612. function (d,
  3613. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  3614. return extendStatics(d, b);
  3615. };
  3616. return function (d, b) {
  3617. extendStatics(d, b);
  3618. function __() { this.constructor = d; }
  3619. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  3620. };
  3621. })();
  3622. var color = Color.parse;
  3623. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  3624. var defined = U.defined,
  3625. extend = U.extend,
  3626. isArray = U.isArray,
  3627. merge = U.merge,
  3628. objectEach = U.objectEach;
  3629. /* eslint-disable require-jsdoc */
  3630. // Utils:
  3631. function maxHigh(arr) {
  3632. return arr.reduce(function (max, res) {
  3633. return Math.max(max, res[1]);
  3634. }, -Infinity);
  3635. }
  3636. function minLow(arr) {
  3637. return arr.reduce(function (min, res) {
  3638. return Math.min(min, res[2]);
  3639. }, Infinity);
  3640. }
  3641. function highlowLevel(arr) {
  3642. return {
  3643. high: maxHigh(arr),
  3644. low: minLow(arr)
  3645. };
  3646. }
  3647. function getClosestPointRange(axis) {
  3648. var closestDataRange,
  3649. loopLength,
  3650. distance,
  3651. xData,
  3652. i;
  3653. axis.series.forEach(function (series) {
  3654. if (series.xData) {
  3655. xData = series.xData;
  3656. loopLength = series.xIncrement ? 1 : xData.length - 1;
  3657. for (i = loopLength; i > 0; i--) {
  3658. distance = xData[i] - xData[i - 1];
  3659. if (typeof closestDataRange === 'undefined' ||
  3660. distance < closestDataRange) {
  3661. closestDataRange = distance;
  3662. }
  3663. }
  3664. }
  3665. });
  3666. return closestDataRange;
  3667. }
  3668. // Check two lines intersection (line a1-a2 and b1-b2)
  3669. // Source: https://en.wikipedia.org/wiki/Line%E2%80%93line_intersection
  3670. function checkLineIntersection(a1, a2, b1, b2) {
  3671. if (a1 && a2 && b1 && b2) {
  3672. var saX = a2.plotX - a1.plotX, // Auxiliary section a2-a1 X
  3673. saY = a2.plotY - a1.plotY, // Auxiliary section a2-a1 Y
  3674. sbX = b2.plotX - b1.plotX, // Auxiliary section b2-b1 X
  3675. sbY = b2.plotY - b1.plotY, // Auxiliary section b2-b1 Y
  3676. sabX = a1.plotX - b1.plotX, // Auxiliary section a1-b1 X
  3677. sabY = a1.plotY - b1.plotY, // Auxiliary section a1-b1 Y
  3678. // First degree Bézier parameters
  3679. u,
  3680. t;
  3681. u = (-saY * sabX + saX * sabY) / (-sbX * saY + saX * sbY);
  3682. t = (sbX * sabY - sbY * sabX) / (-sbX * saY + saX * sbY);
  3683. if (u >= 0 && u <= 1 && t >= 0 && t <= 1) {
  3684. return {
  3685. plotX: a1.plotX + t * saX,
  3686. plotY: a1.plotY + t * saY
  3687. };
  3688. }
  3689. }
  3690. return false;
  3691. }
  3692. // Parameter opt (indicator options object) include indicator, points,
  3693. // nextPoints, color, options, gappedExtend and graph properties
  3694. function drawSenkouSpan(opt) {
  3695. var indicator = opt.indicator;
  3696. indicator.points = opt.points;
  3697. indicator.nextPoints = opt.nextPoints;
  3698. indicator.color = opt.color;
  3699. indicator.options = merge(opt.options.senkouSpan.styles, opt.gap);
  3700. indicator.graph = opt.graph;
  3701. indicator.fillGraph = true;
  3702. SeriesRegistry.seriesTypes.sma.prototype.drawGraph.call(indicator);
  3703. }
  3704. // Data integrity in Ichimoku is different than default 'averages':
  3705. // Point: [undefined, value, value, ...] is correct
  3706. // Point: [undefined, undefined, undefined, ...] is incorrect
  3707. H.approximations['ichimoku-averages'] = function () {
  3708. var ret = [],
  3709. isEmptyRange;
  3710. [].forEach.call(arguments, function (arr, i) {
  3711. ret.push(H.approximations.average(arr));
  3712. isEmptyRange = !isEmptyRange && typeof ret[i] === 'undefined';
  3713. });
  3714. // Return undefined when first elem. is undefined and let
  3715. // sum method handle null (#7377)
  3716. return isEmptyRange ? void 0 : ret;
  3717. };
  3718. /* eslint-enable require-jsdoc */
  3719. /**
  3720. * The IKH series type.
  3721. *
  3722. * @private
  3723. * @class
  3724. * @name Highcharts.seriesTypes.ikh
  3725. *
  3726. * @augments Highcharts.Series
  3727. */
  3728. /* *
  3729. *
  3730. * Class
  3731. *
  3732. * */
  3733. var IKHIndicator = /** @class */ (function (_super) {
  3734. __extends(IKHIndicator, _super);
  3735. function IKHIndicator() {
  3736. var _this = _super !== null && _super.apply(this,
  3737. arguments) || this;
  3738. /* *
  3739. *
  3740. * Properties
  3741. *
  3742. * */
  3743. _this.data = void 0;
  3744. _this.options = void 0;
  3745. _this.points = void 0;
  3746. _this.graphCollection = void 0;
  3747. _this.graphsenkouSpan = void 0;
  3748. _this.ikhMap = void 0;
  3749. _this.nextPoints = void 0;
  3750. return _this;
  3751. }
  3752. /* *
  3753. *
  3754. * Functions
  3755. *
  3756. * */
  3757. IKHIndicator.prototype.init = function () {
  3758. SeriesRegistry.seriesTypes.sma.prototype.init.apply(this, arguments);
  3759. // Set default color for lines:
  3760. this.options = merge({
  3761. tenkanLine: {
  3762. styles: {
  3763. lineColor: this.color
  3764. }
  3765. },
  3766. kijunLine: {
  3767. styles: {
  3768. lineColor: this.color
  3769. }
  3770. },
  3771. chikouLine: {
  3772. styles: {
  3773. lineColor: this.color
  3774. }
  3775. },
  3776. senkouSpanA: {
  3777. styles: {
  3778. lineColor: this.color,
  3779. fill: color(this.color).setOpacity(0.5).get()
  3780. }
  3781. },
  3782. senkouSpanB: {
  3783. styles: {
  3784. lineColor: this.color,
  3785. fill: color(this.color).setOpacity(0.5).get()
  3786. }
  3787. },
  3788. senkouSpan: {
  3789. styles: {
  3790. fill: color(this.color).setOpacity(0.2).get()
  3791. }
  3792. }
  3793. }, this.options);
  3794. };
  3795. IKHIndicator.prototype.toYData = function (point) {
  3796. return [
  3797. point.tenkanSen,
  3798. point.kijunSen,
  3799. point.chikouSpan,
  3800. point.senkouSpanA,
  3801. point.senkouSpanB
  3802. ];
  3803. };
  3804. IKHIndicator.prototype.translate = function () {
  3805. var indicator = this;
  3806. SeriesRegistry.seriesTypes.sma.prototype.translate.apply(indicator);
  3807. indicator.points.forEach(function (point) {
  3808. indicator.pointArrayMap.forEach(function (value) {
  3809. if (defined(point[value])) {
  3810. point['plot' + value] = indicator.yAxis.toPixels(point[value], true);
  3811. // Add extra parameters for support tooltip in moved
  3812. // lines
  3813. point.plotY = point['plot' + value];
  3814. point.tooltipPos = [
  3815. point.plotX,
  3816. point['plot' + value]
  3817. ];
  3818. point.isNull = false;
  3819. }
  3820. });
  3821. });
  3822. };
  3823. IKHIndicator.prototype.drawGraph = function () {
  3824. var indicator = this,
  3825. mainLinePoints = indicator.points,
  3826. pointsLength = mainLinePoints.length,
  3827. mainLineOptions = indicator.options,
  3828. mainLinePath = indicator.graph,
  3829. mainColor = indicator.color,
  3830. gappedExtend = {
  3831. options: {
  3832. gapSize: mainLineOptions.gapSize
  3833. }
  3834. },
  3835. pointArrayMapLength = indicator.pointArrayMap.length,
  3836. allIchimokuPoints = [
  3837. [],
  3838. [],
  3839. [],
  3840. [],
  3841. [],
  3842. []
  3843. ],
  3844. ikhMap = {
  3845. tenkanLine: allIchimokuPoints[0],
  3846. kijunLine: allIchimokuPoints[1],
  3847. chikouLine: allIchimokuPoints[2],
  3848. senkouSpanA: allIchimokuPoints[3],
  3849. senkouSpanB: allIchimokuPoints[4],
  3850. senkouSpan: allIchimokuPoints[5]
  3851. },
  3852. intersectIndexColl = [],
  3853. senkouSpanOptions = indicator
  3854. .options.senkouSpan,
  3855. color = senkouSpanOptions.color ||
  3856. senkouSpanOptions.styles.fill,
  3857. negativeColor = senkouSpanOptions.negativeColor,
  3858. // Points to create color and negativeColor senkouSpan
  3859. points = [
  3860. [],
  3861. [] // Points negative color
  3862. ],
  3863. // For span, we need an access to the next points, used in
  3864. // getGraphPath()
  3865. nextPoints = [
  3866. [],
  3867. [] // NextPoints negative color
  3868. ],
  3869. lineIndex = 0,
  3870. position,
  3871. point,
  3872. i,
  3873. startIntersect,
  3874. endIntersect,
  3875. sectionPoints,
  3876. sectionNextPoints,
  3877. pointsPlotYSum,
  3878. nextPointsPlotYSum,
  3879. senkouSpanTempColor,
  3880. concatArrIndex,
  3881. j,
  3882. k;
  3883. indicator.ikhMap = ikhMap;
  3884. // Generate points for all lines and spans lines:
  3885. while (pointsLength--) {
  3886. point = mainLinePoints[pointsLength];
  3887. for (i = 0; i < pointArrayMapLength; i++) {
  3888. position = indicator.pointArrayMap[i];
  3889. if (defined(point[position])) {
  3890. allIchimokuPoints[i].push({
  3891. plotX: point.plotX,
  3892. plotY: point['plot' + position],
  3893. isNull: false
  3894. });
  3895. }
  3896. }
  3897. if (negativeColor && pointsLength !== mainLinePoints.length - 1) {
  3898. // Check if lines intersect
  3899. var index = ikhMap.senkouSpanB.length - 1,
  3900. intersect = checkLineIntersection(ikhMap.senkouSpanA[index - 1],
  3901. ikhMap.senkouSpanA[index],
  3902. ikhMap.senkouSpanB[index - 1],
  3903. ikhMap.senkouSpanB[index]),
  3904. intersectPointObj = {
  3905. plotX: intersect.plotX,
  3906. plotY: intersect.plotY,
  3907. isNull: false,
  3908. intersectPoint: true
  3909. };
  3910. if (intersect) {
  3911. // Add intersect point to ichimoku points collection
  3912. // Create senkouSpan sections
  3913. ikhMap.senkouSpanA.splice(index, 0, intersectPointObj);
  3914. ikhMap.senkouSpanB.splice(index, 0, intersectPointObj);
  3915. intersectIndexColl.push(index);
  3916. }
  3917. }
  3918. }
  3919. // Modify options and generate lines:
  3920. objectEach(ikhMap, function (values, lineName) {
  3921. if (mainLineOptions[lineName] &&
  3922. lineName !== 'senkouSpan') {
  3923. // First line is rendered by default option
  3924. indicator.points = allIchimokuPoints[lineIndex];
  3925. indicator.options = merge(mainLineOptions[lineName].styles, gappedExtend);
  3926. indicator.graph = indicator['graph' + lineName];
  3927. indicator.fillGraph = false;
  3928. indicator.color = mainColor;
  3929. SeriesRegistry.seriesTypes.sma.prototype.drawGraph.call(indicator);
  3930. // Now save line
  3931. indicator['graph' + lineName] = indicator.graph;
  3932. }
  3933. lineIndex++;
  3934. });
  3935. // Generate senkouSpan area:
  3936. // If graphColection exist then remove svg
  3937. // element and indicator property
  3938. if (indicator.graphCollection) {
  3939. indicator.graphCollection.forEach(function (graphName) {
  3940. indicator[graphName].destroy();
  3941. delete indicator[graphName];
  3942. });
  3943. }
  3944. // Clean grapCollection or initialize it
  3945. indicator.graphCollection = [];
  3946. // When user set negativeColor property
  3947. if (negativeColor && ikhMap.senkouSpanA[0] && ikhMap.senkouSpanB[0]) {
  3948. // Add first and last point to senkouSpan area sections
  3949. intersectIndexColl.unshift(0);
  3950. intersectIndexColl.push(ikhMap.senkouSpanA.length - 1);
  3951. // Populate points and nextPoints arrays
  3952. for (j = 0; j < intersectIndexColl.length - 1; j++) {
  3953. startIntersect = intersectIndexColl[j];
  3954. endIntersect = intersectIndexColl[j + 1];
  3955. sectionPoints = ikhMap.senkouSpanB.slice(startIntersect, endIntersect + 1);
  3956. sectionNextPoints = ikhMap.senkouSpanA.slice(startIntersect, endIntersect + 1);
  3957. // Add points to color or negativeColor arrays
  3958. // Check the middle point (if exist)
  3959. if (Math.floor(sectionPoints.length / 2) >= 1) {
  3960. var x = Math.floor(sectionPoints.length / 2);
  3961. // When middle points has equal values
  3962. // Compare all ponints plotY value sum
  3963. if (sectionPoints[x].plotY === sectionNextPoints[x].plotY) {
  3964. pointsPlotYSum = 0;
  3965. nextPointsPlotYSum = 0;
  3966. for (k = 0; k < sectionPoints.length; k++) {
  3967. pointsPlotYSum += sectionPoints[k].plotY;
  3968. nextPointsPlotYSum += sectionNextPoints[k].plotY;
  3969. }
  3970. concatArrIndex =
  3971. pointsPlotYSum > nextPointsPlotYSum ? 0 : 1;
  3972. points[concatArrIndex] = points[concatArrIndex].concat(sectionPoints);
  3973. nextPoints[concatArrIndex] = nextPoints[concatArrIndex].concat(sectionNextPoints);
  3974. }
  3975. else {
  3976. // Compare middle point of the section
  3977. concatArrIndex =
  3978. sectionPoints[x].plotY > sectionNextPoints[x].plotY ? 0 : 1;
  3979. points[concatArrIndex] = points[concatArrIndex].concat(sectionPoints);
  3980. nextPoints[concatArrIndex] = nextPoints[concatArrIndex].concat(sectionNextPoints);
  3981. }
  3982. }
  3983. else {
  3984. // Compare first point of the section
  3985. concatArrIndex =
  3986. sectionPoints[0].plotY > sectionNextPoints[0].plotY ? 0 : 1;
  3987. points[concatArrIndex] = points[concatArrIndex].concat(sectionPoints);
  3988. nextPoints[concatArrIndex] = nextPoints[concatArrIndex].concat(sectionNextPoints);
  3989. }
  3990. }
  3991. // Render color and negativeColor paths
  3992. ['graphsenkouSpanColor', 'graphsenkouSpanNegativeColor'].forEach(function (areaName, i) {
  3993. if (points[i].length && nextPoints[i].length) {
  3994. senkouSpanTempColor = i === 0 ? color : negativeColor;
  3995. drawSenkouSpan({
  3996. indicator: indicator,
  3997. points: points[i],
  3998. nextPoints: nextPoints[i],
  3999. color: senkouSpanTempColor,
  4000. options: mainLineOptions,
  4001. gap: gappedExtend,
  4002. graph: indicator[areaName]
  4003. });
  4004. // Now save line
  4005. indicator[areaName] = indicator.graph;
  4006. indicator.graphCollection.push(areaName);
  4007. }
  4008. });
  4009. }
  4010. else {
  4011. // When user set only senkouSpan style.fill property
  4012. drawSenkouSpan({
  4013. indicator: indicator,
  4014. points: ikhMap.senkouSpanB,
  4015. nextPoints: ikhMap.senkouSpanA,
  4016. color: color,
  4017. options: mainLineOptions,
  4018. gap: gappedExtend,
  4019. graph: indicator.graphsenkouSpan
  4020. });
  4021. // Now save line
  4022. indicator.graphsenkouSpan = indicator.graph;
  4023. }
  4024. // Clean temporary properties:
  4025. delete indicator.nextPoints;
  4026. delete indicator.fillGraph;
  4027. // Restore options and draw the Tenkan line:
  4028. indicator.points = mainLinePoints;
  4029. indicator.options = mainLineOptions;
  4030. indicator.graph = mainLinePath;
  4031. indicator.color = mainColor;
  4032. };
  4033. IKHIndicator.prototype.getGraphPath = function (points) {
  4034. var indicator = this,
  4035. path = [],
  4036. spanA,
  4037. spanAarr = [];
  4038. points = points || this.points;
  4039. // Render Senkou Span
  4040. if (indicator.fillGraph && indicator.nextPoints) {
  4041. spanA = SeriesRegistry.seriesTypes.sma.prototype.getGraphPath.call(indicator,
  4042. // Reverse points, so Senkou Span A will start from the end:
  4043. indicator.nextPoints);
  4044. if (spanA && spanA.length) {
  4045. spanA[0][0] = 'L';
  4046. path = SeriesRegistry.seriesTypes.sma.prototype.getGraphPath.call(indicator, points);
  4047. spanAarr = spanA.slice(0, path.length);
  4048. for (var i = spanAarr.length - 1; i >= 0; i--) {
  4049. path.push(spanAarr[i]);
  4050. }
  4051. }
  4052. }
  4053. else {
  4054. path = SeriesRegistry.seriesTypes.sma.prototype.getGraphPath.apply(indicator, arguments);
  4055. }
  4056. return path;
  4057. };
  4058. IKHIndicator.prototype.getValues = function (series, params) {
  4059. var period = params.period,
  4060. periodTenkan = params.periodTenkan,
  4061. periodSenkouSpanB = params.periodSenkouSpanB,
  4062. xVal = series.xData,
  4063. yVal = series.yData,
  4064. xAxis = series.xAxis,
  4065. yValLen = (yVal && yVal.length) || 0,
  4066. closestPointRange = getClosestPointRange(xAxis),
  4067. IKH = [],
  4068. xData = [],
  4069. dateStart,
  4070. date,
  4071. slicedTSY,
  4072. slicedKSY,
  4073. slicedSSBY,
  4074. pointTS,
  4075. pointKS,
  4076. pointSSB,
  4077. i,
  4078. TS,
  4079. KS,
  4080. CS,
  4081. SSA,
  4082. SSB;
  4083. // Ikh requires close value
  4084. if (xVal.length <= period ||
  4085. !isArray(yVal[0]) ||
  4086. yVal[0].length !== 4) {
  4087. return;
  4088. }
  4089. // Add timestamps at the beginning
  4090. dateStart = xVal[0] - period * closestPointRange;
  4091. for (i = 0; i < period; i++) {
  4092. xData.push(dateStart + i * closestPointRange);
  4093. }
  4094. for (i = 0; i < yValLen; i++) {
  4095. // Tenkan Sen
  4096. if (i >= periodTenkan) {
  4097. slicedTSY = yVal.slice(i - periodTenkan, i);
  4098. pointTS = highlowLevel(slicedTSY);
  4099. TS = (pointTS.high + pointTS.low) / 2;
  4100. }
  4101. if (i >= period) {
  4102. slicedKSY = yVal.slice(i - period, i);
  4103. pointKS = highlowLevel(slicedKSY);
  4104. KS = (pointKS.high + pointKS.low) / 2;
  4105. SSA = (TS + KS) / 2;
  4106. }
  4107. if (i >= periodSenkouSpanB) {
  4108. slicedSSBY = yVal.slice(i - periodSenkouSpanB, i);
  4109. pointSSB = highlowLevel(slicedSSBY);
  4110. SSB = (pointSSB.high + pointSSB.low) / 2;
  4111. }
  4112. CS = yVal[i][3];
  4113. date = xVal[i];
  4114. if (typeof IKH[i] === 'undefined') {
  4115. IKH[i] = [];
  4116. }
  4117. if (typeof IKH[i + period] === 'undefined') {
  4118. IKH[i + period] = [];
  4119. }
  4120. IKH[i + period][0] = TS;
  4121. IKH[i + period][1] = KS;
  4122. IKH[i + period][2] = void 0;
  4123. IKH[i][2] = CS;
  4124. if (i <= period) {
  4125. IKH[i + period][3] = void 0;
  4126. IKH[i + period][4] = void 0;
  4127. }
  4128. if (typeof IKH[i + 2 * period] === 'undefined') {
  4129. IKH[i + 2 * period] = [];
  4130. }
  4131. IKH[i + 2 * period][3] = SSA;
  4132. IKH[i + 2 * period][4] = SSB;
  4133. xData.push(date);
  4134. }
  4135. // Add timestamps for further points
  4136. for (i = 1; i <= period; i++) {
  4137. xData.push(date + i * closestPointRange);
  4138. }
  4139. return {
  4140. values: IKH,
  4141. xData: xData,
  4142. yData: IKH
  4143. };
  4144. };
  4145. /**
  4146. * Ichimoku Kinko Hyo (IKH). This series requires `linkedTo` option to be
  4147. * set.
  4148. *
  4149. * @sample stock/indicators/ichimoku-kinko-hyo
  4150. * Ichimoku Kinko Hyo indicator
  4151. *
  4152. * @extends plotOptions.sma
  4153. * @since 6.0.0
  4154. * @excluding allAreas, colorAxis, compare, compareBase, joinBy, keys,
  4155. * navigatorOptions, pointInterval, pointIntervalUnit,
  4156. * pointPlacement, pointRange, pointStart, showInNavigator,
  4157. * stacking
  4158. * @product highstock
  4159. * @requires stock/indicators/indicators
  4160. * @requires stock/indicators/ichimoku-kinko-hyo
  4161. * @optionparent plotOptions.ikh
  4162. */
  4163. IKHIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  4164. params: {
  4165. period: 26,
  4166. /**
  4167. * The base period for Tenkan calculations.
  4168. */
  4169. periodTenkan: 9,
  4170. /**
  4171. * The base period for Senkou Span B calculations
  4172. */
  4173. periodSenkouSpanB: 52
  4174. },
  4175. marker: {
  4176. enabled: false
  4177. },
  4178. tooltip: {
  4179. pointFormat: '<span style="color:{point.color}">\u25CF</span> <b> {series.name}</b><br/>' +
  4180. 'TENKAN SEN: {point.tenkanSen:.3f}<br/>' +
  4181. 'KIJUN SEN: {point.kijunSen:.3f}<br/>' +
  4182. 'CHIKOU SPAN: {point.chikouSpan:.3f}<br/>' +
  4183. 'SENKOU SPAN A: {point.senkouSpanA:.3f}<br/>' +
  4184. 'SENKOU SPAN B: {point.senkouSpanB:.3f}<br/>'
  4185. },
  4186. /**
  4187. * The styles for Tenkan line
  4188. */
  4189. tenkanLine: {
  4190. styles: {
  4191. /**
  4192. * Pixel width of the line.
  4193. */
  4194. lineWidth: 1,
  4195. /**
  4196. * Color of the line.
  4197. *
  4198. * @type {Highcharts.ColorString}
  4199. */
  4200. lineColor: void 0
  4201. }
  4202. },
  4203. /**
  4204. * The styles for Kijun line
  4205. */
  4206. kijunLine: {
  4207. styles: {
  4208. /**
  4209. * Pixel width of the line.
  4210. */
  4211. lineWidth: 1,
  4212. /**
  4213. * Color of the line.
  4214. *
  4215. * @type {Highcharts.ColorString}
  4216. */
  4217. lineColor: void 0
  4218. }
  4219. },
  4220. /**
  4221. * The styles for Chikou line
  4222. */
  4223. chikouLine: {
  4224. styles: {
  4225. /**
  4226. * Pixel width of the line.
  4227. */
  4228. lineWidth: 1,
  4229. /**
  4230. * Color of the line.
  4231. *
  4232. * @type {Highcharts.ColorString}
  4233. */
  4234. lineColor: void 0
  4235. }
  4236. },
  4237. /**
  4238. * The styles for Senkou Span A line
  4239. */
  4240. senkouSpanA: {
  4241. styles: {
  4242. /**
  4243. * Pixel width of the line.
  4244. */
  4245. lineWidth: 1,
  4246. /**
  4247. * Color of the line.
  4248. *
  4249. * @type {Highcharts.ColorString}
  4250. */
  4251. lineColor: void 0
  4252. }
  4253. },
  4254. /**
  4255. * The styles for Senkou Span B line
  4256. */
  4257. senkouSpanB: {
  4258. styles: {
  4259. /**
  4260. * Pixel width of the line.
  4261. */
  4262. lineWidth: 1,
  4263. /**
  4264. * Color of the line.
  4265. *
  4266. * @type {Highcharts.ColorString}
  4267. */
  4268. lineColor: void 0
  4269. }
  4270. },
  4271. /**
  4272. * The styles for area between Senkou Span A and B.
  4273. */
  4274. senkouSpan: {
  4275. /**
  4276. * Color of the area between Senkou Span A and B,
  4277. * when Senkou Span A is above Senkou Span B. Note that if
  4278. * a `style.fill` is defined, the `color` takes precedence and
  4279. * the `style.fill` is ignored.
  4280. *
  4281. * @see [senkouSpan.styles.fill](#series.ikh.senkouSpan.styles.fill)
  4282. *
  4283. * @sample stock/indicators/ichimoku-kinko-hyo
  4284. * Ichimoku Kinko Hyo color
  4285. *
  4286. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4287. * @since 7.0.0
  4288. * @apioption plotOptions.ikh.senkouSpan.color
  4289. */
  4290. /**
  4291. * Color of the area between Senkou Span A and B,
  4292. * when Senkou Span A is under Senkou Span B.
  4293. *
  4294. * @sample stock/indicators/ikh-negative-color
  4295. * Ichimoku Kinko Hyo negativeColor
  4296. *
  4297. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4298. * @since 7.0.0
  4299. * @apioption plotOptions.ikh.senkouSpan.negativeColor
  4300. */
  4301. styles: {
  4302. /**
  4303. * Color of the area between Senkou Span A and B.
  4304. *
  4305. * @deprecated
  4306. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4307. */
  4308. fill: 'rgba(255, 0, 0, 0.5)'
  4309. }
  4310. },
  4311. dataGrouping: {
  4312. approximation: 'ichimoku-averages'
  4313. }
  4314. });
  4315. return IKHIndicator;
  4316. }(SMAIndicator));
  4317. extend(IKHIndicator.prototype, {
  4318. pointArrayMap: [
  4319. 'tenkanSen',
  4320. 'kijunSen',
  4321. 'chikouSpan',
  4322. 'senkouSpanA',
  4323. 'senkouSpanB'
  4324. ],
  4325. pointValKey: 'tenkanSen',
  4326. nameComponents: ['periodSenkouSpanB', 'period', 'periodTenkan']
  4327. });
  4328. SeriesRegistry.registerSeriesType('ikh', IKHIndicator);
  4329. /**
  4330. * A `IKH` series. If the [type](#series.ikh.type) option is not
  4331. * specified, it is inherited from [chart.type](#chart.type).
  4332. *
  4333. * @extends series,plotOptions.ikh
  4334. * @since 6.0.0
  4335. * @product highstock
  4336. * @excluding dataParser, dataURL
  4337. * @requires stock/indicators/indicators
  4338. * @requires stock/indicators/ichimoku-kinko-hyo
  4339. * @apioption series.ikh
  4340. */
  4341. (''); // add doclet above to transpiled file
  4342. return IKHIndicator;
  4343. });
  4344. _registerModule(_modules, 'Stock/Indicators/KeltnerChannels/KeltnerChannelsIndicator.js', [_modules['Mixins/MultipleLines.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (MultipleLinesMixin, SeriesRegistry, U) {
  4345. /* *
  4346. *
  4347. * License: www.highcharts.com/license
  4348. *
  4349. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4350. *
  4351. * */
  4352. var __extends = (this && this.__extends) || (function () {
  4353. var extendStatics = function (d,
  4354. b) {
  4355. extendStatics = Object.setPrototypeOf ||
  4356. ({ __proto__: [] } instanceof Array && function (d,
  4357. b) { d.__proto__ = b; }) ||
  4358. function (d,
  4359. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4360. return extendStatics(d, b);
  4361. };
  4362. return function (d, b) {
  4363. extendStatics(d, b);
  4364. function __() { this.constructor = d; }
  4365. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4366. };
  4367. })();
  4368. var _a = SeriesRegistry.seriesTypes,
  4369. SMAIndicator = _a.sma,
  4370. EMAIndicator = _a.ema,
  4371. ATRIndicator = _a.atr;
  4372. var correctFloat = U.correctFloat,
  4373. extend = U.extend,
  4374. merge = U.merge;
  4375. /**
  4376. * The Keltner Channels series type.
  4377. *
  4378. * @private
  4379. * @class
  4380. * @name Highcharts.seriesTypes.keltnerchannels
  4381. *
  4382. * @augments Highcharts.Series
  4383. */
  4384. var KeltnerChannelsIndicator = /** @class */ (function (_super) {
  4385. __extends(KeltnerChannelsIndicator, _super);
  4386. function KeltnerChannelsIndicator() {
  4387. var _this = _super !== null && _super.apply(this,
  4388. arguments) || this;
  4389. _this.data = void 0;
  4390. _this.options = void 0;
  4391. _this.points = void 0;
  4392. return _this;
  4393. }
  4394. KeltnerChannelsIndicator.prototype.init = function () {
  4395. SeriesRegistry.seriesTypes.sma.prototype.init.apply(this, arguments);
  4396. // Set default color for lines:
  4397. this.options = merge({
  4398. topLine: {
  4399. styles: {
  4400. lineColor: this.color
  4401. }
  4402. },
  4403. bottomLine: {
  4404. styles: {
  4405. lineColor: this.color
  4406. }
  4407. }
  4408. }, this.options);
  4409. };
  4410. KeltnerChannelsIndicator.prototype.getValues = function (series, params) {
  4411. var period = params.period,
  4412. periodATR = params.periodATR,
  4413. multiplierATR = params.multiplierATR,
  4414. index = params.index,
  4415. yVal = series.yData,
  4416. yValLen = yVal ? yVal.length : 0,
  4417. // Keltner Channels array structure:
  4418. // 0-date, 1-top line, 2-middle line, 3-bottom line
  4419. KC = [],
  4420. // middle line, top line and bottom lineI
  4421. ML,
  4422. TL,
  4423. BL,
  4424. date,
  4425. seriesEMA = SeriesRegistry.seriesTypes.ema.prototype.getValues(series, {
  4426. period: period,
  4427. index: index
  4428. }),
  4429. seriesATR = SeriesRegistry.seriesTypes.atr.prototype.getValues(series, {
  4430. period: periodATR
  4431. }),
  4432. pointEMA,
  4433. pointATR,
  4434. xData = [],
  4435. yData = [],
  4436. i;
  4437. if (yValLen < period) {
  4438. return;
  4439. }
  4440. for (i = period; i <= yValLen; i++) {
  4441. pointEMA = seriesEMA.values[i - period];
  4442. pointATR = seriesATR.values[i - periodATR];
  4443. date = pointEMA[0];
  4444. TL = correctFloat(pointEMA[1] + (multiplierATR * pointATR[1]));
  4445. BL = correctFloat(pointEMA[1] - (multiplierATR * pointATR[1]));
  4446. ML = pointEMA[1];
  4447. KC.push([date, TL, ML, BL]);
  4448. xData.push(date);
  4449. yData.push([TL, ML, BL]);
  4450. }
  4451. return {
  4452. values: KC,
  4453. xData: xData,
  4454. yData: yData
  4455. };
  4456. };
  4457. /**
  4458. * Keltner Channels. This series requires the `linkedTo` option to be set
  4459. * and should be loaded after the `stock/indicators/indicators.js`,
  4460. * `stock/indicators/atr.js`, and `stock/ema/.js`.
  4461. *
  4462. * @sample {highstock} stock/indicators/keltner-channels
  4463. * Keltner Channels
  4464. *
  4465. * @extends plotOptions.sma
  4466. * @since 7.0.0
  4467. * @product highstock
  4468. * @excluding allAreas, colorAxis, compare, compareBase, joinBy, keys,
  4469. * navigatorOptions, pointInterval, pointIntervalUnit,
  4470. * pointPlacement, pointRange, pointStart,showInNavigator,
  4471. * stacking
  4472. * @requires stock/indicators/indicators
  4473. * @requires stock/indicators/keltner-channels
  4474. * @optionparent plotOptions.keltnerchannels
  4475. */
  4476. KeltnerChannelsIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  4477. params: {
  4478. period: 20,
  4479. /**
  4480. * The ATR period.
  4481. */
  4482. periodATR: 10,
  4483. /**
  4484. * The ATR multiplier.
  4485. */
  4486. multiplierATR: 2
  4487. },
  4488. /**
  4489. * Bottom line options.
  4490. *
  4491. */
  4492. bottomLine: {
  4493. /**
  4494. * Styles for a bottom line.
  4495. *
  4496. */
  4497. styles: {
  4498. /**
  4499. * Pixel width of the line.
  4500. */
  4501. lineWidth: 1,
  4502. /**
  4503. * Color of the line. If not set, it's inherited from
  4504. * `plotOptions.keltnerchannels.color`
  4505. */
  4506. lineColor: void 0
  4507. }
  4508. },
  4509. /**
  4510. * Top line options.
  4511. *
  4512. * @extends plotOptions.keltnerchannels.bottomLine
  4513. */
  4514. topLine: {
  4515. styles: {
  4516. lineWidth: 1,
  4517. lineColor: void 0
  4518. }
  4519. },
  4520. tooltip: {
  4521. pointFormat: '<span style="color:{point.color}">\u25CF</span><b> {series.name}</b><br/>Upper Channel: {point.top}<br/>EMA({series.options.params.period}): {point.middle}<br/>Lower Channel: {point.bottom}<br/>'
  4522. },
  4523. marker: {
  4524. enabled: false
  4525. },
  4526. dataGrouping: {
  4527. approximation: 'averages'
  4528. },
  4529. lineWidth: 1
  4530. });
  4531. return KeltnerChannelsIndicator;
  4532. }(SMAIndicator));
  4533. extend(KeltnerChannelsIndicator.prototype, {
  4534. pointArrayMap: ['top', 'middle', 'bottom'],
  4535. pointValKey: 'middle',
  4536. nameBase: 'Keltner Channels',
  4537. nameComponents: ['period', 'periodATR', 'multiplierATR'],
  4538. linesApiNames: ['topLine', 'bottomLine'],
  4539. requiredIndicators: ['ema', 'atr'],
  4540. drawGraph: MultipleLinesMixin.drawGraph,
  4541. getTranslatedLinesNames: MultipleLinesMixin.getTranslatedLinesNames,
  4542. translate: MultipleLinesMixin.translate,
  4543. toYData: MultipleLinesMixin.toYData
  4544. });
  4545. SeriesRegistry.registerSeriesType('keltnerchannels', KeltnerChannelsIndicator);
  4546. /* *
  4547. *
  4548. * Default Export
  4549. *
  4550. * */
  4551. /**
  4552. * A Keltner Channels indicator. If the [type](#series.keltnerchannels.type)
  4553. * option is not specified, it is inherited from[chart.type](#chart.type).
  4554. *
  4555. * @extends series,plotOptions.sma
  4556. * @since 7.0.0
  4557. * @product highstock
  4558. * @excluding allAreas, colorAxis, compare, compareBase, dataParser, dataURL,
  4559. * joinBy, keys, navigatorOptions, pointInterval,
  4560. * pointIntervalUnit, pointPlacement, pointRange, pointStart,
  4561. * stacking, showInNavigator
  4562. * @requires stock/indicators/indicators
  4563. * @requires stock/indicators/keltner-channels
  4564. * @apioption series.keltnerchannels
  4565. */
  4566. ''; // to include the above in the js output
  4567. return KeltnerChannelsIndicator;
  4568. });
  4569. _registerModule(_modules, 'Stock/Indicators/MACD/MACDIndicator.js', [_modules['Core/Globals.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (H, SeriesRegistry, U) {
  4570. /* *
  4571. *
  4572. * License: www.highcharts.com/license
  4573. *
  4574. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4575. *
  4576. * */
  4577. var __extends = (this && this.__extends) || (function () {
  4578. var extendStatics = function (d,
  4579. b) {
  4580. extendStatics = Object.setPrototypeOf ||
  4581. ({ __proto__: [] } instanceof Array && function (d,
  4582. b) { d.__proto__ = b; }) ||
  4583. function (d,
  4584. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  4585. return extendStatics(d, b);
  4586. };
  4587. return function (d, b) {
  4588. extendStatics(d, b);
  4589. function __() { this.constructor = d; }
  4590. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  4591. };
  4592. })();
  4593. var noop = H.noop;
  4594. var _a = SeriesRegistry.seriesTypes,
  4595. SMAIndicator = _a.sma,
  4596. EMAIndicator = _a.ema,
  4597. ColumnSeries = _a.column;
  4598. var extend = U.extend,
  4599. correctFloat = U.correctFloat,
  4600. defined = U.defined,
  4601. merge = U.merge;
  4602. /**
  4603. *
  4604. * Class
  4605. *
  4606. */
  4607. /**
  4608. * The MACD series type.
  4609. *
  4610. * @private
  4611. * @class
  4612. * @name Highcharts.seriesTypes.macd
  4613. *
  4614. * @augments Highcharts.Series
  4615. */
  4616. var MACDIndicator = /** @class */ (function (_super) {
  4617. __extends(MACDIndicator, _super);
  4618. function MACDIndicator() {
  4619. var _this = _super !== null && _super.apply(this,
  4620. arguments) || this;
  4621. /**
  4622. *
  4623. * Properties
  4624. *
  4625. */
  4626. _this.data = void 0;
  4627. _this.options = void 0;
  4628. _this.points = void 0;
  4629. _this.currentLineZone = void 0;
  4630. _this.graphmacd = void 0;
  4631. _this.graphsignal = void 0;
  4632. _this.macdZones = void 0;
  4633. _this.signalZones = void 0;
  4634. return _this;
  4635. }
  4636. /**
  4637. *
  4638. * Functions
  4639. *
  4640. */
  4641. MACDIndicator.prototype.init = function () {
  4642. SeriesRegistry.seriesTypes.sma.prototype.init.apply(this, arguments);
  4643. // Check whether series is initialized. It may be not initialized,
  4644. // when any of required indicators is missing.
  4645. if (this.options) {
  4646. // Set default color for a signal line and the histogram:
  4647. this.options = merge({
  4648. signalLine: {
  4649. styles: {
  4650. lineColor: this.color
  4651. }
  4652. },
  4653. macdLine: {
  4654. styles: {
  4655. color: this.color
  4656. }
  4657. }
  4658. }, this.options);
  4659. // Zones have indexes automatically calculated, we need to
  4660. // translate them to support multiple lines within one indicator
  4661. this.macdZones = {
  4662. zones: this.options.macdLine.zones,
  4663. startIndex: 0
  4664. };
  4665. this.signalZones = {
  4666. zones: this.macdZones.zones.concat(this.options.signalLine.zones),
  4667. startIndex: this.macdZones.zones.length
  4668. };
  4669. this.resetZones = true;
  4670. }
  4671. };
  4672. MACDIndicator.prototype.toYData = function (point) {
  4673. return [point.y, point.signal, point.MACD];
  4674. };
  4675. MACDIndicator.prototype.translate = function () {
  4676. var indicator = this, plotNames = ['plotSignal', 'plotMACD'];
  4677. H.seriesTypes.column.prototype.translate.apply(indicator);
  4678. indicator.points.forEach(function (point) {
  4679. [point.signal, point.MACD].forEach(function (value, i) {
  4680. if (value !== null) {
  4681. point[plotNames[i]] =
  4682. indicator.yAxis.toPixels(value, true);
  4683. }
  4684. });
  4685. });
  4686. };
  4687. MACDIndicator.prototype.destroy = function () {
  4688. // this.graph is null due to removing two times the same SVG element
  4689. this.graph = null;
  4690. this.graphmacd = this.graphmacd && this.graphmacd.destroy();
  4691. this.graphsignal = this.graphsignal && this.graphsignal.destroy();
  4692. SeriesRegistry.seriesTypes.sma.prototype.destroy.apply(this, arguments);
  4693. };
  4694. MACDIndicator.prototype.drawGraph = function () {
  4695. var indicator = this,
  4696. mainLinePoints = indicator.points,
  4697. pointsLength = mainLinePoints.length,
  4698. mainLineOptions = indicator.options,
  4699. histogramZones = indicator.zones,
  4700. gappedExtend = {
  4701. options: {
  4702. gapSize: mainLineOptions.gapSize
  4703. }
  4704. },
  4705. otherSignals = [[],
  4706. []],
  4707. point;
  4708. // Generate points for top and bottom lines:
  4709. while (pointsLength--) {
  4710. point = mainLinePoints[pointsLength];
  4711. if (defined(point.plotMACD)) {
  4712. otherSignals[0].push({
  4713. plotX: point.plotX,
  4714. plotY: point.plotMACD,
  4715. isNull: !defined(point.plotMACD)
  4716. });
  4717. }
  4718. if (defined(point.plotSignal)) {
  4719. otherSignals[1].push({
  4720. plotX: point.plotX,
  4721. plotY: point.plotSignal,
  4722. isNull: !defined(point.plotMACD)
  4723. });
  4724. }
  4725. }
  4726. // Modify options and generate smoothing line:
  4727. ['macd', 'signal'].forEach(function (lineName, i) {
  4728. indicator.points = otherSignals[i];
  4729. indicator.options = merge(mainLineOptions[lineName + 'Line'].styles, gappedExtend);
  4730. indicator.graph = indicator['graph' + lineName];
  4731. // Zones extension:
  4732. indicator.currentLineZone = lineName + 'Zones';
  4733. indicator.zones =
  4734. indicator[indicator.currentLineZone].zones;
  4735. SeriesRegistry.seriesTypes.sma.prototype.drawGraph.call(indicator);
  4736. indicator['graph' + lineName] = indicator.graph;
  4737. });
  4738. // Restore options:
  4739. indicator.points = mainLinePoints;
  4740. indicator.options = mainLineOptions;
  4741. indicator.zones = histogramZones;
  4742. indicator.currentLineZone = null;
  4743. // indicator.graph = null;
  4744. };
  4745. MACDIndicator.prototype.getZonesGraphs = function (props) {
  4746. var allZones = _super.prototype.getZonesGraphs.call(this,
  4747. props),
  4748. currentZones = allZones;
  4749. if (this.currentLineZone) {
  4750. currentZones = allZones.splice(this[this.currentLineZone].startIndex + 1);
  4751. if (!currentZones.length) {
  4752. // Line has no zones, return basic graph "zone"
  4753. currentZones = [props[0]];
  4754. }
  4755. else {
  4756. // Add back basic prop:
  4757. currentZones.splice(0, 0, props[0]);
  4758. }
  4759. }
  4760. return currentZones;
  4761. };
  4762. MACDIndicator.prototype.applyZones = function () {
  4763. // Histogram zones are handled by drawPoints method
  4764. // Here we need to apply zones for all lines
  4765. var histogramZones = this.zones;
  4766. // signalZones.zones contains all zones:
  4767. this.zones = this.signalZones.zones;
  4768. SeriesRegistry.seriesTypes.sma.prototype.applyZones.call(this);
  4769. // applyZones hides only main series.graph, hide macd line manually
  4770. if (this.graphmacd && this.options.macdLine.zones.length) {
  4771. this.graphmacd.hide();
  4772. }
  4773. this.zones = histogramZones;
  4774. };
  4775. MACDIndicator.prototype.getValues = function (series, params) {
  4776. var j = 0,
  4777. MACD = [],
  4778. xMACD = [],
  4779. yMACD = [],
  4780. signalLine = [],
  4781. shortEMA,
  4782. longEMA,
  4783. i;
  4784. if (series.xData.length <
  4785. params.longPeriod + params.signalPeriod) {
  4786. return;
  4787. }
  4788. // Calculating the short and long EMA used when calculating the MACD
  4789. shortEMA = SeriesRegistry.seriesTypes.ema.prototype.getValues(series, {
  4790. period: params.shortPeriod,
  4791. index: params.index
  4792. });
  4793. longEMA = SeriesRegistry.seriesTypes.ema.prototype.getValues(series, {
  4794. period: params.longPeriod,
  4795. index: params.index
  4796. });
  4797. shortEMA = shortEMA.values;
  4798. longEMA = longEMA.values;
  4799. // Subtract each Y value from the EMA's and create the new dataset
  4800. // (MACD)
  4801. for (i = 1; i <= shortEMA.length; i++) {
  4802. if (defined(longEMA[i - 1]) &&
  4803. defined(longEMA[i - 1][1]) &&
  4804. defined(shortEMA[i + params.shortPeriod + 1]) &&
  4805. defined(shortEMA[i + params.shortPeriod + 1][0])) {
  4806. MACD.push([
  4807. shortEMA[i + params.shortPeriod + 1][0],
  4808. 0,
  4809. null,
  4810. shortEMA[i + params.shortPeriod + 1][1] -
  4811. longEMA[i - 1][1]
  4812. ]);
  4813. }
  4814. }
  4815. // Set the Y and X data of the MACD. This is used in calculating the
  4816. // signal line.
  4817. for (i = 0; i < MACD.length; i++) {
  4818. xMACD.push(MACD[i][0]);
  4819. yMACD.push([0, null, MACD[i][3]]);
  4820. }
  4821. // Setting the signalline (Signal Line: X-day EMA of MACD line).
  4822. signalLine = SeriesRegistry.seriesTypes.ema.prototype.getValues({
  4823. xData: xMACD,
  4824. yData: yMACD
  4825. }, {
  4826. period: params.signalPeriod,
  4827. index: 2
  4828. });
  4829. signalLine = signalLine.values;
  4830. // Setting the MACD Histogram. In comparison to the loop with pure
  4831. // MACD this loop uses MACD x value not xData.
  4832. for (i = 0; i < MACD.length; i++) {
  4833. // detect the first point
  4834. if (MACD[i][0] >= signalLine[0][0]) {
  4835. MACD[i][2] = signalLine[j][1];
  4836. yMACD[i] = [0, signalLine[j][1], MACD[i][3]];
  4837. if (MACD[i][3] === null) {
  4838. MACD[i][1] = 0;
  4839. yMACD[i][0] = 0;
  4840. }
  4841. else {
  4842. MACD[i][1] = correctFloat(MACD[i][3] -
  4843. signalLine[j][1]);
  4844. yMACD[i][0] = correctFloat(MACD[i][3] -
  4845. signalLine[j][1]);
  4846. }
  4847. j++;
  4848. }
  4849. }
  4850. return {
  4851. values: MACD,
  4852. xData: xMACD,
  4853. yData: yMACD
  4854. };
  4855. };
  4856. /**
  4857. * Moving Average Convergence Divergence (MACD). This series requires
  4858. * `linkedTo` option to be set and should be loaded after the
  4859. * `stock/indicators/indicators.js` and `stock/indicators/ema.js`.
  4860. *
  4861. * @sample stock/indicators/macd
  4862. * MACD indicator
  4863. *
  4864. * @extends plotOptions.sma
  4865. * @since 6.0.0
  4866. * @product highstock
  4867. * @requires stock/indicators/indicators
  4868. * @requires stock/indicators/macd
  4869. * @optionparent plotOptions.macd
  4870. */
  4871. MACDIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  4872. params: {
  4873. /**
  4874. * The short period for indicator calculations.
  4875. */
  4876. shortPeriod: 12,
  4877. /**
  4878. * The long period for indicator calculations.
  4879. */
  4880. longPeriod: 26,
  4881. /**
  4882. * The base period for signal calculations.
  4883. */
  4884. signalPeriod: 9,
  4885. period: 26
  4886. },
  4887. /**
  4888. * The styles for signal line
  4889. */
  4890. signalLine: {
  4891. /**
  4892. * @sample stock/indicators/macd-zones
  4893. * Zones in MACD
  4894. *
  4895. * @extends plotOptions.macd.zones
  4896. */
  4897. zones: [],
  4898. styles: {
  4899. /**
  4900. * Pixel width of the line.
  4901. */
  4902. lineWidth: 1,
  4903. /**
  4904. * Color of the line.
  4905. *
  4906. * @type {Highcharts.ColorString}
  4907. */
  4908. lineColor: void 0
  4909. }
  4910. },
  4911. /**
  4912. * The styles for macd line
  4913. */
  4914. macdLine: {
  4915. /**
  4916. * @sample stock/indicators/macd-zones
  4917. * Zones in MACD
  4918. *
  4919. * @extends plotOptions.macd.zones
  4920. */
  4921. zones: [],
  4922. styles: {
  4923. /**
  4924. * Pixel width of the line.
  4925. */
  4926. lineWidth: 1,
  4927. /**
  4928. * Color of the line.
  4929. *
  4930. * @type {Highcharts.ColorString}
  4931. */
  4932. lineColor: void 0
  4933. }
  4934. },
  4935. /**
  4936. * @type {number|null}
  4937. */
  4938. threshold: 0,
  4939. groupPadding: 0.1,
  4940. pointPadding: 0.1,
  4941. crisp: false,
  4942. states: {
  4943. hover: {
  4944. halo: {
  4945. size: 0
  4946. }
  4947. }
  4948. },
  4949. tooltip: {
  4950. pointFormat: '<span style="color:{point.color}">\u25CF</span> <b> {series.name}</b><br/>' +
  4951. 'Value: {point.MACD}<br/>' +
  4952. 'Signal: {point.signal}<br/>' +
  4953. 'Histogram: {point.y}<br/>'
  4954. },
  4955. dataGrouping: {
  4956. approximation: 'averages'
  4957. },
  4958. minPointLength: 0
  4959. });
  4960. return MACDIndicator;
  4961. }(SMAIndicator));
  4962. extend(MACDIndicator.prototype, {
  4963. nameComponents: ['longPeriod', 'shortPeriod', 'signalPeriod'],
  4964. requiredIndicators: ['ema'],
  4965. // "y" value is treated as Histogram data
  4966. pointArrayMap: ['y', 'signal', 'MACD'],
  4967. parallelArrays: ['x', 'y', 'signal', 'MACD'],
  4968. pointValKey: 'y',
  4969. // Columns support:
  4970. markerAttribs: noop,
  4971. getColumnMetrics: H.seriesTypes.column.prototype.getColumnMetrics,
  4972. crispCol: H.seriesTypes.column.prototype.crispCol,
  4973. drawPoints: H.seriesTypes.column.prototype.drawPoints
  4974. });
  4975. SeriesRegistry.registerSeriesType('macd', MACDIndicator);
  4976. /* *
  4977. *
  4978. * Default Export
  4979. *
  4980. * */
  4981. /**
  4982. * A `MACD` series. If the [type](#series.macd.type) option is not
  4983. * specified, it is inherited from [chart.type](#chart.type).
  4984. *
  4985. * @extends series,plotOptions.macd
  4986. * @since 6.0.0
  4987. * @product highstock
  4988. * @excluding dataParser, dataURL
  4989. * @requires stock/indicators/indicators
  4990. * @requires stock/indicators/macd
  4991. * @apioption series.macd
  4992. */
  4993. ''; // to include the above in the js output
  4994. return MACDIndicator;
  4995. });
  4996. _registerModule(_modules, 'Stock/Indicators/MFI/MFIIndicator.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  4997. /* *
  4998. *
  4999. * Money Flow Index indicator for Highstock
  5000. *
  5001. * (c) 2010-2021 Grzegorz Blachliński
  5002. *
  5003. * License: www.highcharts.com/license
  5004. *
  5005. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  5006. *
  5007. * */
  5008. var __extends = (this && this.__extends) || (function () {
  5009. var extendStatics = function (d,
  5010. b) {
  5011. extendStatics = Object.setPrototypeOf ||
  5012. ({ __proto__: [] } instanceof Array && function (d,
  5013. b) { d.__proto__ = b; }) ||
  5014. function (d,
  5015. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5016. return extendStatics(d, b);
  5017. };
  5018. return function (d, b) {
  5019. extendStatics(d, b);
  5020. function __() { this.constructor = d; }
  5021. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5022. };
  5023. })();
  5024. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  5025. var extend = U.extend,
  5026. merge = U.merge,
  5027. error = U.error,
  5028. isArray = U.isArray;
  5029. /* eslint-disable require-jsdoc */
  5030. // Utils:
  5031. function sumArray(array) {
  5032. return array.reduce(function (prev, cur) {
  5033. return prev + cur;
  5034. });
  5035. }
  5036. function toFixed(a, n) {
  5037. return parseFloat(a.toFixed(n));
  5038. }
  5039. function calculateTypicalPrice(point) {
  5040. return (point[1] + point[2] + point[3]) / 3;
  5041. }
  5042. function calculateRawMoneyFlow(typicalPrice, volume) {
  5043. return typicalPrice * volume;
  5044. }
  5045. /* eslint-enable require-jsdoc */
  5046. /* *
  5047. *
  5048. * Class
  5049. *
  5050. * */
  5051. /**
  5052. * The MFI series type.
  5053. *
  5054. * @private
  5055. * @class
  5056. * @name Highcharts.seriesTypes.mfi
  5057. *
  5058. * @augments Highcharts.Series
  5059. */
  5060. var MFIIndicator = /** @class */ (function (_super) {
  5061. __extends(MFIIndicator, _super);
  5062. function MFIIndicator() {
  5063. var _this = _super !== null && _super.apply(this,
  5064. arguments) || this;
  5065. /* *
  5066. *
  5067. * Properties
  5068. *
  5069. * */
  5070. _this.data = void 0;
  5071. _this.options = void 0;
  5072. _this.points = void 0;
  5073. return _this;
  5074. }
  5075. /* *
  5076. *
  5077. * Functions
  5078. *
  5079. * */
  5080. MFIIndicator.prototype.getValues = function (series, params) {
  5081. var period = params.period,
  5082. xVal = series.xData,
  5083. yVal = series.yData,
  5084. yValLen = yVal ? yVal.length : 0,
  5085. decimals = params.decimals,
  5086. // MFI starts calculations from the second point
  5087. // Cause we need to calculate change between two points
  5088. range = 1,
  5089. volumeSeries = series.chart.get(params.volumeSeriesID),
  5090. yValVolume = (volumeSeries && volumeSeries.yData),
  5091. MFI = [],
  5092. isUp = false,
  5093. xData = [],
  5094. yData = [],
  5095. positiveMoneyFlow = [],
  5096. negativeMoneyFlow = [],
  5097. newTypicalPrice,
  5098. oldTypicalPrice,
  5099. rawMoneyFlow,
  5100. negativeMoneyFlowSum,
  5101. positiveMoneyFlowSum,
  5102. moneyFlowRatio,
  5103. MFIPoint,
  5104. i;
  5105. if (!volumeSeries) {
  5106. error('Series ' +
  5107. params.volumeSeriesID +
  5108. ' not found! Check `volumeSeriesID`.', true, series.chart);
  5109. return;
  5110. }
  5111. // MFI requires high low and close values
  5112. if ((xVal.length <= period) || !isArray(yVal[0]) ||
  5113. yVal[0].length !== 4 ||
  5114. !yValVolume) {
  5115. return;
  5116. }
  5117. // Calculate first typical price
  5118. newTypicalPrice = calculateTypicalPrice(yVal[range]);
  5119. // Accumulate first N-points
  5120. while (range < period + 1) {
  5121. // Calculate if up or down
  5122. oldTypicalPrice = newTypicalPrice;
  5123. newTypicalPrice = calculateTypicalPrice(yVal[range]);
  5124. isUp = newTypicalPrice >= oldTypicalPrice;
  5125. // Calculate raw money flow
  5126. rawMoneyFlow = calculateRawMoneyFlow(newTypicalPrice, yValVolume[range]);
  5127. // Add to array
  5128. positiveMoneyFlow.push(isUp ? rawMoneyFlow : 0);
  5129. negativeMoneyFlow.push(isUp ? 0 : rawMoneyFlow);
  5130. range++;
  5131. }
  5132. for (i = range - 1; i < yValLen; i++) {
  5133. if (i > range - 1) {
  5134. // Remove first point from array
  5135. positiveMoneyFlow.shift();
  5136. negativeMoneyFlow.shift();
  5137. // Calculate if up or down
  5138. oldTypicalPrice = newTypicalPrice;
  5139. newTypicalPrice = calculateTypicalPrice(yVal[i]);
  5140. isUp = newTypicalPrice > oldTypicalPrice;
  5141. // Calculate raw money flow
  5142. rawMoneyFlow = calculateRawMoneyFlow(newTypicalPrice, yValVolume[i]);
  5143. // Add to array
  5144. positiveMoneyFlow.push(isUp ? rawMoneyFlow : 0);
  5145. negativeMoneyFlow.push(isUp ? 0 : rawMoneyFlow);
  5146. }
  5147. // Calculate sum of negative and positive money flow:
  5148. negativeMoneyFlowSum = sumArray(negativeMoneyFlow);
  5149. positiveMoneyFlowSum = sumArray(positiveMoneyFlow);
  5150. moneyFlowRatio = positiveMoneyFlowSum / negativeMoneyFlowSum;
  5151. MFIPoint = toFixed(100 - (100 / (1 + moneyFlowRatio)), decimals);
  5152. MFI.push([xVal[i], MFIPoint]);
  5153. xData.push(xVal[i]);
  5154. yData.push(MFIPoint);
  5155. }
  5156. return {
  5157. values: MFI,
  5158. xData: xData,
  5159. yData: yData
  5160. };
  5161. };
  5162. /**
  5163. * Money Flow Index. This series requires `linkedTo` option to be set and
  5164. * should be loaded after the `stock/indicators/indicators.js` file.
  5165. *
  5166. * @sample stock/indicators/mfi
  5167. * Money Flow Index Indicator
  5168. *
  5169. * @extends plotOptions.sma
  5170. * @since 6.0.0
  5171. * @product highstock
  5172. * @requires stock/indicators/indicators
  5173. * @requires stock/indicators/mfi
  5174. * @optionparent plotOptions.mfi
  5175. */
  5176. MFIIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  5177. /**
  5178. * @excluding index
  5179. */
  5180. params: {
  5181. period: 14,
  5182. /**
  5183. * The id of volume series which is mandatory.
  5184. * For example using OHLC data, volumeSeriesID='volume' means
  5185. * the indicator will be calculated using OHLC and volume values.
  5186. */
  5187. volumeSeriesID: 'volume',
  5188. /**
  5189. * Number of maximum decimals that are used in MFI calculations.
  5190. */
  5191. decimals: 4
  5192. }
  5193. });
  5194. return MFIIndicator;
  5195. }(SMAIndicator));
  5196. extend(MFIIndicator.prototype, {
  5197. nameBase: 'Money Flow Index'
  5198. });
  5199. SeriesRegistry.registerSeriesType('mfi', MFIIndicator);
  5200. /* *
  5201. *
  5202. * Default Export
  5203. *
  5204. * */
  5205. /**
  5206. * A `MFI` series. If the [type](#series.mfi.type) option is not specified, it
  5207. * is inherited from [chart.type](#chart.type).
  5208. *
  5209. * @extends series,plotOptions.mfi
  5210. * @since 6.0.0
  5211. * @excluding dataParser, dataURL
  5212. * @product highstock
  5213. * @requires stock/indicators/indicators
  5214. * @requires stock/indicators/mfi
  5215. * @apioption series.mfi
  5216. */
  5217. ''; // to include the above in the js output
  5218. return MFIIndicator;
  5219. });
  5220. _registerModule(_modules, 'Stock/Indicators/Momentum/MomentumIndicator.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  5221. /* *
  5222. *
  5223. * License: www.highcharts.com/license
  5224. *
  5225. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  5226. *
  5227. * */
  5228. var __extends = (this && this.__extends) || (function () {
  5229. var extendStatics = function (d,
  5230. b) {
  5231. extendStatics = Object.setPrototypeOf ||
  5232. ({ __proto__: [] } instanceof Array && function (d,
  5233. b) { d.__proto__ = b; }) ||
  5234. function (d,
  5235. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5236. return extendStatics(d, b);
  5237. };
  5238. return function (d, b) {
  5239. extendStatics(d, b);
  5240. function __() { this.constructor = d; }
  5241. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5242. };
  5243. })();
  5244. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  5245. var extend = U.extend,
  5246. isArray = U.isArray,
  5247. merge = U.merge;
  5248. /* eslint-disable require-jsdoc */
  5249. function populateAverage(points, xVal, yVal, i, period) {
  5250. var mmY = yVal[i - 1][3] - yVal[i - period - 1][3],
  5251. mmX = xVal[i - 1];
  5252. points.shift(); // remove point until range < period
  5253. return [mmX, mmY];
  5254. }
  5255. /* eslint-enable require-jsdoc */
  5256. /**
  5257. * The Momentum series type.
  5258. *
  5259. * @private
  5260. * @class
  5261. * @name Highcharts.seriesTypes.momentum
  5262. *
  5263. * @augments Highcharts.Series
  5264. */
  5265. var MomentumIndicator = /** @class */ (function (_super) {
  5266. __extends(MomentumIndicator, _super);
  5267. function MomentumIndicator() {
  5268. var _this = _super !== null && _super.apply(this,
  5269. arguments) || this;
  5270. _this.data = void 0;
  5271. _this.options = void 0;
  5272. _this.points = void 0;
  5273. return _this;
  5274. }
  5275. MomentumIndicator.prototype.getValues = function (series, params) {
  5276. var period = params.period,
  5277. xVal = series.xData,
  5278. yVal = series.yData,
  5279. yValLen = yVal ? yVal.length : 0,
  5280. xValue = xVal[0],
  5281. yValue = yVal[0],
  5282. MM = [],
  5283. xData = [],
  5284. yData = [],
  5285. index,
  5286. i,
  5287. points,
  5288. MMPoint;
  5289. if (xVal.length <= period) {
  5290. return;
  5291. }
  5292. // Switch index for OHLC / Candlestick / Arearange
  5293. if (isArray(yVal[0])) {
  5294. yValue = yVal[0][3];
  5295. }
  5296. else {
  5297. return;
  5298. }
  5299. // Starting point
  5300. points = [
  5301. [xValue, yValue]
  5302. ];
  5303. // Calculate value one-by-one for each period in visible data
  5304. for (i = (period + 1); i < yValLen; i++) {
  5305. MMPoint = populateAverage(points, xVal, yVal, i, period, index);
  5306. MM.push(MMPoint);
  5307. xData.push(MMPoint[0]);
  5308. yData.push(MMPoint[1]);
  5309. }
  5310. MMPoint = populateAverage(points, xVal, yVal, i, period, index);
  5311. MM.push(MMPoint);
  5312. xData.push(MMPoint[0]);
  5313. yData.push(MMPoint[1]);
  5314. return {
  5315. values: MM,
  5316. xData: xData,
  5317. yData: yData
  5318. };
  5319. };
  5320. /**
  5321. * Momentum. This series requires `linkedTo` option to be set.
  5322. *
  5323. * @sample stock/indicators/momentum
  5324. * Momentum indicator
  5325. *
  5326. * @extends plotOptions.sma
  5327. * @since 6.0.0
  5328. * @product highstock
  5329. * @requires stock/indicators/indicators
  5330. * @requires stock/indicators/momentum
  5331. * @optionparent plotOptions.momentum
  5332. */
  5333. MomentumIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  5334. params: {
  5335. period: 14
  5336. }
  5337. });
  5338. return MomentumIndicator;
  5339. }(SMAIndicator));
  5340. extend(MomentumIndicator.prototype, {
  5341. nameBase: 'Momentum'
  5342. });
  5343. SeriesRegistry.registerSeriesType('momentum', MomentumIndicator);
  5344. /* *
  5345. *
  5346. * Default Export
  5347. *
  5348. * */
  5349. /**
  5350. * A `Momentum` series. If the [type](#series.momentum.type) option is not
  5351. * specified, it is inherited from [chart.type](#chart.type).
  5352. *
  5353. * @extends series,plotOptions.momentum
  5354. * @since 6.0.0
  5355. * @excluding dataParser, dataURL
  5356. * @product highstock
  5357. * @requires stock/indicators/indicators
  5358. * @requires stock/indicators/momentum
  5359. * @apioption series.momentum
  5360. */
  5361. ''; // to include the above in the js output
  5362. return MomentumIndicator;
  5363. });
  5364. _registerModule(_modules, 'Stock/Indicators/NATR/NATRIndicator.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  5365. /* *
  5366. *
  5367. * License: www.highcharts.com/license
  5368. *
  5369. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  5370. *
  5371. * */
  5372. var __extends = (this && this.__extends) || (function () {
  5373. var extendStatics = function (d,
  5374. b) {
  5375. extendStatics = Object.setPrototypeOf ||
  5376. ({ __proto__: [] } instanceof Array && function (d,
  5377. b) { d.__proto__ = b; }) ||
  5378. function (d,
  5379. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5380. return extendStatics(d, b);
  5381. };
  5382. return function (d, b) {
  5383. extendStatics(d, b);
  5384. function __() { this.constructor = d; }
  5385. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5386. };
  5387. })();
  5388. var ATRIndicator = SeriesRegistry.seriesTypes.atr;
  5389. var merge = U.merge,
  5390. extend = U.extend;
  5391. /**
  5392. * The NATR series type.
  5393. *
  5394. * @private
  5395. * @class
  5396. * @name Highcharts.seriesTypes.natr
  5397. *
  5398. * @augments Highcharts.Series
  5399. */
  5400. var NATRIndicator = /** @class */ (function (_super) {
  5401. __extends(NATRIndicator, _super);
  5402. function NATRIndicator() {
  5403. var _this = _super !== null && _super.apply(this,
  5404. arguments) || this;
  5405. /**
  5406. * @lends Highcharts.Series#
  5407. */
  5408. /* *
  5409. *
  5410. * Properties
  5411. *
  5412. * */
  5413. _this.data = void 0;
  5414. _this.points = void 0;
  5415. _this.options = void 0;
  5416. return _this;
  5417. }
  5418. /* *
  5419. *
  5420. * Functions
  5421. *
  5422. * */
  5423. NATRIndicator.prototype.getValues = function (series, params) {
  5424. var atrData = (ATRIndicator.prototype.getValues.apply(this,
  5425. arguments)),
  5426. atrLength = atrData.values.length,
  5427. period = params.period - 1,
  5428. yVal = series.yData,
  5429. i = 0;
  5430. if (!atrData) {
  5431. return;
  5432. }
  5433. for (; i < atrLength; i++) {
  5434. atrData.yData[i] = (atrData.values[i][1] / yVal[period][3] * 100);
  5435. atrData.values[i][1] = atrData.yData[i];
  5436. period++;
  5437. }
  5438. return atrData;
  5439. };
  5440. /**
  5441. * Normalized average true range indicator (NATR). This series requires
  5442. * `linkedTo` option to be set and should be loaded after the
  5443. * `stock/indicators/indicators.js` and `stock/indicators/atr.js`.
  5444. *
  5445. * @sample {highstock} stock/indicators/natr
  5446. * NATR indicator
  5447. *
  5448. * @extends plotOptions.atr
  5449. * @since 7.0.0
  5450. * @product highstock
  5451. * @requires stock/indicators/indicators
  5452. * @requires stock/indicators/natr
  5453. * @optionparent plotOptions.natr
  5454. */
  5455. NATRIndicator.defaultOptions = merge(ATRIndicator.defaultOptions, {
  5456. tooltip: {
  5457. valueSuffix: '%'
  5458. }
  5459. });
  5460. return NATRIndicator;
  5461. }(ATRIndicator));
  5462. extend(NATRIndicator.prototype, {
  5463. requiredIndicators: ['atr']
  5464. });
  5465. SeriesRegistry.registerSeriesType('natr', NATRIndicator);
  5466. /* *
  5467. *
  5468. * Default Export
  5469. *
  5470. * */
  5471. /**
  5472. * A `NATR` series. If the [type](#series.natr.type) option is not specified, it
  5473. * is inherited from [chart.type](#chart.type).
  5474. *
  5475. * @extends series,plotOptions.natr
  5476. * @since 7.0.0
  5477. * @product highstock
  5478. * @excluding dataParser, dataURL
  5479. * @requires stock/indicators/indicators
  5480. * @requires stock/indicators/natr
  5481. * @apioption series.natr
  5482. */
  5483. ''; // to include the above in the js output'
  5484. return NATRIndicator;
  5485. });
  5486. _registerModule(_modules, 'Stock/Indicators/PivotPoints/PivotPointsPoint.js', [_modules['Core/Series/SeriesRegistry.js']], function (SeriesRegistry) {
  5487. /* *
  5488. *
  5489. * License: www.highcharts.com/license
  5490. *
  5491. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  5492. *
  5493. * */
  5494. var __extends = (this && this.__extends) || (function () {
  5495. var extendStatics = function (d,
  5496. b) {
  5497. extendStatics = Object.setPrototypeOf ||
  5498. ({ __proto__: [] } instanceof Array && function (d,
  5499. b) { d.__proto__ = b; }) ||
  5500. function (d,
  5501. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5502. return extendStatics(d, b);
  5503. };
  5504. return function (d, b) {
  5505. extendStatics(d, b);
  5506. function __() { this.constructor = d; }
  5507. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5508. };
  5509. })();
  5510. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  5511. /* eslint-disable valid-jsdoc */
  5512. /**
  5513. * @private
  5514. */
  5515. function destroyExtraLabels(point, functionName) {
  5516. var props = point.series.pointArrayMap,
  5517. prop,
  5518. i = props.length;
  5519. SeriesRegistry.seriesTypes.sma.prototype.pointClass.prototype[functionName].call(point);
  5520. while (i--) {
  5521. prop = 'dataLabel' + props[i];
  5522. // S4 dataLabel could be removed by parent method:
  5523. if (point[prop] && point[prop].element) {
  5524. point[prop].destroy();
  5525. }
  5526. point[prop] = null;
  5527. }
  5528. }
  5529. /* eslint-enable valid-jsdoc */
  5530. /* *
  5531. *
  5532. * Class
  5533. *
  5534. * */
  5535. var PivotPointsPoint = /** @class */ (function (_super) {
  5536. __extends(PivotPointsPoint, _super);
  5537. function PivotPointsPoint() {
  5538. /**
  5539. *
  5540. * Properties
  5541. *
  5542. */
  5543. var _this = _super !== null && _super.apply(this,
  5544. arguments) || this;
  5545. _this.P = void 0;
  5546. _this.pivotLine = void 0;
  5547. _this.series = void 0;
  5548. return _this;
  5549. }
  5550. /**
  5551. *
  5552. * Functions
  5553. *
  5554. */
  5555. PivotPointsPoint.prototype.destroyElements = function () {
  5556. destroyExtraLabels(this, 'destroyElements');
  5557. };
  5558. // This method is called when removing points, e.g. series.update()
  5559. PivotPointsPoint.prototype.destroy = function () {
  5560. destroyExtraLabels(this, 'destroyElements');
  5561. };
  5562. return PivotPointsPoint;
  5563. }(SMAIndicator.prototype.pointClass));
  5564. /* *
  5565. *
  5566. * Default Export
  5567. *
  5568. * */
  5569. return PivotPointsPoint;
  5570. });
  5571. _registerModule(_modules, 'Stock/Indicators/PivotPoints/PivotPointsIndicator.js', [_modules['Stock/Indicators/PivotPoints/PivotPointsPoint.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (PivotPointsPoint, SeriesRegistry, U) {
  5572. /* *
  5573. *
  5574. * License: www.highcharts.com/license
  5575. *
  5576. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  5577. *
  5578. * */
  5579. var __extends = (this && this.__extends) || (function () {
  5580. var extendStatics = function (d,
  5581. b) {
  5582. extendStatics = Object.setPrototypeOf ||
  5583. ({ __proto__: [] } instanceof Array && function (d,
  5584. b) { d.__proto__ = b; }) ||
  5585. function (d,
  5586. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5587. return extendStatics(d, b);
  5588. };
  5589. return function (d, b) {
  5590. extendStatics(d, b);
  5591. function __() { this.constructor = d; }
  5592. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5593. };
  5594. })();
  5595. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  5596. var merge = U.merge,
  5597. extend = U.extend,
  5598. defined = U.defined,
  5599. isArray = U.isArray;
  5600. /**
  5601. *
  5602. * Class
  5603. *
  5604. **/
  5605. /**
  5606. * The Pivot Points series type.
  5607. *
  5608. * @private
  5609. * @class
  5610. * @name Highcharts.seriesTypes.pivotpoints
  5611. *
  5612. * @augments Highcharts.Series
  5613. */
  5614. var PivotPointsIndicator = /** @class */ (function (_super) {
  5615. __extends(PivotPointsIndicator, _super);
  5616. function PivotPointsIndicator() {
  5617. var _this = _super !== null && _super.apply(this,
  5618. arguments) || this;
  5619. /**
  5620. *
  5621. * Properties
  5622. *
  5623. */
  5624. _this.data = void 0;
  5625. _this.options = void 0;
  5626. _this.points = void 0;
  5627. _this.endPoint = void 0;
  5628. _this.plotEndPoint = void 0;
  5629. return _this;
  5630. }
  5631. /**
  5632. *
  5633. * Functions
  5634. *
  5635. */
  5636. PivotPointsIndicator.prototype.toYData = function (point) {
  5637. return [point.P]; // The rest should not affect extremes
  5638. };
  5639. PivotPointsIndicator.prototype.translate = function () {
  5640. var indicator = this;
  5641. SeriesRegistry.seriesTypes.sma.prototype.translate.apply(indicator);
  5642. indicator.points.forEach(function (point) {
  5643. indicator.pointArrayMap.forEach(function (value) {
  5644. if (defined(point[value])) {
  5645. point['plot' + value] = (indicator.yAxis.toPixels(point[value], true));
  5646. }
  5647. });
  5648. });
  5649. // Pivot points are rendered as horizontal lines
  5650. // And last point start not from the next one (as it's the last one)
  5651. // But from the approximated last position in a given range
  5652. indicator.plotEndPoint = indicator.xAxis.toPixels(indicator.endPoint, true);
  5653. };
  5654. PivotPointsIndicator.prototype.getGraphPath = function (points) {
  5655. var indicator = this,
  5656. pointsLength = points.length,
  5657. allPivotPoints = ([[],
  5658. [],
  5659. [],
  5660. [],
  5661. [],
  5662. [],
  5663. [],
  5664. [],
  5665. []]),
  5666. path = [],
  5667. endPoint = indicator.plotEndPoint,
  5668. pointArrayMapLength = indicator.pointArrayMap.length,
  5669. position,
  5670. point,
  5671. i;
  5672. while (pointsLength--) {
  5673. point = points[pointsLength];
  5674. for (i = 0; i < pointArrayMapLength; i++) {
  5675. position = indicator.pointArrayMap[i];
  5676. if (defined(point[position])) {
  5677. allPivotPoints[i].push({
  5678. // Start left:
  5679. plotX: point.plotX,
  5680. plotY: point['plot' + position],
  5681. isNull: false
  5682. }, {
  5683. // Go to right:
  5684. plotX: endPoint,
  5685. plotY: point['plot' + position],
  5686. isNull: false
  5687. }, {
  5688. // And add null points in path to generate breaks:
  5689. plotX: endPoint,
  5690. plotY: null,
  5691. isNull: true
  5692. });
  5693. }
  5694. }
  5695. endPoint = point.plotX;
  5696. }
  5697. allPivotPoints.forEach(function (pivotPoints) {
  5698. path = path.concat(SeriesRegistry.seriesTypes.sma.prototype.getGraphPath.call(indicator, pivotPoints));
  5699. });
  5700. return path;
  5701. };
  5702. // TODO: Rewrite this logic to use multiple datalabels
  5703. PivotPointsIndicator.prototype.drawDataLabels = function () {
  5704. var indicator = this,
  5705. pointMapping = indicator.pointArrayMap,
  5706. currentLabel,
  5707. pointsLength,
  5708. point,
  5709. i;
  5710. if (indicator.options.dataLabels.enabled) {
  5711. pointsLength = indicator.points.length;
  5712. // For every Ressitance/Support group we need to render labels.
  5713. // Add one more item, which will just store dataLabels from
  5714. // previous iteration
  5715. pointMapping.concat([false]).forEach(function (position, k) {
  5716. i = pointsLength;
  5717. while (i--) {
  5718. point = indicator.points[i];
  5719. if (!position) {
  5720. // Store S4 dataLabel too:
  5721. point['dataLabel' + pointMapping[k - 1]] =
  5722. point.dataLabel;
  5723. }
  5724. else {
  5725. point.y = point[position];
  5726. point.pivotLine = position;
  5727. point.plotY = point['plot' + position];
  5728. currentLabel = point['dataLabel' + position];
  5729. // Store previous label
  5730. if (k) {
  5731. point['dataLabel' + pointMapping[k - 1]] = point.dataLabel;
  5732. }
  5733. if (!point.dataLabels) {
  5734. point.dataLabels = [];
  5735. }
  5736. point.dataLabels[0] = point.dataLabel =
  5737. currentLabel =
  5738. currentLabel && currentLabel.element ?
  5739. currentLabel :
  5740. null;
  5741. }
  5742. }
  5743. SeriesRegistry.seriesTypes.sma.prototype.drawDataLabels.apply(indicator, arguments);
  5744. });
  5745. }
  5746. };
  5747. PivotPointsIndicator.prototype.getValues = function (series, params) {
  5748. var period = params.period,
  5749. xVal = series.xData,
  5750. yVal = series.yData,
  5751. yValLen = yVal ? yVal.length : 0,
  5752. placement = this[params.algorithm + 'Placement'],
  5753. // 0- from, 1- to, 2- R1, 3- R2, 4- pivot, 5- S1 etc.
  5754. PP = [],
  5755. endTimestamp,
  5756. xData = [],
  5757. yData = [],
  5758. slicedXLen,
  5759. slicedX,
  5760. slicedY,
  5761. lastPP,
  5762. pivot,
  5763. avg,
  5764. i;
  5765. // Pivot Points requires high, low and close values
  5766. if (xVal.length < period ||
  5767. !isArray(yVal[0]) ||
  5768. yVal[0].length !== 4) {
  5769. return;
  5770. }
  5771. for (i = period + 1; i <= yValLen + period; i += period) {
  5772. slicedX = xVal.slice(i - period - 1, i);
  5773. slicedY = yVal.slice(i - period - 1, i);
  5774. slicedXLen = slicedX.length;
  5775. endTimestamp = slicedX[slicedXLen - 1];
  5776. pivot = this.getPivotAndHLC(slicedY);
  5777. avg = placement(pivot);
  5778. lastPP = PP.push([endTimestamp]
  5779. .concat(avg));
  5780. xData.push(endTimestamp);
  5781. yData.push(PP[lastPP - 1].slice(1));
  5782. }
  5783. // We don't know exact position in ordinal axis
  5784. // So we use simple logic:
  5785. // Get first point in last range, calculate visible average range
  5786. // and multiply by period
  5787. this.endPoint = slicedX[0] + ((endTimestamp - slicedX[0]) /
  5788. slicedXLen) * period;
  5789. return {
  5790. values: PP,
  5791. xData: xData,
  5792. yData: yData
  5793. };
  5794. };
  5795. PivotPointsIndicator.prototype.getPivotAndHLC = function (values) {
  5796. var high = -Infinity,
  5797. low = Infinity,
  5798. close = values[values.length - 1][3],
  5799. pivot;
  5800. values.forEach(function (p) {
  5801. high = Math.max(high, p[1]);
  5802. low = Math.min(low, p[2]);
  5803. });
  5804. pivot = (high + low + close) / 3;
  5805. return [pivot, high, low, close];
  5806. };
  5807. PivotPointsIndicator.prototype.standardPlacement = function (values) {
  5808. var diff = values[1] - values[2],
  5809. avg = [
  5810. null,
  5811. null,
  5812. values[0] + diff,
  5813. values[0] * 2 - values[2],
  5814. values[0],
  5815. values[0] * 2 - values[1],
  5816. values[0] - diff,
  5817. null,
  5818. null
  5819. ];
  5820. return avg;
  5821. };
  5822. PivotPointsIndicator.prototype.camarillaPlacement = function (values) {
  5823. var diff = values[1] - values[2],
  5824. avg = [
  5825. values[3] + diff * 1.5,
  5826. values[3] + diff * 1.25,
  5827. values[3] + diff * 1.1666,
  5828. values[3] + diff * 1.0833,
  5829. values[0],
  5830. values[3] - diff * 1.0833,
  5831. values[3] - diff * 1.1666,
  5832. values[3] - diff * 1.25,
  5833. values[3] - diff * 1.5
  5834. ];
  5835. return avg;
  5836. };
  5837. PivotPointsIndicator.prototype.fibonacciPlacement = function (values) {
  5838. var diff = values[1] - values[2],
  5839. avg = [
  5840. null,
  5841. values[0] + diff,
  5842. values[0] + diff * 0.618,
  5843. values[0] + diff * 0.382,
  5844. values[0],
  5845. values[0] - diff * 0.382,
  5846. values[0] - diff * 0.618,
  5847. values[0] - diff,
  5848. null
  5849. ];
  5850. return avg;
  5851. };
  5852. /**
  5853. * Pivot points indicator. This series requires the `linkedTo` option to be
  5854. * set and should be loaded after `stock/indicators/indicators.js` file.
  5855. *
  5856. * @sample stock/indicators/pivot-points
  5857. * Pivot points
  5858. *
  5859. * @extends plotOptions.sma
  5860. * @since 6.0.0
  5861. * @product highstock
  5862. * @requires stock/indicators/indicators
  5863. * @requires stock/indicators/pivotpoints
  5864. * @optionparent plotOptions.pivotpoints
  5865. */
  5866. PivotPointsIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  5867. /**
  5868. * @excluding index
  5869. */
  5870. params: {
  5871. period: 28,
  5872. /**
  5873. * Algorithm used to calculate ressistance and support lines based
  5874. * on pivot points. Implemented algorithms: `'standard'`,
  5875. * `'fibonacci'` and `'camarilla'`
  5876. */
  5877. algorithm: 'standard'
  5878. },
  5879. marker: {
  5880. enabled: false
  5881. },
  5882. enableMouseTracking: false,
  5883. dataLabels: {
  5884. enabled: true,
  5885. format: '{point.pivotLine}'
  5886. },
  5887. dataGrouping: {
  5888. approximation: 'averages'
  5889. }
  5890. });
  5891. return PivotPointsIndicator;
  5892. }(SMAIndicator));
  5893. extend(PivotPointsIndicator.prototype, {
  5894. nameBase: 'Pivot Points',
  5895. pointArrayMap: ['R4', 'R3', 'R2', 'R1', 'P', 'S1', 'S2', 'S3', 'S4'],
  5896. pointValKey: 'P',
  5897. pointClass: PivotPointsPoint
  5898. });
  5899. /* *
  5900. *
  5901. * Registry
  5902. *
  5903. * */
  5904. SeriesRegistry.registerSeriesType('pivotpoints', PivotPointsIndicator);
  5905. /* *
  5906. *
  5907. * Default Export
  5908. *
  5909. * */
  5910. /**
  5911. * A pivot points indicator. If the [type](#series.pivotpoints.type) option is
  5912. * not specified, it is inherited from [chart.type](#chart.type).
  5913. *
  5914. * @extends series,plotOptions.pivotpoints
  5915. * @since 6.0.0
  5916. * @product highstock
  5917. * @excluding dataParser, dataURL
  5918. * @requires stock/indicators/indicators
  5919. * @requires stock/indicators/pivotpoints
  5920. * @apioption series.pivotpoints
  5921. */
  5922. ''; // to include the above in the js output'
  5923. return PivotPointsIndicator;
  5924. });
  5925. _registerModule(_modules, 'Stock/Indicators/PPO/PPOIndicator.js', [_modules['Mixins/IndicatorRequired.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (RequiredIndicatorMixin, SeriesRegistry, U) {
  5926. /* *
  5927. *
  5928. * License: www.highcharts.com/license
  5929. *
  5930. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  5931. *
  5932. * */
  5933. var __extends = (this && this.__extends) || (function () {
  5934. var extendStatics = function (d,
  5935. b) {
  5936. extendStatics = Object.setPrototypeOf ||
  5937. ({ __proto__: [] } instanceof Array && function (d,
  5938. b) { d.__proto__ = b; }) ||
  5939. function (d,
  5940. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5941. return extendStatics(d, b);
  5942. };
  5943. return function (d, b) {
  5944. extendStatics(d, b);
  5945. function __() { this.constructor = d; }
  5946. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5947. };
  5948. })();
  5949. var EMAIndicator = SeriesRegistry.seriesTypes.ema;
  5950. var correctFloat = U.correctFloat,
  5951. extend = U.extend,
  5952. merge = U.merge,
  5953. error = U.error;
  5954. /* *
  5955. *
  5956. * Class
  5957. *
  5958. * */
  5959. /**
  5960. * The PPO series type.
  5961. *
  5962. * @private
  5963. * @class
  5964. * @name Highcharts.seriesTypes.ppo
  5965. *
  5966. * @augments Highcharts.Series
  5967. */
  5968. var PPOIndicator = /** @class */ (function (_super) {
  5969. __extends(PPOIndicator, _super);
  5970. function PPOIndicator() {
  5971. var _this = _super !== null && _super.apply(this,
  5972. arguments) || this;
  5973. /* *
  5974. *
  5975. * Properties
  5976. *
  5977. * */
  5978. _this.data = void 0;
  5979. _this.options = void 0;
  5980. _this.points = void 0;
  5981. return _this;
  5982. }
  5983. /* *
  5984. *
  5985. * Functions
  5986. *
  5987. * */
  5988. PPOIndicator.prototype.init = function () {
  5989. var args = arguments,
  5990. ctx = this;
  5991. RequiredIndicatorMixin.isParentLoaded(EMAIndicator, 'ema', ctx.type, function (indicator) {
  5992. indicator.prototype.init.apply(ctx, args);
  5993. return;
  5994. });
  5995. };
  5996. PPOIndicator.prototype.getValues = function (series, params) {
  5997. var periods = params.periods,
  5998. index = params.index,
  5999. // 0- date, 1- Percentage Price Oscillator
  6000. PPO = [],
  6001. xData = [],
  6002. yData = [],
  6003. periodsOffset,
  6004. // Shorter Period EMA
  6005. SPE,
  6006. // Longer Period EMA
  6007. LPE,
  6008. oscillator,
  6009. i;
  6010. // Check if periods are correct
  6011. if (periods.length !== 2 || periods[1] <= periods[0]) {
  6012. error('Error: "PPO requires two periods. Notice, first period ' +
  6013. 'should be lower than the second one."');
  6014. return;
  6015. }
  6016. SPE = EMAIndicator.prototype.getValues.call(this, series, {
  6017. index: index,
  6018. period: periods[0]
  6019. });
  6020. LPE = EMAIndicator.prototype.getValues.call(this, series, {
  6021. index: index,
  6022. period: periods[1]
  6023. });
  6024. // Check if ema is calculated properly, if not skip
  6025. if (!SPE || !LPE) {
  6026. return;
  6027. }
  6028. periodsOffset = periods[1] - periods[0];
  6029. for (i = 0; i < LPE.yData.length; i++) {
  6030. oscillator = correctFloat((SPE.yData[i + periodsOffset] -
  6031. LPE.yData[i]) /
  6032. LPE.yData[i] *
  6033. 100);
  6034. PPO.push([LPE.xData[i], oscillator]);
  6035. xData.push(LPE.xData[i]);
  6036. yData.push(oscillator);
  6037. }
  6038. return {
  6039. values: PPO,
  6040. xData: xData,
  6041. yData: yData
  6042. };
  6043. };
  6044. /**
  6045. * Percentage Price Oscillator. This series requires the
  6046. * `linkedTo` option to be set and should be loaded after the
  6047. * `stock/indicators/indicators.js` and `stock/indicators/ema.js`.
  6048. *
  6049. * @sample {highstock} stock/indicators/ppo
  6050. * Percentage Price Oscillator
  6051. *
  6052. * @extends plotOptions.ema
  6053. * @since 7.0.0
  6054. * @product highstock
  6055. * @excluding allAreas, colorAxis, joinBy, keys, navigatorOptions,
  6056. * pointInterval, pointIntervalUnit, pointPlacement,
  6057. * pointRange, pointStart, showInNavigator, stacking
  6058. * @requires stock/indicators/indicators
  6059. * @requires stock/indicators/ema
  6060. * @requires stock/indicators/ppo
  6061. * @optionparent plotOptions.ppo
  6062. */
  6063. PPOIndicator.defaultOptions = merge(EMAIndicator.defaultOptions, {
  6064. /**
  6065. * Paramters used in calculation of Percentage Price Oscillator series
  6066. * points.
  6067. *
  6068. * @excluding period
  6069. */
  6070. params: {
  6071. /**
  6072. * Periods for Percentage Price Oscillator calculations.
  6073. *
  6074. * @type {Array<number>}
  6075. * @default [12, 26]
  6076. */
  6077. periods: [12, 26]
  6078. }
  6079. });
  6080. return PPOIndicator;
  6081. }(EMAIndicator));
  6082. extend(PPOIndicator.prototype, {
  6083. nameBase: 'PPO',
  6084. nameComponents: ['periods']
  6085. });
  6086. SeriesRegistry.registerSeriesType('ppo', PPOIndicator);
  6087. /* *
  6088. *
  6089. * Default Export
  6090. *
  6091. * */
  6092. /**
  6093. * A `Percentage Price Oscillator` series. If the [type](#series.ppo.type)
  6094. * option is not specified, it is inherited from [chart.type](#chart.type).
  6095. *
  6096. * @extends series,plotOptions.ppo
  6097. * @since 7.0.0
  6098. * @product highstock
  6099. * @excluding allAreas, colorAxis, dataParser, dataURL, joinBy, keys,
  6100. * navigatorOptions, pointInterval, pointIntervalUnit,
  6101. * pointPlacement, pointRange, pointStart, showInNavigator, stacking
  6102. * @requires stock/indicators/indicators
  6103. * @requires stock/indicators/ema
  6104. * @requires stock/indicators/ppo
  6105. * @apioption series.ppo
  6106. */
  6107. ''; // to include the above in the js output
  6108. return PPOIndicator;
  6109. });
  6110. _registerModule(_modules, 'Mixins/ReduceArray.js', [], function () {
  6111. /**
  6112. *
  6113. * (c) 2010-2021 Pawel Fus & Daniel Studencki
  6114. *
  6115. * License: www.highcharts.com/license
  6116. *
  6117. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  6118. *
  6119. * */
  6120. var reduceArrayMixin = {
  6121. /**
  6122. * Get min value of array filled by OHLC data.
  6123. * @private
  6124. * @param {Array<*>} arr Array of OHLC points (arrays).
  6125. * @param {string} index Index of "low" value in point array.
  6126. * @return {number} Returns min value.
  6127. */
  6128. minInArray: function (arr,
  6129. index) {
  6130. return arr.reduce(function (min,
  6131. target) {
  6132. return Math.min(min,
  6133. target[index]);
  6134. }, Number.MAX_VALUE);
  6135. },
  6136. /**
  6137. * Get max value of array filled by OHLC data.
  6138. * @private
  6139. * @param {Array<*>} arr Array of OHLC points (arrays).
  6140. * @param {string} index Index of "high" value in point array.
  6141. * @return {number} Returns max value.
  6142. */
  6143. maxInArray: function (arr, index) {
  6144. return arr.reduce(function (max, target) {
  6145. return Math.max(max, target[index]);
  6146. }, -Number.MAX_VALUE);
  6147. },
  6148. /**
  6149. * Get extremes of array filled by OHLC data.
  6150. * @private
  6151. * @param {Array<*>} arr Array of OHLC points (arrays).
  6152. * @param {string} minIndex Index of "low" value in point array.
  6153. * @param {string} maxIndex Index of "high" value in point array.
  6154. * @return {Array<number,number>} Returns array with min and max value.
  6155. */
  6156. getArrayExtremes: function (arr, minIndex, maxIndex) {
  6157. return arr.reduce(function (prev, target) {
  6158. return [
  6159. Math.min(prev[0], target[minIndex]),
  6160. Math.max(prev[1], target[maxIndex])
  6161. ];
  6162. }, [Number.MAX_VALUE, -Number.MAX_VALUE]);
  6163. }
  6164. };
  6165. return reduceArrayMixin;
  6166. });
  6167. _registerModule(_modules, 'Stock/Indicators/PC/PCIndicator.js', [_modules['Core/Color/Palette.js'], _modules['Mixins/MultipleLines.js'], _modules['Mixins/ReduceArray.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (palette, MultipleLinesMixin, ReduceArrayMixin, SeriesRegistry, U) {
  6168. /* *
  6169. *
  6170. * License: www.highcharts.com/license
  6171. *
  6172. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  6173. *
  6174. * */
  6175. var __extends = (this && this.__extends) || (function () {
  6176. var extendStatics = function (d,
  6177. b) {
  6178. extendStatics = Object.setPrototypeOf ||
  6179. ({ __proto__: [] } instanceof Array && function (d,
  6180. b) { d.__proto__ = b; }) ||
  6181. function (d,
  6182. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6183. return extendStatics(d, b);
  6184. };
  6185. return function (d, b) {
  6186. extendStatics(d, b);
  6187. function __() { this.constructor = d; }
  6188. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6189. };
  6190. })();
  6191. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  6192. var merge = U.merge,
  6193. extend = U.extend;
  6194. var getArrayExtremes = ReduceArrayMixin.getArrayExtremes;
  6195. /* *
  6196. *
  6197. * Class
  6198. *
  6199. * */
  6200. /**
  6201. * The Price Channel series type.
  6202. *
  6203. * @private
  6204. * @class
  6205. * @name Highcharts.seriesTypes.pc
  6206. *
  6207. * @augments Highcharts.Series
  6208. */
  6209. var PCIndicator = /** @class */ (function (_super) {
  6210. __extends(PCIndicator, _super);
  6211. function PCIndicator() {
  6212. var _this = _super !== null && _super.apply(this,
  6213. arguments) || this;
  6214. /* *
  6215. *
  6216. * Properties
  6217. *
  6218. * */
  6219. _this.data = void 0;
  6220. _this.options = void 0;
  6221. _this.points = void 0;
  6222. return _this;
  6223. }
  6224. /* *
  6225. *
  6226. * Functions
  6227. *
  6228. * */
  6229. PCIndicator.prototype.getValues = function (series, params) {
  6230. var period = params.period,
  6231. xVal = series.xData,
  6232. yVal = series.yData,
  6233. yValLen = yVal ? yVal.length : 0,
  6234. // 0- date, 1-top line, 2-middle line, 3-bottom line
  6235. PC = [],
  6236. // middle line, top line and bottom line
  6237. ML,
  6238. TL,
  6239. BL,
  6240. date,
  6241. low = 2,
  6242. high = 1,
  6243. xData = [],
  6244. yData = [],
  6245. slicedY,
  6246. extremes,
  6247. i;
  6248. if (yValLen < period) {
  6249. return;
  6250. }
  6251. for (i = period; i <= yValLen; i++) {
  6252. date = xVal[i - 1];
  6253. slicedY = yVal.slice(i - period, i);
  6254. extremes = getArrayExtremes(slicedY, low, high);
  6255. TL = extremes[1];
  6256. BL = extremes[0];
  6257. ML = (TL + BL) / 2;
  6258. PC.push([date, TL, ML, BL]);
  6259. xData.push(date);
  6260. yData.push([TL, ML, BL]);
  6261. }
  6262. return {
  6263. values: PC,
  6264. xData: xData,
  6265. yData: yData
  6266. };
  6267. };
  6268. /**
  6269. * Price channel (PC). This series requires the `linkedTo` option to be
  6270. * set and should be loaded after the `stock/indicators/indicators.js`.
  6271. *
  6272. * @sample {highstock} stock/indicators/price-channel
  6273. * Price Channel
  6274. *
  6275. * @extends plotOptions.sma
  6276. * @since 7.0.0
  6277. * @product highstock
  6278. * @excluding allAreas, colorAxis, compare, compareBase, joinBy, keys,
  6279. * navigatorOptions, pointInterval, pointIntervalUnit,
  6280. * pointPlacement, pointRange, pointStart, showInNavigator,
  6281. * stacking
  6282. * @requires stock/indicators/indicators
  6283. * @requires stock/indicators/price-channel
  6284. * @optionparent plotOptions.pc
  6285. */
  6286. PCIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  6287. /**
  6288. * @excluding index
  6289. */
  6290. params: {
  6291. period: 20
  6292. },
  6293. lineWidth: 1,
  6294. topLine: {
  6295. styles: {
  6296. /**
  6297. * Color of the top line. If not set, it's inherited from
  6298. * [plotOptions.pc.color](#plotOptions.pc.color).
  6299. *
  6300. * @type {Highcharts.ColorString}
  6301. */
  6302. lineColor: palette.colors[2],
  6303. /**
  6304. * Pixel width of the line.
  6305. */
  6306. lineWidth: 1
  6307. }
  6308. },
  6309. bottomLine: {
  6310. styles: {
  6311. /**
  6312. * Color of the bottom line. If not set, it's inherited from
  6313. * [plotOptions.pc.color](#plotOptions.pc.color).
  6314. *
  6315. * @type {Highcharts.ColorString}
  6316. */
  6317. lineColor: palette.colors[8],
  6318. /**
  6319. * Pixel width of the line.
  6320. */
  6321. lineWidth: 1
  6322. }
  6323. },
  6324. dataGrouping: {
  6325. approximation: 'averages'
  6326. }
  6327. });
  6328. return PCIndicator;
  6329. }(SMAIndicator));
  6330. extend(PCIndicator.prototype, {
  6331. getTranslatedLinesNames: MultipleLinesMixin.getTranslatedLinesNames,
  6332. drawGraph: MultipleLinesMixin.drawGraph,
  6333. toYData: MultipleLinesMixin.toYData,
  6334. pointArrayMap: ['top', 'middle', 'bottom'],
  6335. pointValKey: 'middle',
  6336. nameBase: 'Price Channel',
  6337. nameComponents: ['period'],
  6338. linesApiNames: ['topLine', 'bottomLine'],
  6339. translate: MultipleLinesMixin.translate
  6340. });
  6341. SeriesRegistry.registerSeriesType('pc', PCIndicator);
  6342. /* *
  6343. *
  6344. * Default Export
  6345. *
  6346. * */
  6347. /**
  6348. * A Price channel indicator. If the [type](#series.pc.type) option is not
  6349. * specified, it is inherited from [chart.type](#chart.type).
  6350. *
  6351. * @extends series,plotOptions.pc
  6352. * @since 7.0.0
  6353. * @product highstock
  6354. * @excluding allAreas, colorAxis, compare, compareBase, dataParser, dataURL,
  6355. * joinBy, keys, navigatorOptions, pointInterval,
  6356. * pointIntervalUnit, pointPlacement, pointRange, pointStart,
  6357. * showInNavigator, stacking
  6358. * @requires stock/indicators/indicators
  6359. * @requires stock/indicators/price-channel
  6360. * @apioption series.pc
  6361. */
  6362. ''; // to include the above in the js output
  6363. return PCIndicator;
  6364. });
  6365. _registerModule(_modules, 'Stock/Indicators/PriceEnvelopes/PriceEnvelopesIndicator.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  6366. /* *
  6367. *
  6368. * License: www.highcharts.com/license
  6369. *
  6370. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  6371. *
  6372. * */
  6373. var __extends = (this && this.__extends) || (function () {
  6374. var extendStatics = function (d,
  6375. b) {
  6376. extendStatics = Object.setPrototypeOf ||
  6377. ({ __proto__: [] } instanceof Array && function (d,
  6378. b) { d.__proto__ = b; }) ||
  6379. function (d,
  6380. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6381. return extendStatics(d, b);
  6382. };
  6383. return function (d, b) {
  6384. extendStatics(d, b);
  6385. function __() { this.constructor = d; }
  6386. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6387. };
  6388. })();
  6389. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  6390. var extend = U.extend,
  6391. isArray = U.isArray,
  6392. merge = U.merge;
  6393. /**
  6394. * The Price Envelopes series type.
  6395. *
  6396. * @private
  6397. * @class
  6398. * @name Highcharts.seriesTypes.priceenvelopes
  6399. *
  6400. * @augments Highcharts.Series
  6401. */
  6402. var PriceEnvelopesIndicator = /** @class */ (function (_super) {
  6403. __extends(PriceEnvelopesIndicator, _super);
  6404. function PriceEnvelopesIndicator() {
  6405. var _this = _super !== null && _super.apply(this,
  6406. arguments) || this;
  6407. _this.data = void 0;
  6408. _this.options = void 0;
  6409. _this.points = void 0;
  6410. return _this;
  6411. }
  6412. PriceEnvelopesIndicator.prototype.init = function () {
  6413. SeriesRegistry.seriesTypes.sma.prototype.init.apply(this, arguments);
  6414. // Set default color for lines:
  6415. this.options = merge({
  6416. topLine: {
  6417. styles: {
  6418. lineColor: this.color
  6419. }
  6420. },
  6421. bottomLine: {
  6422. styles: {
  6423. lineColor: this.color
  6424. }
  6425. }
  6426. }, this.options);
  6427. };
  6428. PriceEnvelopesIndicator.prototype.toYData = function (point) {
  6429. return [point.top, point.middle, point.bottom];
  6430. };
  6431. PriceEnvelopesIndicator.prototype.translate = function () {
  6432. var indicator = this, translatedEnvelopes = ['plotTop', 'plotMiddle', 'plotBottom'];
  6433. SeriesRegistry.seriesTypes.sma.prototype.translate.apply(indicator);
  6434. indicator.points.forEach(function (point) {
  6435. [point.top, point.middle, point.bottom].forEach(function (value, i) {
  6436. if (value !== null) {
  6437. point[translatedEnvelopes[i]] =
  6438. indicator.yAxis.toPixels(value, true);
  6439. }
  6440. });
  6441. });
  6442. };
  6443. PriceEnvelopesIndicator.prototype.drawGraph = function () {
  6444. var indicator = this,
  6445. middleLinePoints = indicator.points,
  6446. pointsLength = middleLinePoints.length,
  6447. middleLineOptions = (indicator.options),
  6448. middleLinePath = indicator.graph,
  6449. gappedExtend = {
  6450. options: {
  6451. gapSize: middleLineOptions.gapSize
  6452. }
  6453. },
  6454. deviations = [[],
  6455. []], // top and bottom point place holders
  6456. point;
  6457. // Generate points for top and bottom lines:
  6458. while (pointsLength--) {
  6459. point = middleLinePoints[pointsLength];
  6460. deviations[0].push({
  6461. plotX: point.plotX,
  6462. plotY: point.plotTop,
  6463. isNull: point.isNull
  6464. });
  6465. deviations[1].push({
  6466. plotX: point.plotX,
  6467. plotY: point.plotBottom,
  6468. isNull: point.isNull
  6469. });
  6470. }
  6471. // Modify options and generate lines:
  6472. ['topLine', 'bottomLine'].forEach(function (lineName, i) {
  6473. indicator.points = deviations[i];
  6474. indicator.options = merge(middleLineOptions[lineName].styles, gappedExtend);
  6475. indicator.graph = indicator['graph' + lineName];
  6476. SeriesRegistry.seriesTypes.sma.prototype.drawGraph.call(indicator);
  6477. // Now save lines:
  6478. indicator['graph' + lineName] = indicator.graph;
  6479. });
  6480. // Restore options and draw a middle line:
  6481. indicator.points = middleLinePoints;
  6482. indicator.options = middleLineOptions;
  6483. indicator.graph = middleLinePath;
  6484. SeriesRegistry.seriesTypes.sma.prototype.drawGraph.call(indicator);
  6485. };
  6486. PriceEnvelopesIndicator.prototype.getValues = function (series, params) {
  6487. var period = params.period,
  6488. topPercent = params.topBand,
  6489. botPercent = params.bottomBand,
  6490. xVal = series.xData,
  6491. yVal = series.yData,
  6492. yValLen = yVal ? yVal.length : 0,
  6493. // 0- date, 1-top line, 2-middle line, 3-bottom line
  6494. PE = [],
  6495. // middle line, top line and bottom line
  6496. ML,
  6497. TL,
  6498. BL,
  6499. date,
  6500. xData = [],
  6501. yData = [],
  6502. slicedX,
  6503. slicedY,
  6504. point,
  6505. i;
  6506. // Price envelopes requires close value
  6507. if (xVal.length < period ||
  6508. !isArray(yVal[0]) ||
  6509. yVal[0].length !== 4) {
  6510. return;
  6511. }
  6512. for (i = period; i <= yValLen; i++) {
  6513. slicedX = xVal.slice(i - period, i);
  6514. slicedY = yVal.slice(i - period, i);
  6515. point = SeriesRegistry.seriesTypes.sma.prototype.getValues.call(this, {
  6516. xData: slicedX,
  6517. yData: slicedY
  6518. }, params);
  6519. date = point.xData[0];
  6520. ML = point.yData[0];
  6521. TL = ML * (1 + topPercent);
  6522. BL = ML * (1 - botPercent);
  6523. PE.push([date, TL, ML, BL]);
  6524. xData.push(date);
  6525. yData.push([TL, ML, BL]);
  6526. }
  6527. return {
  6528. values: PE,
  6529. xData: xData,
  6530. yData: yData
  6531. };
  6532. };
  6533. /**
  6534. * Price envelopes indicator based on [SMA](#plotOptions.sma) calculations.
  6535. * This series requires the `linkedTo` option to be set and should be loaded
  6536. * after the `stock/indicators/indicators.js` file.
  6537. *
  6538. * @sample stock/indicators/price-envelopes
  6539. * Price envelopes
  6540. *
  6541. * @extends plotOptions.sma
  6542. * @since 6.0.0
  6543. * @product highstock
  6544. * @requires stock/indicators/indicators
  6545. * @requires stock/indicators/price-envelopes
  6546. * @optionparent plotOptions.priceenvelopes
  6547. */
  6548. PriceEnvelopesIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  6549. marker: {
  6550. enabled: false
  6551. },
  6552. tooltip: {
  6553. pointFormat: '<span style="color:{point.color}">\u25CF</span><b> {series.name}</b><br/>Top: {point.top}<br/>Middle: {point.middle}<br/>Bottom: {point.bottom}<br/>'
  6554. },
  6555. params: {
  6556. period: 20,
  6557. /**
  6558. * Percentage above the moving average that should be displayed.
  6559. * 0.1 means 110%. Relative to the calculated value.
  6560. */
  6561. topBand: 0.1,
  6562. /**
  6563. * Percentage below the moving average that should be displayed.
  6564. * 0.1 means 90%. Relative to the calculated value.
  6565. */
  6566. bottomBand: 0.1
  6567. },
  6568. /**
  6569. * Bottom line options.
  6570. */
  6571. bottomLine: {
  6572. styles: {
  6573. /**
  6574. * Pixel width of the line.
  6575. */
  6576. lineWidth: 1,
  6577. /**
  6578. * Color of the line. If not set, it's inherited from
  6579. * [plotOptions.priceenvelopes.color](
  6580. * #plotOptions.priceenvelopes.color).
  6581. *
  6582. * @type {Highcharts.ColorString}
  6583. */
  6584. lineColor: void 0
  6585. }
  6586. },
  6587. /**
  6588. * Top line options.
  6589. *
  6590. * @extends plotOptions.priceenvelopes.bottomLine
  6591. */
  6592. topLine: {
  6593. styles: {
  6594. lineWidth: 1
  6595. }
  6596. },
  6597. dataGrouping: {
  6598. approximation: 'averages'
  6599. }
  6600. });
  6601. return PriceEnvelopesIndicator;
  6602. }(SMAIndicator));
  6603. extend(PriceEnvelopesIndicator.prototype, {
  6604. nameComponents: ['period', 'topBand', 'bottomBand'],
  6605. nameBase: 'Price envelopes',
  6606. pointArrayMap: ['top', 'middle', 'bottom'],
  6607. parallelArrays: ['x', 'y', 'top', 'bottom'],
  6608. pointValKey: 'middle'
  6609. });
  6610. SeriesRegistry.registerSeriesType('priceenvelopes', PriceEnvelopesIndicator);
  6611. /* *
  6612. *
  6613. * Default Export
  6614. *
  6615. * */
  6616. /**
  6617. * A price envelopes indicator. If the [type](#series.priceenvelopes.type)
  6618. * option is not specified, it is inherited from [chart.type](#chart.type).
  6619. *
  6620. * @extends series,plotOptions.priceenvelopes
  6621. * @since 6.0.0
  6622. * @excluding dataParser, dataURL
  6623. * @product highstock
  6624. * @requires stock/indicators/indicators
  6625. * @requires stock/indicators/price-envelopes
  6626. * @apioption series.priceenvelopes
  6627. */
  6628. ''; // to include the above in the js output
  6629. return PriceEnvelopesIndicator;
  6630. });
  6631. _registerModule(_modules, 'Stock/Indicators/PSAR/PSARIndicator.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  6632. /* *
  6633. *
  6634. * Parabolic SAR indicator for Highstock
  6635. *
  6636. * (c) 2010-2021 Grzegorz Blachliński
  6637. *
  6638. * License: www.highcharts.com/license
  6639. *
  6640. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  6641. *
  6642. * */
  6643. var __extends = (this && this.__extends) || (function () {
  6644. var extendStatics = function (d,
  6645. b) {
  6646. extendStatics = Object.setPrototypeOf ||
  6647. ({ __proto__: [] } instanceof Array && function (d,
  6648. b) { d.__proto__ = b; }) ||
  6649. function (d,
  6650. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6651. return extendStatics(d, b);
  6652. };
  6653. return function (d, b) {
  6654. extendStatics(d, b);
  6655. function __() { this.constructor = d; }
  6656. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6657. };
  6658. })();
  6659. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  6660. var merge = U.merge,
  6661. extend = U.extend;
  6662. /* eslint-disable require-jsdoc */
  6663. // Utils:
  6664. function toFixed(a, n) {
  6665. return parseFloat(a.toFixed(n));
  6666. }
  6667. function calculateDirection(previousDirection, low, high, PSAR) {
  6668. if ((previousDirection === 1 && low > PSAR) ||
  6669. (previousDirection === -1 && high > PSAR)) {
  6670. return 1;
  6671. }
  6672. return -1;
  6673. }
  6674. /* *
  6675. * Method for calculating acceleration factor
  6676. * dir - direction
  6677. * pDir - previous Direction
  6678. * eP - extreme point
  6679. * pEP - previous extreme point
  6680. * inc - increment for acceleration factor
  6681. * maxAcc - maximum acceleration factor
  6682. * initAcc - initial acceleration factor
  6683. */
  6684. function getAccelerationFactor(dir, pDir, eP, pEP, pAcc, inc, maxAcc, initAcc) {
  6685. if (dir === pDir) {
  6686. if (dir === 1 && (eP > pEP)) {
  6687. return (pAcc === maxAcc) ? maxAcc : toFixed(pAcc + inc, 2);
  6688. }
  6689. if (dir === -1 && (eP < pEP)) {
  6690. return (pAcc === maxAcc) ? maxAcc : toFixed(pAcc + inc, 2);
  6691. }
  6692. return pAcc;
  6693. }
  6694. return initAcc;
  6695. }
  6696. function getExtremePoint(high, low, previousDirection, previousExtremePoint) {
  6697. if (previousDirection === 1) {
  6698. return (high > previousExtremePoint) ? high : previousExtremePoint;
  6699. }
  6700. return (low < previousExtremePoint) ? low : previousExtremePoint;
  6701. }
  6702. function getEPMinusPSAR(EP, PSAR) {
  6703. return EP - PSAR;
  6704. }
  6705. function getAccelerationFactorMultiply(accelerationFactor, EPMinusSAR) {
  6706. return accelerationFactor * EPMinusSAR;
  6707. }
  6708. /* *
  6709. * Method for calculating PSAR
  6710. * pdir - previous direction
  6711. * sDir - second previous Direction
  6712. * PSAR - previous PSAR
  6713. * pACCMultiply - previous acceleration factor multiply
  6714. * sLow - second previous low
  6715. * pLow - previous low
  6716. * sHigh - second previous high
  6717. * pHigh - previous high
  6718. * pEP - previous extreme point
  6719. */
  6720. function getPSAR(pdir, sDir, PSAR, pACCMulti, sLow, pLow, pHigh, sHigh, pEP) {
  6721. if (pdir === sDir) {
  6722. if (pdir === 1) {
  6723. return (PSAR + pACCMulti < Math.min(sLow, pLow)) ?
  6724. PSAR + pACCMulti :
  6725. Math.min(sLow, pLow);
  6726. }
  6727. return (PSAR + pACCMulti > Math.max(sHigh, pHigh)) ?
  6728. PSAR + pACCMulti :
  6729. Math.max(sHigh, pHigh);
  6730. }
  6731. return pEP;
  6732. }
  6733. /* eslint-enable require-jsdoc */
  6734. /* *
  6735. *
  6736. * Class
  6737. *
  6738. * */
  6739. /**
  6740. * The Parabolic SAR series type.
  6741. *
  6742. * @private
  6743. * @class
  6744. * @name Highcharts.seriesTypes.psar
  6745. *
  6746. * @augments Highcharts.Series
  6747. */
  6748. var PSARIndicator = /** @class */ (function (_super) {
  6749. __extends(PSARIndicator, _super);
  6750. function PSARIndicator() {
  6751. var _this = _super !== null && _super.apply(this,
  6752. arguments) || this;
  6753. /* *
  6754. *
  6755. * Properties
  6756. *
  6757. * */
  6758. _this.data = void 0;
  6759. _this.points = void 0;
  6760. _this.options = void 0;
  6761. return _this;
  6762. }
  6763. /* *
  6764. *
  6765. * Functions
  6766. *
  6767. * */
  6768. PSARIndicator.prototype.getValues = function (series, params) {
  6769. var xVal = series.xData,
  6770. yVal = series.yData,
  6771. // Extreme point is the lowest low for falling and highest high
  6772. // for rising psar - and we are starting with falling
  6773. extremePoint = yVal[0][1],
  6774. accelerationFactor = params.initialAccelerationFactor,
  6775. maxAccelerationFactor = params.maxAccelerationFactor,
  6776. increment = params.increment,
  6777. // Set initial acc factor (for every new trend!)
  6778. initialAccelerationFactor = params.initialAccelerationFactor,
  6779. PSAR = yVal[0][2],
  6780. decimals = params.decimals,
  6781. index = params.index,
  6782. PSARArr = [],
  6783. xData = [],
  6784. yData = [],
  6785. previousDirection = 1,
  6786. direction,
  6787. EPMinusPSAR,
  6788. accelerationFactorMultiply,
  6789. newDirection,
  6790. prevLow,
  6791. prevPrevLow,
  6792. prevHigh,
  6793. prevPrevHigh,
  6794. newExtremePoint,
  6795. high,
  6796. low,
  6797. ind;
  6798. if (index >= yVal.length) {
  6799. return;
  6800. }
  6801. for (ind = 0; ind < index; ind++) {
  6802. extremePoint = Math.max(yVal[ind][1], extremePoint);
  6803. PSAR = Math.min(yVal[ind][2], toFixed(PSAR, decimals));
  6804. }
  6805. direction = (yVal[ind][1] > PSAR) ? 1 : -1;
  6806. EPMinusPSAR = getEPMinusPSAR(extremePoint, PSAR);
  6807. accelerationFactor = params.initialAccelerationFactor;
  6808. accelerationFactorMultiply = getAccelerationFactorMultiply(accelerationFactor, EPMinusPSAR);
  6809. PSARArr.push([xVal[index], PSAR]);
  6810. xData.push(xVal[index]);
  6811. yData.push(toFixed(PSAR, decimals));
  6812. for (ind = index + 1; ind < yVal.length; ind++) {
  6813. prevLow = yVal[ind - 1][2];
  6814. prevPrevLow = yVal[ind - 2][2];
  6815. prevHigh = yVal[ind - 1][1];
  6816. prevPrevHigh = yVal[ind - 2][1];
  6817. high = yVal[ind][1];
  6818. low = yVal[ind][2];
  6819. // Null points break PSAR
  6820. if (prevPrevLow !== null &&
  6821. prevPrevHigh !== null &&
  6822. prevLow !== null &&
  6823. prevHigh !== null &&
  6824. high !== null &&
  6825. low !== null) {
  6826. PSAR = getPSAR(direction, previousDirection, PSAR, accelerationFactorMultiply, prevPrevLow, prevLow, prevHigh, prevPrevHigh, extremePoint);
  6827. newExtremePoint = getExtremePoint(high, low, direction, extremePoint);
  6828. newDirection = calculateDirection(previousDirection, low, high, PSAR);
  6829. accelerationFactor = getAccelerationFactor(newDirection, direction, newExtremePoint, extremePoint, accelerationFactor, increment, maxAccelerationFactor, initialAccelerationFactor);
  6830. EPMinusPSAR = getEPMinusPSAR(newExtremePoint, PSAR);
  6831. accelerationFactorMultiply = getAccelerationFactorMultiply(accelerationFactor, EPMinusPSAR);
  6832. PSARArr.push([xVal[ind], toFixed(PSAR, decimals)]);
  6833. xData.push(xVal[ind]);
  6834. yData.push(toFixed(PSAR, decimals));
  6835. previousDirection = direction;
  6836. direction = newDirection;
  6837. extremePoint = newExtremePoint;
  6838. }
  6839. }
  6840. return {
  6841. values: PSARArr,
  6842. xData: xData,
  6843. yData: yData
  6844. };
  6845. };
  6846. /**
  6847. * Parabolic SAR. This series requires `linkedTo`
  6848. * option to be set and should be loaded
  6849. * after `stock/indicators/indicators.js` file.
  6850. *
  6851. * @sample stock/indicators/psar
  6852. * Parabolic SAR Indicator
  6853. *
  6854. * @extends plotOptions.sma
  6855. * @since 6.0.0
  6856. * @product highstock
  6857. * @requires stock/indicators/indicators
  6858. * @requires stock/indicators/psar
  6859. * @optionparent plotOptions.psar
  6860. */
  6861. PSARIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  6862. lineWidth: 0,
  6863. marker: {
  6864. enabled: true
  6865. },
  6866. states: {
  6867. hover: {
  6868. lineWidthPlus: 0
  6869. }
  6870. },
  6871. /**
  6872. * @excluding period
  6873. */
  6874. params: {
  6875. /**
  6876. * The initial value for acceleration factor.
  6877. * Acceleration factor is starting with this value
  6878. * and increases by specified increment each time
  6879. * the extreme point makes a new high.
  6880. * AF can reach a maximum of maxAccelerationFactor,
  6881. * no matter how long the uptrend extends.
  6882. */
  6883. initialAccelerationFactor: 0.02,
  6884. /**
  6885. * The Maximum value for acceleration factor.
  6886. * AF can reach a maximum of maxAccelerationFactor,
  6887. * no matter how long the uptrend extends.
  6888. */
  6889. maxAccelerationFactor: 0.2,
  6890. /**
  6891. * Acceleration factor increases by increment each time
  6892. * the extreme point makes a new high.
  6893. *
  6894. * @since 6.0.0
  6895. */
  6896. increment: 0.02,
  6897. /**
  6898. * Index from which PSAR is starting calculation
  6899. *
  6900. * @since 6.0.0
  6901. */
  6902. index: 2,
  6903. /**
  6904. * Number of maximum decimals that are used in PSAR calculations.
  6905. *
  6906. * @since 6.0.0
  6907. */
  6908. decimals: 4
  6909. }
  6910. });
  6911. return PSARIndicator;
  6912. }(SMAIndicator));
  6913. extend(PSARIndicator.prototype, {
  6914. nameComponents: false
  6915. });
  6916. SeriesRegistry.registerSeriesType('psar', PSARIndicator);
  6917. /* *
  6918. *
  6919. * Default Export
  6920. *
  6921. * */
  6922. /**
  6923. * A `PSAR` series. If the [type](#series.psar.type) option is not specified, it
  6924. * is inherited from [chart.type](#chart.type).
  6925. *
  6926. * @extends series,plotOptions.psar
  6927. * @since 6.0.0
  6928. * @product highstock
  6929. * @excluding dataParser, dataURL
  6930. * @requires stock/indicators/indicators
  6931. * @requires stock/indicators/psar
  6932. * @apioption series.psar
  6933. */
  6934. ''; // to include the above in the js output
  6935. return PSARIndicator;
  6936. });
  6937. _registerModule(_modules, 'Stock/Indicators/ROC/ROCIndicator.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  6938. /* *
  6939. *
  6940. * (c) 2010-2021 Kacper Madej
  6941. *
  6942. * License: www.highcharts.com/license
  6943. *
  6944. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  6945. *
  6946. * */
  6947. var __extends = (this && this.__extends) || (function () {
  6948. var extendStatics = function (d,
  6949. b) {
  6950. extendStatics = Object.setPrototypeOf ||
  6951. ({ __proto__: [] } instanceof Array && function (d,
  6952. b) { d.__proto__ = b; }) ||
  6953. function (d,
  6954. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6955. return extendStatics(d, b);
  6956. };
  6957. return function (d, b) {
  6958. extendStatics(d, b);
  6959. function __() { this.constructor = d; }
  6960. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  6961. };
  6962. })();
  6963. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  6964. var isArray = U.isArray,
  6965. merge = U.merge,
  6966. extend = U.extend;
  6967. /* eslint-disable require-jsdoc */
  6968. // Utils:
  6969. function populateAverage(xVal, yVal, i, period, index) {
  6970. /* Calculated as:
  6971. (Closing Price [today] - Closing Price [n days ago]) /
  6972. Closing Price [n days ago] * 100
  6973. Return y as null when avoiding division by zero */
  6974. var nDaysAgoY,
  6975. rocY;
  6976. if (index < 0) {
  6977. // y data given as an array of values
  6978. nDaysAgoY = yVal[i - period];
  6979. rocY = nDaysAgoY ?
  6980. (yVal[i] - nDaysAgoY) / nDaysAgoY * 100 :
  6981. null;
  6982. }
  6983. else {
  6984. // y data given as an array of arrays and the index should be used
  6985. nDaysAgoY = yVal[i - period][index];
  6986. rocY = nDaysAgoY ?
  6987. (yVal[i][index] - nDaysAgoY) / nDaysAgoY * 100 :
  6988. null;
  6989. }
  6990. return [xVal[i], rocY];
  6991. }
  6992. /* eslint-enable require-jsdoc */
  6993. /* *
  6994. *
  6995. * Class
  6996. *
  6997. * */
  6998. /**
  6999. * The ROC series type.
  7000. *
  7001. * @private
  7002. * @class
  7003. * @name Highcharts.seriesTypes.roc
  7004. *
  7005. * @augments Highcharts.Series
  7006. */
  7007. var ROCIndicator = /** @class */ (function (_super) {
  7008. __extends(ROCIndicator, _super);
  7009. function ROCIndicator() {
  7010. var _this = _super !== null && _super.apply(this,
  7011. arguments) || this;
  7012. /* *
  7013. *
  7014. * Properties
  7015. *
  7016. * */
  7017. _this.data = void 0;
  7018. _this.options = void 0;
  7019. _this.points = void 0;
  7020. return _this;
  7021. }
  7022. /* *
  7023. *
  7024. * Functions
  7025. *
  7026. * */
  7027. ROCIndicator.prototype.getValues = function (series, params) {
  7028. var period = params.period,
  7029. xVal = series.xData,
  7030. yVal = series.yData,
  7031. yValLen = yVal ? yVal.length : 0,
  7032. ROC = [],
  7033. xData = [],
  7034. yData = [],
  7035. i,
  7036. index = -1,
  7037. ROCPoint;
  7038. // Period is used as a number of time periods ago, so we need more
  7039. // (at least 1 more) data than the period value
  7040. if (xVal.length <= period) {
  7041. return;
  7042. }
  7043. // Switch index for OHLC / Candlestick / Arearange
  7044. if (isArray(yVal[0])) {
  7045. index = params.index;
  7046. }
  7047. // i = period <-- skip first N-points
  7048. // Calculate value one-by-one for each period in visible data
  7049. for (i = period; i < yValLen; i++) {
  7050. ROCPoint = populateAverage(xVal, yVal, i, period, index);
  7051. ROC.push(ROCPoint);
  7052. xData.push(ROCPoint[0]);
  7053. yData.push(ROCPoint[1]);
  7054. }
  7055. return {
  7056. values: ROC,
  7057. xData: xData,
  7058. yData: yData
  7059. };
  7060. };
  7061. /**
  7062. * Rate of change indicator (ROC). The indicator value for each point
  7063. * is defined as:
  7064. *
  7065. * `(C - Cn) / Cn * 100`
  7066. *
  7067. * where: `C` is the close value of the point of the same x in the
  7068. * linked series and `Cn` is the close value of the point `n` periods
  7069. * ago. `n` is set through [period](#plotOptions.roc.params.period).
  7070. *
  7071. * This series requires `linkedTo` option to be set.
  7072. *
  7073. * @sample stock/indicators/roc
  7074. * Rate of change indicator
  7075. *
  7076. * @extends plotOptions.sma
  7077. * @since 6.0.0
  7078. * @product highstock
  7079. * @requires stock/indicators/indicators
  7080. * @requires stock/indicators/roc
  7081. * @optionparent plotOptions.roc
  7082. */
  7083. ROCIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  7084. params: {
  7085. index: 3,
  7086. period: 9
  7087. }
  7088. });
  7089. return ROCIndicator;
  7090. }(SMAIndicator));
  7091. extend(ROCIndicator.prototype, {
  7092. nameBase: 'Rate of Change'
  7093. });
  7094. SeriesRegistry.registerSeriesType('roc', ROCIndicator);
  7095. /* *
  7096. *
  7097. * Default Export
  7098. *
  7099. * */
  7100. /**
  7101. * A `ROC` series. If the [type](#series.wma.type) option is not
  7102. * specified, it is inherited from [chart.type](#chart.type).
  7103. *
  7104. * Rate of change indicator (ROC). The indicator value for each point
  7105. * is defined as:
  7106. *
  7107. * `(C - Cn) / Cn * 100`
  7108. *
  7109. * where: `C` is the close value of the point of the same x in the
  7110. * linked series and `Cn` is the close value of the point `n` periods
  7111. * ago. `n` is set through [period](#series.roc.params.period).
  7112. *
  7113. * This series requires `linkedTo` option to be set.
  7114. *
  7115. * @extends series,plotOptions.roc
  7116. * @since 6.0.0
  7117. * @product highstock
  7118. * @excluding dataParser, dataURL
  7119. * @requires stock/indicators/indicators
  7120. * @requires stock/indicators/roc
  7121. * @apioption series.roc
  7122. */
  7123. ''; // to include the above in the js output
  7124. return ROCIndicator;
  7125. });
  7126. _registerModule(_modules, 'Stock/Indicators/RSI/RSIIndicator.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  7127. /* *
  7128. *
  7129. * License: www.highcharts.com/license
  7130. *
  7131. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7132. *
  7133. * */
  7134. var __extends = (this && this.__extends) || (function () {
  7135. var extendStatics = function (d,
  7136. b) {
  7137. extendStatics = Object.setPrototypeOf ||
  7138. ({ __proto__: [] } instanceof Array && function (d,
  7139. b) { d.__proto__ = b; }) ||
  7140. function (d,
  7141. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  7142. return extendStatics(d, b);
  7143. };
  7144. return function (d, b) {
  7145. extendStatics(d, b);
  7146. function __() { this.constructor = d; }
  7147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7148. };
  7149. })();
  7150. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  7151. var isArray = U.isArray,
  7152. merge = U.merge;
  7153. /* eslint-disable require-jsdoc */
  7154. // Utils:
  7155. function toFixed(a, n) {
  7156. return parseFloat(a.toFixed(n));
  7157. }
  7158. /* eslint-enable require-jsdoc */
  7159. /**
  7160. * The RSI series type.
  7161. *
  7162. * @private
  7163. * @class
  7164. * @name Highcharts.seriesTypes.rsi
  7165. *
  7166. * @augments Highcharts.Series
  7167. */
  7168. var RSIIndicator = /** @class */ (function (_super) {
  7169. __extends(RSIIndicator, _super);
  7170. function RSIIndicator() {
  7171. var _this = _super !== null && _super.apply(this,
  7172. arguments) || this;
  7173. /* *
  7174. *
  7175. * Properties
  7176. *
  7177. * */
  7178. _this.data = void 0;
  7179. _this.points = void 0;
  7180. _this.options = void 0;
  7181. return _this;
  7182. }
  7183. /* *
  7184. *
  7185. * Functions
  7186. *
  7187. * */
  7188. RSIIndicator.prototype.getValues = function (series, params) {
  7189. var period = params.period,
  7190. xVal = series.xData,
  7191. yVal = series.yData,
  7192. yValLen = yVal ? yVal.length : 0,
  7193. decimals = params.decimals,
  7194. // RSI starts calculations from the second point
  7195. // Cause we need to calculate change between two points
  7196. range = 1,
  7197. RSI = [],
  7198. xData = [],
  7199. yData = [],
  7200. index = 3,
  7201. gain = 0,
  7202. loss = 0,
  7203. RSIPoint,
  7204. change,
  7205. avgGain,
  7206. avgLoss,
  7207. i;
  7208. // RSI requires close value
  7209. if ((xVal.length < period) || !isArray(yVal[0]) ||
  7210. yVal[0].length !== 4) {
  7211. return;
  7212. }
  7213. // Calculate changes for first N points
  7214. while (range < period) {
  7215. change = toFixed(yVal[range][index] - yVal[range - 1][index], decimals);
  7216. if (change > 0) {
  7217. gain += change;
  7218. }
  7219. else {
  7220. loss += Math.abs(change);
  7221. }
  7222. range++;
  7223. }
  7224. // Average for first n-1 points:
  7225. avgGain = toFixed(gain / (period - 1), decimals);
  7226. avgLoss = toFixed(loss / (period - 1), decimals);
  7227. for (i = range; i < yValLen; i++) {
  7228. change = toFixed(yVal[i][index] - yVal[i - 1][index], decimals);
  7229. if (change > 0) {
  7230. gain = change;
  7231. loss = 0;
  7232. }
  7233. else {
  7234. gain = 0;
  7235. loss = Math.abs(change);
  7236. }
  7237. // Calculate smoothed averages, RS, RSI values:
  7238. avgGain = toFixed((avgGain * (period - 1) + gain) / period, decimals);
  7239. avgLoss = toFixed((avgLoss * (period - 1) + loss) / period, decimals);
  7240. // If average-loss is equal zero, then by definition RSI is set
  7241. // to 100:
  7242. if (avgLoss === 0) {
  7243. RSIPoint = 100;
  7244. // If average-gain is equal zero, then by definition RSI is set
  7245. // to 0:
  7246. }
  7247. else if (avgGain === 0) {
  7248. RSIPoint = 0;
  7249. }
  7250. else {
  7251. RSIPoint = toFixed(100 - (100 / (1 + (avgGain / avgLoss))), decimals);
  7252. }
  7253. RSI.push([xVal[i], RSIPoint]);
  7254. xData.push(xVal[i]);
  7255. yData.push(RSIPoint);
  7256. }
  7257. return {
  7258. values: RSI,
  7259. xData: xData,
  7260. yData: yData
  7261. };
  7262. };
  7263. /**
  7264. * Relative strength index (RSI) technical indicator. This series
  7265. * requires the `linkedTo` option to be set and should be loaded after
  7266. * the `stock/indicators/indicators.js` file.
  7267. *
  7268. * @sample stock/indicators/rsi
  7269. * RSI indicator
  7270. *
  7271. * @extends plotOptions.sma
  7272. * @since 6.0.0
  7273. * @product highstock
  7274. * @requires stock/indicators/indicators
  7275. * @requires stock/indicators/rsi
  7276. * @optionparent plotOptions.rsi
  7277. */
  7278. RSIIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  7279. params: {
  7280. period: 14,
  7281. decimals: 4
  7282. }
  7283. });
  7284. return RSIIndicator;
  7285. }(SMAIndicator));
  7286. SeriesRegistry.registerSeriesType('rsi', RSIIndicator);
  7287. /* *
  7288. *
  7289. * Default Export
  7290. *
  7291. * */
  7292. /**
  7293. * A `RSI` series. If the [type](#series.rsi.type) option is not
  7294. * specified, it is inherited from [chart.type](#chart.type).
  7295. *
  7296. * @extends series,plotOptions.rsi
  7297. * @since 6.0.0
  7298. * @product highstock
  7299. * @excluding dataParser, dataURL
  7300. * @requires stock/indicators/indicators
  7301. * @requires stock/indicators/rsi
  7302. * @apioption series.rsi
  7303. */
  7304. ''; // to include the above in the js output
  7305. return RSIIndicator;
  7306. });
  7307. _registerModule(_modules, 'Stock/Indicators/Stochastic/StochasticIndicator.js', [_modules['Mixins/MultipleLines.js'], _modules['Mixins/ReduceArray.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (MultipleLinesMixin, ReduceArrayMixin, SeriesRegistry, U) {
  7308. /* *
  7309. *
  7310. * License: www.highcharts.com/license
  7311. *
  7312. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7313. *
  7314. * */
  7315. var __extends = (this && this.__extends) || (function () {
  7316. var extendStatics = function (d,
  7317. b) {
  7318. extendStatics = Object.setPrototypeOf ||
  7319. ({ __proto__: [] } instanceof Array && function (d,
  7320. b) { d.__proto__ = b; }) ||
  7321. function (d,
  7322. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  7323. return extendStatics(d, b);
  7324. };
  7325. return function (d, b) {
  7326. extendStatics(d, b);
  7327. function __() { this.constructor = d; }
  7328. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7329. };
  7330. })();
  7331. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  7332. var extend = U.extend,
  7333. isArray = U.isArray,
  7334. merge = U.merge;
  7335. /**
  7336. * The Stochastic series type.
  7337. *
  7338. * @private
  7339. * @class
  7340. * @name Highcharts.seriesTypes.stochastic
  7341. *
  7342. * @augments Highcharts.Series
  7343. */
  7344. var StochasticIndicator = /** @class */ (function (_super) {
  7345. __extends(StochasticIndicator, _super);
  7346. function StochasticIndicator() {
  7347. var _this = _super !== null && _super.apply(this,
  7348. arguments) || this;
  7349. _this.data = void 0;
  7350. _this.options = void 0;
  7351. _this.points = void 0;
  7352. return _this;
  7353. }
  7354. StochasticIndicator.prototype.init = function () {
  7355. SeriesRegistry.seriesTypes.sma.prototype.init.apply(this, arguments);
  7356. // Set default color for lines:
  7357. this.options = merge({
  7358. smoothedLine: {
  7359. styles: {
  7360. lineColor: this.color
  7361. }
  7362. }
  7363. }, this.options);
  7364. };
  7365. StochasticIndicator.prototype.getValues = function (series, params) {
  7366. var periodK = params.periods[0],
  7367. periodD = params.periods[1],
  7368. xVal = series.xData,
  7369. yVal = series.yData,
  7370. yValLen = yVal ? yVal.length : 0,
  7371. // 0- date, 1-%K, 2-%D
  7372. SO = [],
  7373. xData = [],
  7374. yData = [],
  7375. slicedY,
  7376. close = 3,
  7377. low = 2,
  7378. high = 1,
  7379. CL,
  7380. HL,
  7381. LL,
  7382. K,
  7383. D = null,
  7384. points,
  7385. extremes,
  7386. i;
  7387. // Stochastic requires close value
  7388. if (yValLen < periodK ||
  7389. !isArray(yVal[0]) ||
  7390. yVal[0].length !== 4) {
  7391. return;
  7392. }
  7393. // For a N-period, we start from N-1 point, to calculate Nth point
  7394. // That is why we later need to comprehend slice() elements list
  7395. // with (+1)
  7396. for (i = periodK - 1; i < yValLen; i++) {
  7397. slicedY = yVal.slice(i - periodK + 1, i + 1);
  7398. // Calculate %K
  7399. extremes = ReduceArrayMixin.getArrayExtremes(slicedY, low, high);
  7400. LL = extremes[0]; // Lowest low in %K periods
  7401. CL = yVal[i][close] - LL;
  7402. HL = extremes[1] - LL;
  7403. K = CL / HL * 100;
  7404. xData.push(xVal[i]);
  7405. yData.push([K, null]);
  7406. // Calculate smoothed %D, which is SMA of %K
  7407. if (i >= (periodK - 1) + (periodD - 1)) {
  7408. points = SeriesRegistry.seriesTypes.sma.prototype.getValues.call(this, {
  7409. xData: xData.slice(-periodD),
  7410. yData: yData.slice(-periodD)
  7411. }, {
  7412. period: periodD
  7413. });
  7414. D = points.yData[0];
  7415. }
  7416. SO.push([xVal[i], K, D]);
  7417. yData[yData.length - 1][1] = D;
  7418. }
  7419. return {
  7420. values: SO,
  7421. xData: xData,
  7422. yData: yData
  7423. };
  7424. };
  7425. /**
  7426. * Stochastic oscillator. This series requires the `linkedTo` option to be
  7427. * set and should be loaded after the `stock/indicators/indicators.js` file.
  7428. *
  7429. * @sample stock/indicators/stochastic
  7430. * Stochastic oscillator
  7431. *
  7432. * @extends plotOptions.sma
  7433. * @since 6.0.0
  7434. * @product highstock
  7435. * @excluding allAreas, colorAxis, joinBy, keys, navigatorOptions,
  7436. * pointInterval, pointIntervalUnit, pointPlacement,
  7437. * pointRange, pointStart, showInNavigator, stacking
  7438. * @requires stock/indicators/indicators
  7439. * @requires stock/indicators/stochastic
  7440. * @optionparent plotOptions.stochastic
  7441. */
  7442. StochasticIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  7443. /**
  7444. * @excluding index, period
  7445. */
  7446. params: {
  7447. /**
  7448. * Periods for Stochastic oscillator: [%K, %D].
  7449. *
  7450. * @type {Array<number,number>}
  7451. * @default [14, 3]
  7452. */
  7453. periods: [14, 3]
  7454. },
  7455. marker: {
  7456. enabled: false
  7457. },
  7458. tooltip: {
  7459. pointFormat: '<span style="color:{point.color}">\u25CF</span><b> {series.name}</b><br/>%K: {point.y}<br/>%D: {point.smoothed}<br/>'
  7460. },
  7461. /**
  7462. * Smoothed line options.
  7463. */
  7464. smoothedLine: {
  7465. /**
  7466. * Styles for a smoothed line.
  7467. */
  7468. styles: {
  7469. /**
  7470. * Pixel width of the line.
  7471. */
  7472. lineWidth: 1,
  7473. /**
  7474. * Color of the line. If not set, it's inherited from
  7475. * [plotOptions.stochastic.color
  7476. * ](#plotOptions.stochastic.color).
  7477. *
  7478. * @type {Highcharts.ColorString}
  7479. */
  7480. lineColor: void 0
  7481. }
  7482. },
  7483. dataGrouping: {
  7484. approximation: 'averages'
  7485. }
  7486. });
  7487. return StochasticIndicator;
  7488. }(SMAIndicator));
  7489. extend(StochasticIndicator.prototype, {
  7490. nameComponents: ['periods'],
  7491. nameBase: 'Stochastic',
  7492. pointArrayMap: ['y', 'smoothed'],
  7493. parallelArrays: ['x', 'y', 'smoothed'],
  7494. pointValKey: 'y',
  7495. linesApiNames: ['smoothedLine'],
  7496. drawGraph: MultipleLinesMixin.drawGraph,
  7497. getTranslatedLinesNames: MultipleLinesMixin.getTranslatedLinesNames,
  7498. translate: MultipleLinesMixin.translate,
  7499. toYData: MultipleLinesMixin.toYData
  7500. });
  7501. SeriesRegistry.registerSeriesType('stochastic', StochasticIndicator);
  7502. /* *
  7503. *
  7504. * Default Export
  7505. *
  7506. * */
  7507. /**
  7508. * A Stochastic indicator. If the [type](#series.stochastic.type) option is not
  7509. * specified, it is inherited from [chart.type](#chart.type).
  7510. *
  7511. * @extends series,plotOptions.stochastic
  7512. * @since 6.0.0
  7513. * @product highstock
  7514. * @excluding allAreas, colorAxis, dataParser, dataURL, joinBy, keys,
  7515. * navigatorOptions, pointInterval, pointIntervalUnit,
  7516. * pointPlacement, pointRange, pointStart, showInNavigator, stacking
  7517. * @requires stock/indicators/indicators
  7518. * @requires stock/indicators/stochastic
  7519. * @apioption series.stochastic
  7520. */
  7521. ''; // to include the above in the js output
  7522. return StochasticIndicator;
  7523. });
  7524. _registerModule(_modules, 'Stock/Indicators/SlowStochastic/SlowStochasticIndicator.js', [_modules['Mixins/IndicatorRequired.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (RequiredIndicatorMixin, SeriesRegistry, U) {
  7525. /* *
  7526. *
  7527. * License: www.highcharts.com/license
  7528. *
  7529. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7530. *
  7531. * */
  7532. var __extends = (this && this.__extends) || (function () {
  7533. var extendStatics = function (d,
  7534. b) {
  7535. extendStatics = Object.setPrototypeOf ||
  7536. ({ __proto__: [] } instanceof Array && function (d,
  7537. b) { d.__proto__ = b; }) ||
  7538. function (d,
  7539. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  7540. return extendStatics(d, b);
  7541. };
  7542. return function (d, b) {
  7543. extendStatics(d, b);
  7544. function __() { this.constructor = d; }
  7545. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7546. };
  7547. })();
  7548. var StochasticIndicator = SeriesRegistry.seriesTypes.stochastic;
  7549. var seriesTypes = SeriesRegistry.seriesTypes;
  7550. var extend = U.extend,
  7551. merge = U.merge;
  7552. /**
  7553. * The Slow Stochastic series type.
  7554. *
  7555. * @private
  7556. * @class
  7557. * @name Highcharts.seriesTypes.slowstochastic
  7558. *
  7559. * @augments Highcharts.Series
  7560. */
  7561. var SlowStochasticIndicator = /** @class */ (function (_super) {
  7562. __extends(SlowStochasticIndicator, _super);
  7563. function SlowStochasticIndicator() {
  7564. var _this = _super !== null && _super.apply(this,
  7565. arguments) || this;
  7566. _this.data = void 0;
  7567. _this.options = void 0;
  7568. _this.points = void 0;
  7569. return _this;
  7570. }
  7571. SlowStochasticIndicator.prototype.init = function () {
  7572. var args = arguments,
  7573. ctx = this;
  7574. RequiredIndicatorMixin.isParentLoaded(seriesTypes.stochastic, 'stochastic', ctx.type, function (indicator) {
  7575. indicator.prototype.init.apply(ctx, args);
  7576. return;
  7577. });
  7578. };
  7579. SlowStochasticIndicator.prototype.getValues = function (series, params) {
  7580. var periods = params.periods,
  7581. fastValues = seriesTypes.stochastic.prototype.getValues.call(this,
  7582. series,
  7583. params),
  7584. slowValues = {
  7585. values: [],
  7586. xData: [],
  7587. yData: []
  7588. };
  7589. var i = 0;
  7590. if (!fastValues) {
  7591. return;
  7592. }
  7593. slowValues.xData = fastValues.xData.slice(periods[1] - 1);
  7594. var fastYData = fastValues.yData.slice(periods[1] - 1);
  7595. // Get SMA(%D)
  7596. var smoothedValues = seriesTypes.sma.prototype.getValues.call(this, {
  7597. xData: slowValues.xData,
  7598. yData: fastYData
  7599. }, {
  7600. index: 1,
  7601. period: periods[2]
  7602. });
  7603. if (!smoothedValues) {
  7604. return;
  7605. }
  7606. var xDataLen = slowValues.xData.length;
  7607. // Format data
  7608. for (; i < xDataLen; i++) {
  7609. slowValues.yData[i] = [
  7610. fastYData[i][1],
  7611. smoothedValues.yData[i - periods[2] + 1] || null
  7612. ];
  7613. slowValues.values[i] = [
  7614. slowValues.xData[i],
  7615. fastYData[i][1],
  7616. smoothedValues.yData[i - periods[2] + 1] || null
  7617. ];
  7618. }
  7619. return slowValues;
  7620. };
  7621. /**
  7622. * Slow Stochastic oscillator. This series requires the `linkedTo` option
  7623. * to be set and should be loaded after `stock/indicators/indicators.js`
  7624. * and `stock/indicators/stochastic.js` files.
  7625. *
  7626. * @sample stock/indicators/slow-stochastic
  7627. * Slow Stochastic oscillator
  7628. *
  7629. * @extends plotOptions.stochastic
  7630. * @since 8.0.0
  7631. * @product highstock
  7632. * @requires stock/indicators/indicators
  7633. * @requires stock/indicators/stochastic
  7634. * @requires stock/indicators/slowstochastic
  7635. * @optionparent plotOptions.slowstochastic
  7636. */
  7637. SlowStochasticIndicator.defaultOptions = merge(StochasticIndicator.defaultOptions, {
  7638. params: {
  7639. /**
  7640. * Periods for Slow Stochastic oscillator: [%K, %D, SMA(%D)].
  7641. *
  7642. * @type {Array<number,number,number>}
  7643. * @default [14, 3, 3]
  7644. */
  7645. periods: [14, 3, 3]
  7646. }
  7647. });
  7648. return SlowStochasticIndicator;
  7649. }(StochasticIndicator));
  7650. extend(SlowStochasticIndicator.prototype, {
  7651. nameBase: 'Slow Stochastic'
  7652. });
  7653. SeriesRegistry.registerSeriesType('slowstochastic', SlowStochasticIndicator);
  7654. /* *
  7655. *
  7656. * Default Export
  7657. *
  7658. * */
  7659. /**
  7660. * A Slow Stochastic indicator. If the [type](#series.slowstochastic.type)
  7661. * option is not specified, it is inherited from [chart.type](#chart.type).
  7662. *
  7663. * @extends series,plotOptions.slowstochastic
  7664. * @since 8.0.0
  7665. * @product highstock
  7666. * @requires stock/indicators/indicators
  7667. * @requires stock/indicators/stochastic
  7668. * @requires stock/indicators/slowstochastic
  7669. * @apioption series.slowstochastic
  7670. */
  7671. ''; // to include the above in the js output
  7672. return SlowStochasticIndicator;
  7673. });
  7674. _registerModule(_modules, 'Stock/Indicators/Supertrend/SupertrendIndicator.js', [_modules['Core/Color/Palette.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (palette, SeriesRegistry, U) {
  7675. /* *
  7676. *
  7677. * License: www.highcharts.com/license
  7678. *
  7679. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7680. *
  7681. * */
  7682. var __extends = (this && this.__extends) || (function () {
  7683. var extendStatics = function (d,
  7684. b) {
  7685. extendStatics = Object.setPrototypeOf ||
  7686. ({ __proto__: [] } instanceof Array && function (d,
  7687. b) { d.__proto__ = b; }) ||
  7688. function (d,
  7689. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  7690. return extendStatics(d, b);
  7691. };
  7692. return function (d, b) {
  7693. extendStatics(d, b);
  7694. function __() { this.constructor = d; }
  7695. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  7696. };
  7697. })();
  7698. var _a = SeriesRegistry.seriesTypes,
  7699. ATRIndicator = _a.atr,
  7700. SMAIndicator = _a.sma;
  7701. var correctFloat = U.correctFloat,
  7702. isArray = U.isArray,
  7703. extend = U.extend,
  7704. merge = U.merge,
  7705. objectEach = U.objectEach;
  7706. /* eslint-disable require-jsdoc */
  7707. // Utils:
  7708. function createPointObj(mainSeries, index, close) {
  7709. return {
  7710. index: index,
  7711. close: mainSeries.yData[index][close],
  7712. x: mainSeries.xData[index]
  7713. };
  7714. }
  7715. /* eslint-enable require-jsdoc */
  7716. /* *
  7717. *
  7718. * Class
  7719. *
  7720. * */
  7721. /**
  7722. * The Supertrend series type.
  7723. *
  7724. * @private
  7725. * @class
  7726. * @name Highcharts.seriesTypes.supertrend
  7727. *
  7728. * @augments Highcharts.Series
  7729. */
  7730. var SupertrendIndicator = /** @class */ (function (_super) {
  7731. __extends(SupertrendIndicator, _super);
  7732. function SupertrendIndicator() {
  7733. var _this = _super !== null && _super.apply(this,
  7734. arguments) || this;
  7735. /* *
  7736. *
  7737. * Properties
  7738. *
  7739. * */
  7740. _this.data = void 0;
  7741. _this.linkedParent = void 0;
  7742. _this.options = void 0;
  7743. _this.points = void 0;
  7744. return _this;
  7745. }
  7746. /* *
  7747. *
  7748. * Functions
  7749. *
  7750. * */
  7751. SupertrendIndicator.prototype.init = function () {
  7752. var options,
  7753. parentOptions;
  7754. SMAIndicator.prototype.init.apply(this, arguments);
  7755. options = this.options;
  7756. parentOptions = this.linkedParent.options;
  7757. // Indicator cropThreshold has to be equal linked series one
  7758. // reduced by period due to points comparison in drawGraph method
  7759. // (#9787)
  7760. options.cropThreshold = (parentOptions.cropThreshold -
  7761. (options.params.period - 1));
  7762. };
  7763. SupertrendIndicator.prototype.drawGraph = function () {
  7764. var indicator = this,
  7765. indicOptions = indicator.options,
  7766. // Series that indicator is linked to
  7767. mainSeries = indicator.linkedParent,
  7768. mainLinePoints = (mainSeries ? mainSeries.points : []),
  7769. indicPoints = indicator.points,
  7770. indicPath = indicator.graph,
  7771. indicPointsLen = indicPoints.length,
  7772. // Points offset between lines
  7773. tempOffset = mainLinePoints.length - indicPointsLen,
  7774. offset = tempOffset > 0 ? tempOffset : 0,
  7775. // @todo: fix when ichi-moku indicator is merged to master.
  7776. gappedExtend = {
  7777. options: {
  7778. gapSize: indicOptions.gapSize
  7779. }
  7780. },
  7781. // Sorted supertrend points array
  7782. groupedPoitns = {
  7783. top: [],
  7784. bottom: [],
  7785. intersect: [] // Change trend line points
  7786. },
  7787. // Options for trend lines
  7788. supertrendLineOptions = {
  7789. top: {
  7790. styles: {
  7791. lineWidth: indicOptions.lineWidth,
  7792. lineColor: (indicOptions.fallingTrendColor ||
  7793. indicOptions.color),
  7794. dashStyle: indicOptions.dashStyle
  7795. }
  7796. },
  7797. bottom: {
  7798. styles: {
  7799. lineWidth: indicOptions.lineWidth,
  7800. lineColor: (indicOptions.risingTrendColor ||
  7801. indicOptions.color),
  7802. dashStyle: indicOptions.dashStyle
  7803. }
  7804. },
  7805. intersect: indicOptions.changeTrendLine
  7806. },
  7807. close = 3,
  7808. // Supertrend line point
  7809. point,
  7810. // Supertrend line next point (has smaller x pos than point)
  7811. nextPoint,
  7812. // Main series points
  7813. mainPoint,
  7814. nextMainPoint,
  7815. // Used when supertrend and main points are shifted
  7816. // relative to each other
  7817. prevMainPoint,
  7818. prevPrevMainPoint,
  7819. // Used when particular point color is set
  7820. pointColor,
  7821. // Temporary points that fill groupedPoitns array
  7822. newPoint,
  7823. newNextPoint;
  7824. // Loop which sort supertrend points
  7825. while (indicPointsLen--) {
  7826. point = indicPoints[indicPointsLen];
  7827. nextPoint = indicPoints[indicPointsLen - 1];
  7828. mainPoint = mainLinePoints[indicPointsLen - 1 + offset];
  7829. nextMainPoint = mainLinePoints[indicPointsLen - 2 + offset];
  7830. prevMainPoint = mainLinePoints[indicPointsLen + offset];
  7831. prevPrevMainPoint = mainLinePoints[indicPointsLen + offset + 1];
  7832. pointColor = point.options.color;
  7833. newPoint = {
  7834. x: point.x,
  7835. plotX: point.plotX,
  7836. plotY: point.plotY,
  7837. isNull: false
  7838. };
  7839. // When mainPoint is the last one (left plot area edge)
  7840. // but supertrend has additional one
  7841. if (!nextMainPoint &&
  7842. mainPoint && mainSeries.yData[mainPoint.index - 1]) {
  7843. nextMainPoint = createPointObj(mainSeries, mainPoint.index - 1, close);
  7844. }
  7845. // When prevMainPoint is the last one (right plot area edge)
  7846. // but supertrend has additional one (and points are shifted)
  7847. if (!prevPrevMainPoint &&
  7848. prevMainPoint && mainSeries.yData[prevMainPoint.index + 1]) {
  7849. prevPrevMainPoint = createPointObj(mainSeries, prevMainPoint.index + 1, close);
  7850. }
  7851. // When points are shifted (right or left plot area edge)
  7852. if (!mainPoint &&
  7853. nextMainPoint && mainSeries.yData[nextMainPoint.index + 1]) {
  7854. mainPoint = createPointObj(mainSeries, nextMainPoint.index + 1, close);
  7855. }
  7856. else if (!mainPoint &&
  7857. prevMainPoint && mainSeries.yData[prevMainPoint.index - 1]) {
  7858. mainPoint = createPointObj(mainSeries, prevMainPoint.index - 1, close);
  7859. }
  7860. // Check if points are shifted relative to each other
  7861. if (point &&
  7862. mainPoint &&
  7863. prevMainPoint &&
  7864. nextMainPoint &&
  7865. point.x !== mainPoint.x) {
  7866. if (point.x === prevMainPoint.x) {
  7867. nextMainPoint = mainPoint;
  7868. mainPoint = prevMainPoint;
  7869. }
  7870. else if (point.x === nextMainPoint.x) {
  7871. mainPoint = nextMainPoint;
  7872. nextMainPoint = {
  7873. close: mainSeries.yData[mainPoint.index - 1][close],
  7874. x: mainSeries.xData[mainPoint.index - 1]
  7875. };
  7876. }
  7877. else if (prevPrevMainPoint && point.x === prevPrevMainPoint.x) {
  7878. mainPoint = prevPrevMainPoint;
  7879. nextMainPoint = prevMainPoint;
  7880. }
  7881. }
  7882. if (nextPoint && nextMainPoint && mainPoint) {
  7883. newNextPoint = {
  7884. x: nextPoint.x,
  7885. plotX: nextPoint.plotX,
  7886. plotY: nextPoint.plotY,
  7887. isNull: false
  7888. };
  7889. if (point.y >= mainPoint.close &&
  7890. nextPoint.y >= nextMainPoint.close) {
  7891. point.color = (pointColor || indicOptions.fallingTrendColor ||
  7892. indicOptions.color);
  7893. groupedPoitns.top.push(newPoint);
  7894. }
  7895. else if (point.y < mainPoint.close &&
  7896. nextPoint.y < nextMainPoint.close) {
  7897. point.color = (pointColor || indicOptions.risingTrendColor ||
  7898. indicOptions.color);
  7899. groupedPoitns.bottom.push(newPoint);
  7900. }
  7901. else {
  7902. groupedPoitns.intersect.push(newPoint);
  7903. groupedPoitns.intersect.push(newNextPoint);
  7904. // Additional null point to make a gap in line
  7905. groupedPoitns.intersect.push(merge(newNextPoint, {
  7906. isNull: true
  7907. }));
  7908. if (point.y >= mainPoint.close &&
  7909. nextPoint.y < nextMainPoint.close) {
  7910. point.color = (pointColor || indicOptions.fallingTrendColor ||
  7911. indicOptions.color);
  7912. nextPoint.color = (pointColor || indicOptions.risingTrendColor ||
  7913. indicOptions.color);
  7914. groupedPoitns.top.push(newPoint);
  7915. groupedPoitns.top.push(merge(newNextPoint, {
  7916. isNull: true
  7917. }));
  7918. }
  7919. else if (point.y < mainPoint.close &&
  7920. nextPoint.y >= nextMainPoint.close) {
  7921. point.color = (pointColor || indicOptions.risingTrendColor ||
  7922. indicOptions.color);
  7923. nextPoint.color = (pointColor || indicOptions.fallingTrendColor ||
  7924. indicOptions.color);
  7925. groupedPoitns.bottom.push(newPoint);
  7926. groupedPoitns.bottom.push(merge(newNextPoint, {
  7927. isNull: true
  7928. }));
  7929. }
  7930. }
  7931. }
  7932. else if (mainPoint) {
  7933. if (point.y >= mainPoint.close) {
  7934. point.color = (pointColor || indicOptions.fallingTrendColor ||
  7935. indicOptions.color);
  7936. groupedPoitns.top.push(newPoint);
  7937. }
  7938. else {
  7939. point.color = (pointColor || indicOptions.risingTrendColor ||
  7940. indicOptions.color);
  7941. groupedPoitns.bottom.push(newPoint);
  7942. }
  7943. }
  7944. }
  7945. // Generate lines:
  7946. objectEach(groupedPoitns, function (values, lineName) {
  7947. indicator.points = values;
  7948. indicator.options = merge(supertrendLineOptions[lineName].styles, gappedExtend);
  7949. indicator.graph = indicator['graph' + lineName + 'Line'];
  7950. SMAIndicator.prototype.drawGraph.call(indicator);
  7951. // Now save line
  7952. indicator['graph' + lineName + 'Line'] = indicator.graph;
  7953. });
  7954. // Restore options:
  7955. indicator.points = indicPoints;
  7956. indicator.options = indicOptions;
  7957. indicator.graph = indicPath;
  7958. };
  7959. // Supertrend (Multiplier, Period) Formula:
  7960. // BASIC UPPERBAND = (HIGH + LOW) / 2 + Multiplier * ATR(Period)
  7961. // BASIC LOWERBAND = (HIGH + LOW) / 2 - Multiplier * ATR(Period)
  7962. // FINAL UPPERBAND =
  7963. // IF(
  7964. // Current BASICUPPERBAND < Previous FINAL UPPERBAND AND
  7965. // Previous Close > Previous FINAL UPPERBAND
  7966. // ) THEN (Current BASIC UPPERBAND)
  7967. // ELSE (Previous FINALUPPERBAND)
  7968. // FINAL LOWERBAND =
  7969. // IF(
  7970. // Current BASIC LOWERBAND > Previous FINAL LOWERBAND AND
  7971. // Previous Close < Previous FINAL LOWERBAND
  7972. // ) THEN (Current BASIC LOWERBAND)
  7973. // ELSE (Previous FINAL LOWERBAND)
  7974. // SUPERTREND =
  7975. // IF(
  7976. // Previous Supertrend == Previous FINAL UPPERBAND AND
  7977. // Current Close < Current FINAL UPPERBAND
  7978. // ) THAN Current FINAL UPPERBAND
  7979. // ELSE IF(
  7980. // Previous Supertrend == Previous FINAL LOWERBAND AND
  7981. // Current Close < Current FINAL LOWERBAND
  7982. // ) THAN Current FINAL UPPERBAND
  7983. // ELSE IF(
  7984. // Previous Supertrend == Previous FINAL UPPERBAND AND
  7985. // Current Close > Current FINAL UPPERBAND
  7986. // ) THAN Current FINAL LOWERBAND
  7987. // ELSE IF(
  7988. // Previous Supertrend == Previous FINAL LOWERBAND AND
  7989. // Current Close > Current FINAL LOWERBAND
  7990. // ) THAN Current FINAL LOWERBAND
  7991. SupertrendIndicator.prototype.getValues = function (series, params) {
  7992. var period = params.period,
  7993. multiplier = params.multiplier,
  7994. xVal = series.xData,
  7995. yVal = series.yData,
  7996. ATRData = [],
  7997. // 0- date, 1- Supertrend indicator
  7998. ST = [],
  7999. xData = [],
  8000. yData = [],
  8001. close = 3,
  8002. low = 2,
  8003. high = 1,
  8004. periodsOffset = (period === 0) ? 0 : period - 1,
  8005. basicUp,
  8006. basicDown,
  8007. finalUp = [],
  8008. finalDown = [],
  8009. supertrend,
  8010. prevFinalUp,
  8011. prevFinalDown,
  8012. prevST, // previous Supertrend
  8013. prevY,
  8014. y,
  8015. i;
  8016. if ((xVal.length <= period) || !isArray(yVal[0]) ||
  8017. yVal[0].length !== 4 || period < 0) {
  8018. return;
  8019. }
  8020. ATRData = ATRIndicator.prototype.getValues.call(this, series, {
  8021. period: period
  8022. }).yData;
  8023. for (i = 0; i < ATRData.length; i++) {
  8024. y = yVal[periodsOffset + i];
  8025. prevY = yVal[periodsOffset + i - 1] || [];
  8026. prevFinalUp = finalUp[i - 1];
  8027. prevFinalDown = finalDown[i - 1];
  8028. prevST = yData[i - 1];
  8029. if (i === 0) {
  8030. prevFinalUp = prevFinalDown = prevST = 0;
  8031. }
  8032. basicUp = correctFloat((y[high] + y[low]) / 2 + multiplier * ATRData[i]);
  8033. basicDown = correctFloat((y[high] + y[low]) / 2 - multiplier * ATRData[i]);
  8034. if ((basicUp < prevFinalUp) ||
  8035. (prevY[close] > prevFinalUp)) {
  8036. finalUp[i] = basicUp;
  8037. }
  8038. else {
  8039. finalUp[i] = prevFinalUp;
  8040. }
  8041. if ((basicDown > prevFinalDown) ||
  8042. (prevY[close] < prevFinalDown)) {
  8043. finalDown[i] = basicDown;
  8044. }
  8045. else {
  8046. finalDown[i] = prevFinalDown;
  8047. }
  8048. if (prevST === prevFinalUp && y[close] < finalUp[i] ||
  8049. prevST === prevFinalDown && y[close] < finalDown[i]) {
  8050. supertrend = finalUp[i];
  8051. }
  8052. else if (prevST === prevFinalUp && y[close] > finalUp[i] ||
  8053. prevST === prevFinalDown && y[close] > finalDown[i]) {
  8054. supertrend = finalDown[i];
  8055. }
  8056. ST.push([xVal[periodsOffset + i], supertrend]);
  8057. xData.push(xVal[periodsOffset + i]);
  8058. yData.push(supertrend);
  8059. }
  8060. return {
  8061. values: ST,
  8062. xData: xData,
  8063. yData: yData
  8064. };
  8065. };
  8066. /**
  8067. * Supertrend indicator. This series requires the `linkedTo` option to be
  8068. * set and should be loaded after the `stock/indicators/indicators.js` and
  8069. * `stock/indicators/sma.js`.
  8070. *
  8071. * @sample {highstock} stock/indicators/supertrend
  8072. * Supertrend indicator
  8073. *
  8074. * @extends plotOptions.sma
  8075. * @since 7.0.0
  8076. * @product highstock
  8077. * @excluding allAreas, cropThreshold, negativeColor, colorAxis, joinBy,
  8078. * keys, navigatorOptions, pointInterval, pointIntervalUnit,
  8079. * pointPlacement, pointRange, pointStart, showInNavigator,
  8080. * stacking, threshold
  8081. * @requires stock/indicators/indicators
  8082. * @requires stock/indicators/supertrend
  8083. * @optionparent plotOptions.supertrend
  8084. */
  8085. SupertrendIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  8086. /**
  8087. * Paramters used in calculation of Supertrend indicator series points.
  8088. *
  8089. * @excluding index
  8090. */
  8091. params: {
  8092. /**
  8093. * Multiplier for Supertrend Indicator.
  8094. */
  8095. multiplier: 3,
  8096. /**
  8097. * The base period for indicator Supertrend Indicator calculations.
  8098. * This is the number of data points which are taken into account
  8099. * for the indicator calculations.
  8100. */
  8101. period: 10
  8102. },
  8103. /**
  8104. * Color of the Supertrend series line that is beneath the main series.
  8105. *
  8106. * @sample {highstock} stock/indicators/supertrend/
  8107. * Example with risingTrendColor
  8108. *
  8109. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  8110. */
  8111. risingTrendColor: palette.indicatorPositiveLine,
  8112. /**
  8113. * Color of the Supertrend series line that is above the main series.
  8114. *
  8115. * @sample {highstock} stock/indicators/supertrend/
  8116. * Example with fallingTrendColor
  8117. *
  8118. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  8119. */
  8120. fallingTrendColor: palette.indicatorNegativeLine,
  8121. /**
  8122. * The styles for the Supertrend line that intersect main series.
  8123. *
  8124. * @sample {highstock} stock/indicators/supertrend/
  8125. * Example with changeTrendLine
  8126. */
  8127. changeTrendLine: {
  8128. styles: {
  8129. /**
  8130. * Pixel width of the line.
  8131. */
  8132. lineWidth: 1,
  8133. /**
  8134. * Color of the line.
  8135. *
  8136. * @type {Highcharts.ColorString}
  8137. */
  8138. lineColor: palette.neutralColor80,
  8139. /**
  8140. * The dash or dot style of the grid lines. For possible
  8141. * values, see
  8142. * [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  8143. *
  8144. * @sample {highcharts} highcharts/yaxis/gridlinedashstyle/
  8145. * Long dashes
  8146. * @sample {highstock} stock/xaxis/gridlinedashstyle/
  8147. * Long dashes
  8148. *
  8149. * @type {Highcharts.DashStyleValue}
  8150. * @since 7.0.0
  8151. */
  8152. dashStyle: 'LongDash'
  8153. }
  8154. }
  8155. });
  8156. return SupertrendIndicator;
  8157. }(SMAIndicator));
  8158. extend(SupertrendIndicator.prototype, {
  8159. nameBase: 'Supertrend',
  8160. nameComponents: ['multiplier', 'period'],
  8161. requiredIndicators: ['atr']
  8162. });
  8163. SeriesRegistry.registerSeriesType('supertrend', SupertrendIndicator);
  8164. /* *
  8165. *
  8166. * Default Export
  8167. *
  8168. * */
  8169. /**
  8170. * A `Supertrend indicator` series. If the [type](#series.supertrend.type)
  8171. * option is not specified, it is inherited from [chart.type](#chart.type).
  8172. *
  8173. * @extends series,plotOptions.supertrend
  8174. * @since 7.0.0
  8175. * @product highstock
  8176. * @excluding allAreas, colorAxis, cropThreshold, data, dataParser, dataURL,
  8177. * joinBy, keys, navigatorOptions, negativeColor, pointInterval,
  8178. * pointIntervalUnit, pointPlacement, pointRange, pointStart,
  8179. * showInNavigator, stacking, threshold
  8180. * @requires stock/indicators/indicators
  8181. * @requires stock/indicators/supertrend
  8182. * @apioption series.supertrend
  8183. */
  8184. ''; // to include the above in the js output
  8185. return SupertrendIndicator;
  8186. });
  8187. _registerModule(_modules, 'Stock/Indicators/VBP/VBPIndicator.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (A, H, SeriesRegistry, U) {
  8188. /* *
  8189. *
  8190. * (c) 2010-2021 Paweł Dalek
  8191. *
  8192. * Volume By Price (VBP) indicator for Highstock
  8193. *
  8194. * License: www.highcharts.com/license
  8195. *
  8196. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8197. *
  8198. * */
  8199. var __extends = (this && this.__extends) || (function () {
  8200. var extendStatics = function (d,
  8201. b) {
  8202. extendStatics = Object.setPrototypeOf ||
  8203. ({ __proto__: [] } instanceof Array && function (d,
  8204. b) { d.__proto__ = b; }) ||
  8205. function (d,
  8206. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  8207. return extendStatics(d, b);
  8208. };
  8209. return function (d, b) {
  8210. extendStatics(d, b);
  8211. function __() { this.constructor = d; }
  8212. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8213. };
  8214. })();
  8215. var animObject = A.animObject;
  8216. var noop = H.noop;
  8217. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  8218. var addEvent = U.addEvent,
  8219. arrayMax = U.arrayMax,
  8220. arrayMin = U.arrayMin,
  8221. correctFloat = U.correctFloat,
  8222. error = U.error,
  8223. extend = U.extend,
  8224. isArray = U.isArray,
  8225. merge = U.merge;
  8226. /* eslint-disable require-jsdoc */
  8227. // Utils
  8228. function arrayExtremesOHLC(data) {
  8229. var dataLength = data.length,
  8230. min = data[0][3],
  8231. max = min,
  8232. i = 1,
  8233. currentPoint;
  8234. for (; i < dataLength; i++) {
  8235. currentPoint = data[i][3];
  8236. if (currentPoint < min) {
  8237. min = currentPoint;
  8238. }
  8239. if (currentPoint > max) {
  8240. max = currentPoint;
  8241. }
  8242. }
  8243. return {
  8244. min: min,
  8245. max: max
  8246. };
  8247. }
  8248. /* eslint-enable require-jsdoc */
  8249. var abs = Math.abs,
  8250. columnPrototype = SeriesRegistry.seriesTypes.column.prototype;
  8251. /**
  8252. * The Volume By Price (VBP) series type.
  8253. *
  8254. * @private
  8255. * @class
  8256. * @name Highcharts.seriesTypes.vbp
  8257. *
  8258. * @augments Highcharts.Series
  8259. */
  8260. var VBPIndicator = /** @class */ (function (_super) {
  8261. __extends(VBPIndicator, _super);
  8262. function VBPIndicator() {
  8263. var _this = _super !== null && _super.apply(this,
  8264. arguments) || this;
  8265. _this.data = void 0;
  8266. _this.negWidths = void 0;
  8267. _this.options = void 0;
  8268. _this.points = void 0;
  8269. _this.posWidths = void 0;
  8270. _this.priceZones = void 0;
  8271. _this.rangeStep = void 0;
  8272. _this.volumeDataArray = void 0;
  8273. _this.zoneStarts = void 0;
  8274. _this.zoneLinesSVG = void 0;
  8275. return _this;
  8276. }
  8277. VBPIndicator.prototype.init = function (chart) {
  8278. var indicator = this,
  8279. params,
  8280. baseSeries,
  8281. volumeSeries;
  8282. H.seriesTypes.sma.prototype.init.apply(indicator, arguments);
  8283. params = indicator.options.params;
  8284. baseSeries = indicator.linkedParent;
  8285. volumeSeries = chart.get(params.volumeSeriesID);
  8286. indicator.addCustomEvents(baseSeries, volumeSeries);
  8287. return indicator;
  8288. };
  8289. // Adds events related with removing series
  8290. VBPIndicator.prototype.addCustomEvents = function (baseSeries, volumeSeries) {
  8291. var indicator = this;
  8292. /* eslint-disable require-jsdoc */
  8293. function toEmptyIndicator() {
  8294. indicator.chart.redraw();
  8295. indicator.setData([]);
  8296. indicator.zoneStarts = [];
  8297. if (indicator.zoneLinesSVG) {
  8298. indicator.zoneLinesSVG.destroy();
  8299. delete indicator.zoneLinesSVG;
  8300. }
  8301. }
  8302. /* eslint-enable require-jsdoc */
  8303. // If base series is deleted, indicator series data is filled with
  8304. // an empty array
  8305. indicator.dataEventsToUnbind.push(addEvent(baseSeries, 'remove', function () {
  8306. toEmptyIndicator();
  8307. }));
  8308. // If volume series is deleted, indicator series data is filled with
  8309. // an empty array
  8310. if (volumeSeries) {
  8311. indicator.dataEventsToUnbind.push(addEvent(volumeSeries, 'remove', function () {
  8312. toEmptyIndicator();
  8313. }));
  8314. }
  8315. return indicator;
  8316. };
  8317. // Initial animation
  8318. VBPIndicator.prototype.animate = function (init) {
  8319. var series = this,
  8320. inverted = series.chart.inverted,
  8321. group = series.group,
  8322. attr = {},
  8323. translate,
  8324. position;
  8325. if (!init && group) {
  8326. translate = inverted ? 'translateY' : 'translateX';
  8327. position = inverted ? series.yAxis.top : series.xAxis.left;
  8328. group['forceAnimate:' + translate] = true;
  8329. attr[translate] = position;
  8330. group.animate(attr, extend(animObject(series.options.animation), {
  8331. step: function (val, fx) {
  8332. series.group.attr({
  8333. scaleX: Math.max(0.001, fx.pos)
  8334. });
  8335. }
  8336. }));
  8337. }
  8338. };
  8339. VBPIndicator.prototype.drawPoints = function () {
  8340. var indicator = this;
  8341. if (indicator.options.volumeDivision.enabled) {
  8342. indicator.posNegVolume(true, true);
  8343. columnPrototype.drawPoints.apply(indicator, arguments);
  8344. indicator.posNegVolume(false, false);
  8345. }
  8346. columnPrototype.drawPoints.apply(indicator, arguments);
  8347. };
  8348. // Function responsible for dividing volume into positive and negative
  8349. VBPIndicator.prototype.posNegVolume = function (initVol, pos) {
  8350. var indicator = this, signOrder = pos ?
  8351. ['positive', 'negative'] :
  8352. ['negative', 'positive'], volumeDivision = indicator.options.volumeDivision, pointLength = indicator.points.length, posWidths = [], negWidths = [], i = 0, pointWidth, priceZone, wholeVol, point;
  8353. if (initVol) {
  8354. indicator.posWidths = posWidths;
  8355. indicator.negWidths = negWidths;
  8356. }
  8357. else {
  8358. posWidths = indicator.posWidths;
  8359. negWidths = indicator.negWidths;
  8360. }
  8361. for (; i < pointLength; i++) {
  8362. point = indicator.points[i];
  8363. point[signOrder[0] + 'Graphic'] = point.graphic;
  8364. point.graphic = point[signOrder[1] + 'Graphic'];
  8365. if (initVol) {
  8366. pointWidth = point.shapeArgs.width;
  8367. priceZone = indicator.priceZones[i];
  8368. wholeVol = priceZone.wholeVolumeData;
  8369. if (wholeVol) {
  8370. posWidths.push(pointWidth / wholeVol * priceZone.positiveVolumeData);
  8371. negWidths.push(pointWidth / wholeVol * priceZone.negativeVolumeData);
  8372. }
  8373. else {
  8374. posWidths.push(0);
  8375. negWidths.push(0);
  8376. }
  8377. }
  8378. point.color = pos ?
  8379. volumeDivision.styles.positiveColor :
  8380. volumeDivision.styles.negativeColor;
  8381. point.shapeArgs.width = pos ?
  8382. indicator.posWidths[i] :
  8383. indicator.negWidths[i];
  8384. point.shapeArgs.x = pos ?
  8385. point.shapeArgs.x :
  8386. indicator.posWidths[i];
  8387. }
  8388. };
  8389. VBPIndicator.prototype.translate = function () {
  8390. var indicator = this,
  8391. options = indicator.options,
  8392. chart = indicator.chart,
  8393. yAxis = indicator.yAxis,
  8394. yAxisMin = yAxis.min,
  8395. zoneLinesOptions = indicator.options.zoneLines,
  8396. priceZones = (indicator.priceZones),
  8397. yBarOffset = 0,
  8398. indicatorPoints,
  8399. volumeDataArray,
  8400. maxVolume,
  8401. primalBarWidth,
  8402. barHeight,
  8403. barHeightP,
  8404. oldBarHeight,
  8405. barWidth,
  8406. pointPadding,
  8407. chartPlotTop,
  8408. barX,
  8409. barY;
  8410. columnPrototype.translate.apply(indicator);
  8411. indicatorPoints = indicator.points;
  8412. // Do translate operation when points exist
  8413. if (indicatorPoints.length) {
  8414. pointPadding = options.pointPadding < 0.5 ?
  8415. options.pointPadding :
  8416. 0.1;
  8417. volumeDataArray = indicator.volumeDataArray;
  8418. maxVolume = arrayMax(volumeDataArray);
  8419. primalBarWidth = chart.plotWidth / 2;
  8420. chartPlotTop = chart.plotTop;
  8421. barHeight = abs(yAxis.toPixels(yAxisMin) -
  8422. yAxis.toPixels(yAxisMin + indicator.rangeStep));
  8423. oldBarHeight = abs(yAxis.toPixels(yAxisMin) -
  8424. yAxis.toPixels(yAxisMin + indicator.rangeStep));
  8425. if (pointPadding) {
  8426. barHeightP = abs(barHeight * (1 - 2 * pointPadding));
  8427. yBarOffset = abs((barHeight - barHeightP) / 2);
  8428. barHeight = abs(barHeightP);
  8429. }
  8430. indicatorPoints.forEach(function (point, index) {
  8431. barX = point.barX = point.plotX = 0;
  8432. barY = point.plotY = (yAxis.toPixels(priceZones[index].start) -
  8433. chartPlotTop -
  8434. (yAxis.reversed ?
  8435. (barHeight - oldBarHeight) :
  8436. barHeight) -
  8437. yBarOffset);
  8438. barWidth = correctFloat(primalBarWidth *
  8439. priceZones[index].wholeVolumeData / maxVolume);
  8440. point.pointWidth = barWidth;
  8441. point.shapeArgs = indicator.crispCol.apply(// eslint-disable-line no-useless-call
  8442. indicator, [barX, barY, barWidth, barHeight]);
  8443. point.volumeNeg = priceZones[index].negativeVolumeData;
  8444. point.volumePos = priceZones[index].positiveVolumeData;
  8445. point.volumeAll = priceZones[index].wholeVolumeData;
  8446. });
  8447. if (zoneLinesOptions.enabled) {
  8448. indicator.drawZones(chart, yAxis, indicator.zoneStarts, zoneLinesOptions.styles);
  8449. }
  8450. }
  8451. };
  8452. VBPIndicator.prototype.getValues = function (series, params) {
  8453. var indicator = this,
  8454. xValues = series.processedXData,
  8455. yValues = series.processedYData,
  8456. chart = indicator.chart,
  8457. ranges = params.ranges,
  8458. VBP = [],
  8459. xData = [],
  8460. yData = [],
  8461. isOHLC,
  8462. volumeSeries,
  8463. priceZones;
  8464. // Checks if base series exists
  8465. if (!series.chart) {
  8466. error('Base series not found! In case it has been removed, add ' +
  8467. 'a new one.', true, chart);
  8468. return;
  8469. }
  8470. // Checks if volume series exists
  8471. if (!(volumeSeries = (chart.get(params.volumeSeriesID)))) {
  8472. error('Series ' +
  8473. params.volumeSeriesID +
  8474. ' not found! Check `volumeSeriesID`.', true, chart);
  8475. return;
  8476. }
  8477. // Checks if series data fits the OHLC format
  8478. isOHLC = isArray(yValues[0]);
  8479. if (isOHLC && yValues[0].length !== 4) {
  8480. error('Type of ' +
  8481. series.name +
  8482. ' series is different than line, OHLC or candlestick.', true, chart);
  8483. return;
  8484. }
  8485. // Price zones contains all the information about the zones (index,
  8486. // start, end, volumes, etc.)
  8487. priceZones = indicator.priceZones = indicator.specifyZones(isOHLC, xValues, yValues, ranges, volumeSeries);
  8488. priceZones.forEach(function (zone, index) {
  8489. VBP.push([zone.x, zone.end]);
  8490. xData.push(VBP[index][0]);
  8491. yData.push(VBP[index][1]);
  8492. });
  8493. return {
  8494. values: VBP,
  8495. xData: xData,
  8496. yData: yData
  8497. };
  8498. };
  8499. // Specifing where each zone should start ans end
  8500. VBPIndicator.prototype.specifyZones = function (isOHLC, xValues, yValues, ranges, volumeSeries) {
  8501. var indicator = this,
  8502. rangeExtremes = (isOHLC ? arrayExtremesOHLC(yValues) : false),
  8503. lowRange = rangeExtremes ?
  8504. rangeExtremes.min :
  8505. arrayMin(yValues),
  8506. highRange = rangeExtremes ?
  8507. rangeExtremes.max :
  8508. arrayMax(yValues),
  8509. zoneStarts = indicator.zoneStarts = [],
  8510. priceZones = [],
  8511. i = 0,
  8512. j = 1,
  8513. rangeStep,
  8514. zoneStartsLength;
  8515. if (!lowRange || !highRange) {
  8516. if (this.points.length) {
  8517. this.setData([]);
  8518. this.zoneStarts = [];
  8519. this.zoneLinesSVG.destroy();
  8520. }
  8521. return [];
  8522. }
  8523. rangeStep = indicator.rangeStep =
  8524. correctFloat(highRange - lowRange) / ranges;
  8525. zoneStarts.push(lowRange);
  8526. for (; i < ranges - 1; i++) {
  8527. zoneStarts.push(correctFloat(zoneStarts[i] + rangeStep));
  8528. }
  8529. zoneStarts.push(highRange);
  8530. zoneStartsLength = zoneStarts.length;
  8531. // Creating zones
  8532. for (; j < zoneStartsLength; j++) {
  8533. priceZones.push({
  8534. index: j - 1,
  8535. x: xValues[0],
  8536. start: zoneStarts[j - 1],
  8537. end: zoneStarts[j]
  8538. });
  8539. }
  8540. return indicator.volumePerZone(isOHLC, priceZones, volumeSeries, xValues, yValues);
  8541. };
  8542. // Calculating sum of volume values for a specific zone
  8543. VBPIndicator.prototype.volumePerZone = function (isOHLC, priceZones, volumeSeries, xValues, yValues) {
  8544. var indicator = this,
  8545. volumeXData = volumeSeries.processedXData,
  8546. volumeYData = volumeSeries.processedYData,
  8547. lastZoneIndex = priceZones.length - 1,
  8548. baseSeriesLength = yValues.length,
  8549. volumeSeriesLength = volumeYData.length,
  8550. previousValue,
  8551. startFlag,
  8552. endFlag,
  8553. value,
  8554. i;
  8555. // Checks if each point has a corresponding volume value
  8556. if (abs(baseSeriesLength - volumeSeriesLength)) {
  8557. // If the first point don't have volume, add 0 value at the
  8558. // beggining of the volume array
  8559. if (xValues[0] !== volumeXData[0]) {
  8560. volumeYData.unshift(0);
  8561. }
  8562. // If the last point don't have volume, add 0 value at the end
  8563. // of the volume array
  8564. if (xValues[baseSeriesLength - 1] !==
  8565. volumeXData[volumeSeriesLength - 1]) {
  8566. volumeYData.push(0);
  8567. }
  8568. }
  8569. indicator.volumeDataArray = [];
  8570. priceZones.forEach(function (zone) {
  8571. zone.wholeVolumeData = 0;
  8572. zone.positiveVolumeData = 0;
  8573. zone.negativeVolumeData = 0;
  8574. for (i = 0; i < baseSeriesLength; i++) {
  8575. startFlag = false;
  8576. endFlag = false;
  8577. value = isOHLC ? yValues[i][3] : yValues[i];
  8578. previousValue = i ?
  8579. (isOHLC ?
  8580. yValues[i - 1][3] :
  8581. yValues[i - 1]) :
  8582. value;
  8583. // Checks if this is the point with the
  8584. // lowest close value and if so, adds it calculations
  8585. if (value <= zone.start && zone.index === 0) {
  8586. startFlag = true;
  8587. }
  8588. // Checks if this is the point with the highest
  8589. // close value and if so, adds it calculations
  8590. if (value >= zone.end && zone.index === lastZoneIndex) {
  8591. endFlag = true;
  8592. }
  8593. if ((value > zone.start || startFlag) &&
  8594. (value < zone.end || endFlag)) {
  8595. zone.wholeVolumeData += volumeYData[i];
  8596. if (previousValue > value) {
  8597. zone.negativeVolumeData += volumeYData[i];
  8598. }
  8599. else {
  8600. zone.positiveVolumeData += volumeYData[i];
  8601. }
  8602. }
  8603. }
  8604. indicator.volumeDataArray.push(zone.wholeVolumeData);
  8605. });
  8606. return priceZones;
  8607. };
  8608. // Function responsoble for drawing additional lines indicating zones
  8609. VBPIndicator.prototype.drawZones = function (chart, yAxis, zonesValues, zonesStyles) {
  8610. var indicator = this,
  8611. renderer = chart.renderer,
  8612. zoneLinesSVG = indicator.zoneLinesSVG,
  8613. zoneLinesPath = [],
  8614. leftLinePos = 0,
  8615. rightLinePos = chart.plotWidth,
  8616. verticalOffset = chart.plotTop,
  8617. verticalLinePos;
  8618. zonesValues.forEach(function (value) {
  8619. verticalLinePos = yAxis.toPixels(value) - verticalOffset;
  8620. zoneLinesPath = zoneLinesPath.concat(chart.renderer.crispLine([[
  8621. 'M',
  8622. leftLinePos,
  8623. verticalLinePos
  8624. ], [
  8625. 'L',
  8626. rightLinePos,
  8627. verticalLinePos
  8628. ]], zonesStyles.lineWidth));
  8629. });
  8630. // Create zone lines one path or update it while animating
  8631. if (zoneLinesSVG) {
  8632. zoneLinesSVG.animate({
  8633. d: zoneLinesPath
  8634. });
  8635. }
  8636. else {
  8637. zoneLinesSVG = indicator.zoneLinesSVG =
  8638. renderer.path(zoneLinesPath).attr({
  8639. 'stroke-width': zonesStyles.lineWidth,
  8640. 'stroke': zonesStyles.color,
  8641. 'dashstyle': zonesStyles.dashStyle,
  8642. 'zIndex': indicator.group.zIndex + 0.1
  8643. })
  8644. .add(indicator.group);
  8645. }
  8646. };
  8647. /**
  8648. * Volume By Price indicator.
  8649. *
  8650. * This series requires `linkedTo` option to be set.
  8651. *
  8652. * @sample stock/indicators/volume-by-price
  8653. * Volume By Price indicator
  8654. *
  8655. * @extends plotOptions.sma
  8656. * @since 6.0.0
  8657. * @product highstock
  8658. * @requires stock/indicators/indicators
  8659. * @requires stock/indicators/volume-by-price
  8660. * @optionparent plotOptions.vbp
  8661. */
  8662. VBPIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  8663. /**
  8664. * @excluding index, period
  8665. */
  8666. params: {
  8667. /**
  8668. * The number of price zones.
  8669. */
  8670. ranges: 12,
  8671. /**
  8672. * The id of volume series which is mandatory. For example using
  8673. * OHLC data, volumeSeriesID='volume' means the indicator will be
  8674. * calculated using OHLC and volume values.
  8675. */
  8676. volumeSeriesID: 'volume'
  8677. },
  8678. /**
  8679. * The styles for lines which determine price zones.
  8680. */
  8681. zoneLines: {
  8682. /**
  8683. * Enable/disable zone lines.
  8684. */
  8685. enabled: true,
  8686. /**
  8687. * Specify the style of zone lines.
  8688. *
  8689. * @type {Highcharts.CSSObject}
  8690. * @default {"color": "#0A9AC9", "dashStyle": "LongDash", "lineWidth": 1}
  8691. */
  8692. styles: {
  8693. /** @ignore-options */
  8694. color: '#0A9AC9',
  8695. /** @ignore-options */
  8696. dashStyle: 'LongDash',
  8697. /** @ignore-options */
  8698. lineWidth: 1
  8699. }
  8700. },
  8701. /**
  8702. * The styles for bars when volume is divided into positive/negative.
  8703. */
  8704. volumeDivision: {
  8705. /**
  8706. * Option to control if volume is divided.
  8707. */
  8708. enabled: true,
  8709. styles: {
  8710. /**
  8711. * Color of positive volume bars.
  8712. *
  8713. * @type {Highcharts.ColorString}
  8714. */
  8715. positiveColor: 'rgba(144, 237, 125, 0.8)',
  8716. /**
  8717. * Color of negative volume bars.
  8718. *
  8719. * @type {Highcharts.ColorString}
  8720. */
  8721. negativeColor: 'rgba(244, 91, 91, 0.8)'
  8722. }
  8723. },
  8724. // To enable series animation; must be animationLimit > pointCount
  8725. animationLimit: 1000,
  8726. enableMouseTracking: false,
  8727. pointPadding: 0,
  8728. zIndex: -1,
  8729. crisp: true,
  8730. dataGrouping: {
  8731. enabled: false
  8732. },
  8733. dataLabels: {
  8734. allowOverlap: true,
  8735. enabled: true,
  8736. format: 'P: {point.volumePos:.2f} | N: {point.volumeNeg:.2f}',
  8737. padding: 0,
  8738. style: {
  8739. /** @internal */
  8740. fontSize: '7px'
  8741. },
  8742. verticalAlign: 'top'
  8743. }
  8744. });
  8745. return VBPIndicator;
  8746. }(SMAIndicator));
  8747. extend(VBPIndicator.prototype, {
  8748. nameBase: 'Volume by Price',
  8749. bindTo: {
  8750. series: false,
  8751. eventName: 'afterSetExtremes'
  8752. },
  8753. calculateOn: 'render',
  8754. markerAttribs: noop,
  8755. drawGraph: noop,
  8756. getColumnMetrics: columnPrototype.getColumnMetrics,
  8757. crispCol: columnPrototype.crispCol
  8758. });
  8759. SeriesRegistry.registerSeriesType('vbp', VBPIndicator);
  8760. /* *
  8761. *
  8762. * Default Export
  8763. *
  8764. * */
  8765. /**
  8766. * A `Volume By Price (VBP)` series. If the [type](#series.vbp.type) option is
  8767. * not specified, it is inherited from [chart.type](#chart.type).
  8768. *
  8769. * @extends series,plotOptions.vbp
  8770. * @since 6.0.0
  8771. * @product highstock
  8772. * @excluding dataParser, dataURL
  8773. * @requires stock/indicators/indicators
  8774. * @requires stock/indicators/volume-by-price
  8775. * @apioption series.vbp
  8776. */
  8777. ''; // to include the above in the js output
  8778. return VBPIndicator;
  8779. });
  8780. _registerModule(_modules, 'Stock/Indicators/VWAP/VWAPIndicator.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  8781. /* *
  8782. *
  8783. * (c) 2010-2021 Paweł Dalek
  8784. *
  8785. * Volume Weighted Average Price (VWAP) indicator for Highstock
  8786. *
  8787. * License: www.highcharts.com/license
  8788. *
  8789. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8790. *
  8791. * */
  8792. var __extends = (this && this.__extends) || (function () {
  8793. var extendStatics = function (d,
  8794. b) {
  8795. extendStatics = Object.setPrototypeOf ||
  8796. ({ __proto__: [] } instanceof Array && function (d,
  8797. b) { d.__proto__ = b; }) ||
  8798. function (d,
  8799. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  8800. return extendStatics(d, b);
  8801. };
  8802. return function (d, b) {
  8803. extendStatics(d, b);
  8804. function __() { this.constructor = d; }
  8805. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  8806. };
  8807. })();
  8808. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  8809. var error = U.error,
  8810. isArray = U.isArray,
  8811. merge = U.merge;
  8812. /* *
  8813. *
  8814. * Class
  8815. *
  8816. * */
  8817. /**
  8818. * The Volume Weighted Average Price (VWAP) series type.
  8819. *
  8820. * @private
  8821. * @class
  8822. * @name Highcharts.seriesTypes.vwap
  8823. *
  8824. * @augments Highcharts.Series
  8825. */
  8826. var VWAPIndicator = /** @class */ (function (_super) {
  8827. __extends(VWAPIndicator, _super);
  8828. function VWAPIndicator() {
  8829. var _this = _super !== null && _super.apply(this,
  8830. arguments) || this;
  8831. /* *
  8832. *
  8833. * Properties
  8834. *
  8835. * */
  8836. _this.data = void 0;
  8837. _this.points = void 0;
  8838. _this.options = void 0;
  8839. return _this;
  8840. }
  8841. /* *
  8842. *
  8843. * Functions
  8844. *
  8845. * */
  8846. VWAPIndicator.prototype.getValues = function (series, params) {
  8847. var indicator = this,
  8848. chart = series.chart,
  8849. xValues = series.xData,
  8850. yValues = series.yData,
  8851. period = params.period,
  8852. isOHLC = true,
  8853. volumeSeries;
  8854. // Checks if volume series exists
  8855. if (!(volumeSeries = (chart.get(params.volumeSeriesID)))) {
  8856. error('Series ' +
  8857. params.volumeSeriesID +
  8858. ' not found! Check `volumeSeriesID`.', true, chart);
  8859. return;
  8860. }
  8861. // Checks if series data fits the OHLC format
  8862. if (!(isArray(yValues[0]))) {
  8863. isOHLC = false;
  8864. }
  8865. return indicator.calculateVWAPValues(isOHLC, xValues, yValues, volumeSeries, period);
  8866. };
  8867. /**
  8868. * Main algorithm used to calculate Volume Weighted Average Price (VWAP)
  8869. * values
  8870. * @private
  8871. * @param {boolean} isOHLC - says if data has OHLC format
  8872. * @param {Array<number>} xValues - array of timestamps
  8873. * @param {Array<number|Array<number,number,number,number>>} yValues -
  8874. * array of yValues, can be an array of a four arrays (OHLC) or array of
  8875. * values (line)
  8876. * @param {Array<*>} volumeSeries - volume series
  8877. * @param {number} period - number of points to be calculated
  8878. * @return {object} - Object contains computed VWAP
  8879. **/
  8880. VWAPIndicator.prototype.calculateVWAPValues = function (isOHLC, xValues, yValues, volumeSeries, period) {
  8881. var volumeValues = volumeSeries.yData,
  8882. volumeLength = volumeSeries.xData.length,
  8883. pointsLength = xValues.length,
  8884. cumulativePrice = [],
  8885. cumulativeVolume = [],
  8886. xData = [],
  8887. yData = [],
  8888. VWAP = [],
  8889. commonLength,
  8890. typicalPrice,
  8891. cPrice,
  8892. cVolume,
  8893. i,
  8894. j;
  8895. if (pointsLength <= volumeLength) {
  8896. commonLength = pointsLength;
  8897. }
  8898. else {
  8899. commonLength = volumeLength;
  8900. }
  8901. for (i = 0, j = 0; i < commonLength; i++) {
  8902. // Depending on whether series is OHLC or line type, price is
  8903. // average of the high, low and close or a simple value
  8904. typicalPrice = isOHLC ?
  8905. ((yValues[i][1] + yValues[i][2] +
  8906. yValues[i][3]) / 3) :
  8907. yValues[i];
  8908. typicalPrice *= volumeValues[i];
  8909. cPrice = j ?
  8910. (cumulativePrice[i - 1] + typicalPrice) :
  8911. typicalPrice;
  8912. cVolume = j ?
  8913. (cumulativeVolume[i - 1] + volumeValues[i]) :
  8914. volumeValues[i];
  8915. cumulativePrice.push(cPrice);
  8916. cumulativeVolume.push(cVolume);
  8917. VWAP.push([xValues[i], (cPrice / cVolume)]);
  8918. xData.push(VWAP[i][0]);
  8919. yData.push(VWAP[i][1]);
  8920. j++;
  8921. if (j === period) {
  8922. j = 0;
  8923. }
  8924. }
  8925. return {
  8926. values: VWAP,
  8927. xData: xData,
  8928. yData: yData
  8929. };
  8930. };
  8931. /**
  8932. * Volume Weighted Average Price indicator.
  8933. *
  8934. * This series requires `linkedTo` option to be set.
  8935. *
  8936. * @sample stock/indicators/vwap
  8937. * Volume Weighted Average Price indicator
  8938. *
  8939. * @extends plotOptions.sma
  8940. * @since 6.0.0
  8941. * @product highstock
  8942. * @requires stock/indicators/indicators
  8943. * @requires stock/indicators/vwap
  8944. * @optionparent plotOptions.vwap
  8945. */
  8946. VWAPIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  8947. /**
  8948. * @excluding index
  8949. */
  8950. params: {
  8951. period: 30,
  8952. /**
  8953. * The id of volume series which is mandatory. For example using
  8954. * OHLC data, volumeSeriesID='volume' means the indicator will be
  8955. * calculated using OHLC and volume values.
  8956. */
  8957. volumeSeriesID: 'volume'
  8958. }
  8959. });
  8960. return VWAPIndicator;
  8961. }(SMAIndicator));
  8962. SeriesRegistry.registerSeriesType('vwap', VWAPIndicator);
  8963. /* *
  8964. *
  8965. * Default Export
  8966. *
  8967. * */
  8968. /**
  8969. * A `Volume Weighted Average Price (VWAP)` series. If the
  8970. * [type](#series.vwap.type) option is not specified, it is inherited from
  8971. * [chart.type](#chart.type).
  8972. *
  8973. * @extends series,plotOptions.vwap
  8974. * @since 6.0.0
  8975. * @product highstock
  8976. * @excluding dataParser, dataURL
  8977. * @requires stock/indicators/indicators
  8978. * @requires stock/indicators/vwap
  8979. * @apioption series.vwap
  8980. */
  8981. ''; // to include the above in the js output
  8982. return VWAPIndicator;
  8983. });
  8984. _registerModule(_modules, 'Stock/Indicators/WilliamsR/WilliamsRIndicator.js', [_modules['Mixins/ReduceArray.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (ReduceArrayMixin, SeriesRegistry, U) {
  8985. /* *
  8986. *
  8987. * License: www.highcharts.com/license
  8988. *
  8989. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8990. *
  8991. * */
  8992. var __extends = (this && this.__extends) || (function () {
  8993. var extendStatics = function (d,
  8994. b) {
  8995. extendStatics = Object.setPrototypeOf ||
  8996. ({ __proto__: [] } instanceof Array && function (d,
  8997. b) { d.__proto__ = b; }) ||
  8998. function (d,
  8999. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  9000. return extendStatics(d, b);
  9001. };
  9002. return function (d, b) {
  9003. extendStatics(d, b);
  9004. function __() { this.constructor = d; }
  9005. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9006. };
  9007. })();
  9008. var getArrayExtremes = ReduceArrayMixin.getArrayExtremes;
  9009. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  9010. var extend = U.extend,
  9011. isArray = U.isArray,
  9012. merge = U.merge;
  9013. /**
  9014. * The Williams %R series type.
  9015. *
  9016. * @private
  9017. * @class
  9018. * @name Highcharts.seriesTypes.williamsr
  9019. *
  9020. * @augments Highcharts.Series
  9021. */
  9022. var WilliamsRIndicator = /** @class */ (function (_super) {
  9023. __extends(WilliamsRIndicator, _super);
  9024. function WilliamsRIndicator() {
  9025. var _this = _super !== null && _super.apply(this,
  9026. arguments) || this;
  9027. _this.data = void 0;
  9028. _this.options = void 0;
  9029. _this.points = void 0;
  9030. return _this;
  9031. }
  9032. WilliamsRIndicator.prototype.getValues = function (series, params) {
  9033. var period = params.period,
  9034. xVal = series.xData,
  9035. yVal = series.yData,
  9036. yValLen = yVal ? yVal.length : 0,
  9037. WR = [], // 0- date, 1- Williams %R
  9038. xData = [],
  9039. yData = [],
  9040. slicedY,
  9041. close = 3,
  9042. low = 2,
  9043. high = 1,
  9044. extremes,
  9045. R,
  9046. HH, // Highest high value in period
  9047. LL, // Lowest low value in period
  9048. CC, // Current close value
  9049. i;
  9050. // Williams %R requires close value
  9051. if (xVal.length < period ||
  9052. !isArray(yVal[0]) ||
  9053. yVal[0].length !== 4) {
  9054. return;
  9055. }
  9056. // For a N-period, we start from N-1 point, to calculate Nth point
  9057. // That is why we later need to comprehend slice() elements list
  9058. // with (+1)
  9059. for (i = period - 1; i < yValLen; i++) {
  9060. slicedY = yVal.slice(i - period + 1, i + 1);
  9061. extremes = getArrayExtremes(slicedY, low, high);
  9062. LL = extremes[0];
  9063. HH = extremes[1];
  9064. CC = yVal[i][close];
  9065. R = ((HH - CC) / (HH - LL)) * -100;
  9066. if (xVal[i]) {
  9067. WR.push([xVal[i], R]);
  9068. xData.push(xVal[i]);
  9069. yData.push(R);
  9070. }
  9071. }
  9072. return {
  9073. values: WR,
  9074. xData: xData,
  9075. yData: yData
  9076. };
  9077. };
  9078. /**
  9079. * Williams %R. This series requires the `linkedTo` option to be
  9080. * set and should be loaded after the `stock/indicators/indicators.js`.
  9081. *
  9082. * @sample {highstock} stock/indicators/williams-r
  9083. * Williams %R
  9084. *
  9085. * @extends plotOptions.sma
  9086. * @since 7.0.0
  9087. * @product highstock
  9088. * @excluding allAreas, colorAxis, joinBy, keys, navigatorOptions,
  9089. * pointInterval, pointIntervalUnit, pointPlacement,
  9090. * pointRange, pointStart, showInNavigator, stacking
  9091. * @requires stock/indicators/indicators
  9092. * @requires stock/indicators/williams-r
  9093. * @optionparent plotOptions.williamsr
  9094. */
  9095. WilliamsRIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  9096. /**
  9097. * Paramters used in calculation of Williams %R series points.
  9098. * @excluding index
  9099. */
  9100. params: {
  9101. /**
  9102. * Period for Williams %R oscillator
  9103. */
  9104. period: 14
  9105. }
  9106. });
  9107. return WilliamsRIndicator;
  9108. }(SMAIndicator));
  9109. extend(WilliamsRIndicator.prototype, {
  9110. nameBase: 'Williams %R'
  9111. });
  9112. SeriesRegistry.registerSeriesType('williamsr', WilliamsRIndicator);
  9113. /* *
  9114. *
  9115. * Default Export
  9116. *
  9117. * */
  9118. /**
  9119. * A `Williams %R Oscillator` series. If the [type](#series.williamsr.type)
  9120. * option is not specified, it is inherited from [chart.type](#chart.type).
  9121. *
  9122. * @extends series,plotOptions.williamsr
  9123. * @since 7.0.0
  9124. * @product highstock
  9125. * @excluding allAreas, colorAxis, dataParser, dataURL, joinBy, keys,
  9126. * navigatorOptions, pointInterval, pointIntervalUnit,
  9127. * pointPlacement, pointRange, pointStart, showInNavigator, stacking
  9128. * @requires stock/indicators/indicators
  9129. * @requires stock/indicators/williams-r
  9130. * @apioption series.williamsr
  9131. */
  9132. ''; // adds doclets above to the transpiled file
  9133. return WilliamsRIndicator;
  9134. });
  9135. _registerModule(_modules, 'Stock/Indicators/WMA/WMAIndicator.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  9136. /* *
  9137. *
  9138. * (c) 2010-2021 Kacper Madej
  9139. *
  9140. * License: www.highcharts.com/license
  9141. *
  9142. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  9143. *
  9144. * */
  9145. var __extends = (this && this.__extends) || (function () {
  9146. var extendStatics = function (d,
  9147. b) {
  9148. extendStatics = Object.setPrototypeOf ||
  9149. ({ __proto__: [] } instanceof Array && function (d,
  9150. b) { d.__proto__ = b; }) ||
  9151. function (d,
  9152. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  9153. return extendStatics(d, b);
  9154. };
  9155. return function (d, b) {
  9156. extendStatics(d, b);
  9157. function __() { this.constructor = d; }
  9158. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9159. };
  9160. })();
  9161. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  9162. var isArray = U.isArray,
  9163. merge = U.merge;
  9164. /* eslint-disable valid-jsdoc */
  9165. // Utils:
  9166. /**
  9167. * @private
  9168. */
  9169. function accumulateAverage(points, xVal, yVal, i, index) {
  9170. var xValue = xVal[i],
  9171. yValue = index < 0 ? yVal[i] : yVal[i][index];
  9172. points.push([xValue, yValue]);
  9173. }
  9174. /**
  9175. * @private
  9176. */
  9177. function weightedSumArray(array, pLen) {
  9178. // The denominator is the sum of the number of days as a triangular number.
  9179. // If there are 5 days, the triangular numbers are 5, 4, 3, 2, and 1.
  9180. // The sum is 5 + 4 + 3 + 2 + 1 = 15.
  9181. var denominator = (pLen + 1) / 2 * pLen;
  9182. // reduce VS loop => reduce
  9183. return array.reduce(function (prev, cur, i) {
  9184. return [null, prev[1] + cur[1] * (i + 1)];
  9185. })[1] / denominator;
  9186. }
  9187. /**
  9188. * @private
  9189. */
  9190. function populateAverage(points, xVal, yVal, i) {
  9191. var pLen = points.length,
  9192. wmaY = weightedSumArray(points,
  9193. pLen),
  9194. wmaX = xVal[i - 1];
  9195. points.shift(); // remove point until range < period
  9196. return [wmaX, wmaY];
  9197. }
  9198. /* eslint-enable valid-jsdoc */
  9199. /**
  9200. * The SMA series type.
  9201. *
  9202. * @private
  9203. * @class
  9204. * @name Highcharts.seriesTypes.wma
  9205. *
  9206. * @augments Highcharts.Series
  9207. */
  9208. var WMAIndicator = /** @class */ (function (_super) {
  9209. __extends(WMAIndicator, _super);
  9210. function WMAIndicator() {
  9211. var _this = _super !== null && _super.apply(this,
  9212. arguments) || this;
  9213. _this.data = void 0;
  9214. _this.options = void 0;
  9215. _this.points = void 0;
  9216. return _this;
  9217. }
  9218. WMAIndicator.prototype.getValues = function (series, params) {
  9219. var period = params.period,
  9220. xVal = series.xData,
  9221. yVal = series.yData,
  9222. yValLen = yVal ? yVal.length : 0,
  9223. range = 1,
  9224. xValue = xVal[0],
  9225. yValue = yVal[0],
  9226. WMA = [],
  9227. xData = [],
  9228. yData = [],
  9229. index = -1,
  9230. i,
  9231. points,
  9232. WMAPoint;
  9233. if (xVal.length < period) {
  9234. return;
  9235. }
  9236. // Switch index for OHLC / Candlestick
  9237. if (isArray(yVal[0])) {
  9238. index = params.index;
  9239. yValue = yVal[0][index];
  9240. }
  9241. // Starting point
  9242. points = [[xValue, yValue]];
  9243. // Accumulate first N-points
  9244. while (range !== period) {
  9245. accumulateAverage(points, xVal, yVal, range, index);
  9246. range++;
  9247. }
  9248. // Calculate value one-by-one for each period in visible data
  9249. for (i = range; i < yValLen; i++) {
  9250. WMAPoint = populateAverage(points, xVal, yVal, i);
  9251. WMA.push(WMAPoint);
  9252. xData.push(WMAPoint[0]);
  9253. yData.push(WMAPoint[1]);
  9254. accumulateAverage(points, xVal, yVal, i, index);
  9255. }
  9256. WMAPoint = populateAverage(points, xVal, yVal, i);
  9257. WMA.push(WMAPoint);
  9258. xData.push(WMAPoint[0]);
  9259. yData.push(WMAPoint[1]);
  9260. return {
  9261. values: WMA,
  9262. xData: xData,
  9263. yData: yData
  9264. };
  9265. };
  9266. /**
  9267. * Weighted moving average indicator (WMA). This series requires `linkedTo`
  9268. * option to be set.
  9269. *
  9270. * @sample stock/indicators/wma
  9271. * Weighted moving average indicator
  9272. *
  9273. * @extends plotOptions.sma
  9274. * @since 6.0.0
  9275. * @product highstock
  9276. * @requires stock/indicators/indicators
  9277. * @requires stock/indicators/wma
  9278. * @optionparent plotOptions.wma
  9279. */
  9280. WMAIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  9281. params: {
  9282. index: 3,
  9283. period: 9
  9284. }
  9285. });
  9286. return WMAIndicator;
  9287. }(SMAIndicator));
  9288. SeriesRegistry.registerSeriesType('wma', WMAIndicator);
  9289. /* *
  9290. *
  9291. * Default Export
  9292. *
  9293. * */
  9294. /**
  9295. * A `WMA` series. If the [type](#series.wma.type) option is not specified, it
  9296. * is inherited from [chart.type](#chart.type).
  9297. *
  9298. * @extends series,plotOptions.wma
  9299. * @since 6.0.0
  9300. * @product highstock
  9301. * @excluding dataParser, dataURL
  9302. * @requires stock/indicators/indicators
  9303. * @requires stock/indicators/wma
  9304. * @apioption series.wma
  9305. */
  9306. ''; // adds doclet above to the transpiled file
  9307. return WMAIndicator;
  9308. });
  9309. _registerModule(_modules, 'Stock/Indicators/Zigzag/ZigzagIndicator.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  9310. /* *
  9311. *
  9312. * (c) 2010-2021 Kacper Madej
  9313. *
  9314. * License: www.highcharts.com/license
  9315. *
  9316. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  9317. *
  9318. * */
  9319. var __extends = (this && this.__extends) || (function () {
  9320. var extendStatics = function (d,
  9321. b) {
  9322. extendStatics = Object.setPrototypeOf ||
  9323. ({ __proto__: [] } instanceof Array && function (d,
  9324. b) { d.__proto__ = b; }) ||
  9325. function (d,
  9326. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  9327. return extendStatics(d, b);
  9328. };
  9329. return function (d, b) {
  9330. extendStatics(d, b);
  9331. function __() { this.constructor = d; }
  9332. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9333. };
  9334. })();
  9335. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  9336. var merge = U.merge,
  9337. extend = U.extend;
  9338. /* *
  9339. *
  9340. * Class
  9341. *
  9342. * */
  9343. /**
  9344. * The Zig Zag series type.
  9345. *
  9346. * @private
  9347. * @class
  9348. * @name Highcharts.seriesTypes.zigzag
  9349. *
  9350. * @augments Highcharts.Series
  9351. */
  9352. var ZigzagIndicator = /** @class */ (function (_super) {
  9353. __extends(ZigzagIndicator, _super);
  9354. function ZigzagIndicator() {
  9355. var _this = _super !== null && _super.apply(this,
  9356. arguments) || this;
  9357. /* *
  9358. *
  9359. * Properties
  9360. *
  9361. * */
  9362. _this.data = void 0;
  9363. _this.points = void 0;
  9364. _this.options = void 0;
  9365. return _this;
  9366. }
  9367. /* *
  9368. *
  9369. * Functions
  9370. *
  9371. * */
  9372. ZigzagIndicator.prototype.getValues = function (series, params) {
  9373. var lowIndex = params.lowIndex,
  9374. highIndex = params.highIndex,
  9375. deviation = params.deviation / 100,
  9376. deviations = {
  9377. 'low': 1 + deviation,
  9378. 'high': 1 - deviation
  9379. },
  9380. xVal = series.xData,
  9381. yVal = series.yData,
  9382. yValLen = yVal ? yVal.length : 0,
  9383. zigzag = [],
  9384. xData = [],
  9385. yData = [],
  9386. i,
  9387. j,
  9388. zigzagPoint,
  9389. firstZigzagLow,
  9390. firstZigzagHigh,
  9391. directionUp,
  9392. zigzagLen,
  9393. exitLoop = false,
  9394. yIndex = false;
  9395. // Exit if not enught points or no low or high values
  9396. if (!xVal || xVal.length <= 1 ||
  9397. (yValLen &&
  9398. (typeof yVal[0][lowIndex] === 'undefined' ||
  9399. typeof yVal[0][highIndex] === 'undefined'))) {
  9400. return;
  9401. }
  9402. // Set first zigzag point candidate
  9403. firstZigzagLow = yVal[0][lowIndex];
  9404. firstZigzagHigh = yVal[0][highIndex];
  9405. // Search for a second zigzag point candidate,
  9406. // this will also set first zigzag point
  9407. for (i = 1; i < yValLen; i++) {
  9408. // requried change to go down
  9409. if (yVal[i][lowIndex] <= firstZigzagHigh * deviations.high) {
  9410. zigzag.push([xVal[0], firstZigzagHigh]);
  9411. // second zigzag point candidate
  9412. zigzagPoint = [xVal[i], yVal[i][lowIndex]];
  9413. // next line will be going up
  9414. directionUp = true;
  9415. exitLoop = true;
  9416. // requried change to go up
  9417. }
  9418. else if (yVal[i][highIndex] >= firstZigzagLow * deviations.low) {
  9419. zigzag.push([xVal[0], firstZigzagLow]);
  9420. // second zigzag point candidate
  9421. zigzagPoint = [xVal[i], yVal[i][highIndex]];
  9422. // next line will be going down
  9423. directionUp = false;
  9424. exitLoop = true;
  9425. }
  9426. if (exitLoop) {
  9427. xData.push(zigzag[0][0]);
  9428. yData.push(zigzag[0][1]);
  9429. j = i++;
  9430. i = yValLen;
  9431. }
  9432. }
  9433. // Search for next zigzags
  9434. for (i = j; i < yValLen; i++) {
  9435. if (directionUp) { // next line up
  9436. // lower when going down -> change zigzag candidate
  9437. if (yVal[i][lowIndex] <= zigzagPoint[1]) {
  9438. zigzagPoint = [xVal[i], yVal[i][lowIndex]];
  9439. }
  9440. // requried change to go down -> new zigzagpoint and
  9441. // direction change
  9442. if (yVal[i][highIndex] >=
  9443. zigzagPoint[1] * deviations.low) {
  9444. yIndex = highIndex;
  9445. }
  9446. }
  9447. else { // next line down
  9448. // higher when going up -> change zigzag candidate
  9449. if (yVal[i][highIndex] >= zigzagPoint[1]) {
  9450. zigzagPoint = [xVal[i], yVal[i][highIndex]];
  9451. }
  9452. // requried change to go down -> new zigzagpoint and
  9453. // direction change
  9454. if (yVal[i][lowIndex] <=
  9455. zigzagPoint[1] * deviations.high) {
  9456. yIndex = lowIndex;
  9457. }
  9458. }
  9459. if (yIndex !== false) { // new zigzag point and direction change
  9460. zigzag.push(zigzagPoint);
  9461. xData.push(zigzagPoint[0]);
  9462. yData.push(zigzagPoint[1]);
  9463. zigzagPoint = [xVal[i], yVal[i][yIndex]];
  9464. directionUp = !directionUp;
  9465. yIndex = false;
  9466. }
  9467. }
  9468. zigzagLen = zigzag.length;
  9469. // no zigzag for last point
  9470. if (zigzagLen !== 0 &&
  9471. zigzag[zigzagLen - 1][0] < xVal[yValLen - 1]) {
  9472. // set last point from zigzag candidate
  9473. zigzag.push(zigzagPoint);
  9474. xData.push(zigzagPoint[0]);
  9475. yData.push(zigzagPoint[1]);
  9476. }
  9477. return {
  9478. values: zigzag,
  9479. xData: xData,
  9480. yData: yData
  9481. };
  9482. };
  9483. /**
  9484. * Zig Zag indicator.
  9485. *
  9486. * This series requires `linkedTo` option to be set.
  9487. *
  9488. * @sample stock/indicators/zigzag
  9489. * Zig Zag indicator
  9490. *
  9491. * @extends plotOptions.sma
  9492. * @since 6.0.0
  9493. * @product highstock
  9494. * @requires stock/indicators/indicators
  9495. * @requires stock/indicators/zigzag
  9496. * @optionparent plotOptions.zigzag
  9497. */
  9498. ZigzagIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  9499. /**
  9500. * @excluding index, period
  9501. */
  9502. params: {
  9503. /**
  9504. * The point index which indicator calculations will base - low
  9505. * value.
  9506. *
  9507. * For example using OHLC data, index=2 means the indicator will be
  9508. * calculated using Low values.
  9509. */
  9510. lowIndex: 2,
  9511. /**
  9512. * The point index which indicator calculations will base - high
  9513. * value.
  9514. *
  9515. * For example using OHLC data, index=1 means the indicator will be
  9516. * calculated using High values.
  9517. */
  9518. highIndex: 1,
  9519. /**
  9520. * The threshold for the value change.
  9521. *
  9522. * For example deviation=1 means the indicator will ignore all price
  9523. * movements less than 1%.
  9524. */
  9525. deviation: 1
  9526. }
  9527. });
  9528. return ZigzagIndicator;
  9529. }(SMAIndicator));
  9530. extend(ZigzagIndicator.prototype, {
  9531. nameComponents: ['deviation'],
  9532. nameSuffixes: ['%'],
  9533. nameBase: 'Zig Zag'
  9534. });
  9535. SeriesRegistry.registerSeriesType('zigzag', ZigzagIndicator);
  9536. /* *
  9537. *
  9538. * Default Export
  9539. *
  9540. * */
  9541. /**
  9542. * A `Zig Zag` series. If the [type](#series.zigzag.type) option is not
  9543. * specified, it is inherited from [chart.type](#chart.type).
  9544. *
  9545. * @extends series,plotOptions.zigzag
  9546. * @since 6.0.0
  9547. * @product highstock
  9548. * @excluding dataParser, dataURL
  9549. * @requires stock/indicators/indicators
  9550. * @requires stock/indicators/zigzag
  9551. * @apioption series.zigzag
  9552. */
  9553. ''; // adds doclets above to transpiled file
  9554. return ZigzagIndicator;
  9555. });
  9556. _registerModule(_modules, 'Stock/Indicators/LinearRegression/LinearRegression.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  9557. /**
  9558. *
  9559. * (c) 2010-2021 Kamil Kulig
  9560. *
  9561. * License: www.highcharts.com/license
  9562. *
  9563. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  9564. *
  9565. * */
  9566. var __extends = (this && this.__extends) || (function () {
  9567. var extendStatics = function (d,
  9568. b) {
  9569. extendStatics = Object.setPrototypeOf ||
  9570. ({ __proto__: [] } instanceof Array && function (d,
  9571. b) { d.__proto__ = b; }) ||
  9572. function (d,
  9573. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  9574. return extendStatics(d, b);
  9575. };
  9576. return function (d, b) {
  9577. extendStatics(d, b);
  9578. function __() { this.constructor = d; }
  9579. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9580. };
  9581. })();
  9582. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  9583. var isArray = U.isArray,
  9584. extend = U.extend,
  9585. merge = U.merge;
  9586. /* *
  9587. *
  9588. * Class
  9589. *
  9590. * */
  9591. /**
  9592. * Linear regression series type.
  9593. *
  9594. * @private
  9595. * @class
  9596. * @name Highcharts.seriesTypes.linearregression
  9597. *
  9598. * @augments Highcharts.Series
  9599. */
  9600. var LinearRegressionIndicator = /** @class */ (function (_super) {
  9601. __extends(LinearRegressionIndicator, _super);
  9602. function LinearRegressionIndicator() {
  9603. var _this = _super !== null && _super.apply(this,
  9604. arguments) || this;
  9605. /* *
  9606. *
  9607. * Properties
  9608. *
  9609. * */
  9610. _this.data = void 0;
  9611. _this.options = void 0;
  9612. _this.points = void 0;
  9613. return _this;
  9614. }
  9615. /* *
  9616. *
  9617. * Functions
  9618. *
  9619. * */
  9620. /**
  9621. * Return the slope and intercept of a straight line function.
  9622. * @private
  9623. * @param {Highcharts.LinearRegressionIndicator} this indicator to use
  9624. * @param {Array<number>} xData - list of all x coordinates in a period
  9625. * @param {Array<number>} yData - list of all y coordinates in a period
  9626. * @return {Highcharts.RegressionLineParametersObject}
  9627. * object that contains the slope and the intercept
  9628. * of a straight line function
  9629. */
  9630. LinearRegressionIndicator.prototype.getRegressionLineParameters = function (xData, yData) {
  9631. // least squares method
  9632. var yIndex = this.options.params.index,
  9633. getSingleYValue = function (yValue,
  9634. yIndex) {
  9635. return isArray(yValue) ? yValue[yIndex] : yValue;
  9636. }, xSum = xData.reduce(function (accX, val) {
  9637. return val + accX;
  9638. }, 0), ySum = yData.reduce(function (accY, val) {
  9639. return getSingleYValue(val, yIndex) + accY;
  9640. }, 0), xMean = xSum / xData.length, yMean = ySum / yData.length, xError, yError, formulaNumerator = 0, formulaDenominator = 0, i, slope;
  9641. for (i = 0; i < xData.length; i++) {
  9642. xError = xData[i] - xMean;
  9643. yError = getSingleYValue(yData[i], yIndex) - yMean;
  9644. formulaNumerator += xError * yError;
  9645. formulaDenominator += Math.pow(xError, 2);
  9646. }
  9647. slope = formulaDenominator ?
  9648. formulaNumerator / formulaDenominator : 0; // don't divide by 0
  9649. return {
  9650. slope: slope,
  9651. intercept: yMean - slope * xMean
  9652. };
  9653. };
  9654. /**
  9655. * Return the y value on a straight line.
  9656. * @private
  9657. * @param {Highcharts.RegressionLineParametersObject} lineParameters
  9658. * object that contains the slope and the intercept
  9659. * of a straight line function
  9660. * @param {number} endPointX - x coordinate of the point
  9661. * @return {number} - y value of the point that lies on the line
  9662. */
  9663. LinearRegressionIndicator.prototype.getEndPointY = function (lineParameters, endPointX) {
  9664. return lineParameters.slope * endPointX + lineParameters.intercept;
  9665. };
  9666. /**
  9667. * Transform the coordinate system so that x values start at 0 and
  9668. * apply xAxisUnit.
  9669. * @private
  9670. * @param {Array<number>} xData - list of all x coordinates in a period
  9671. * @param {number} xAxisUnit - option (see the API)
  9672. * @return {Array<number>} - array of transformed x data
  9673. */
  9674. LinearRegressionIndicator.prototype.transformXData = function (xData, xAxisUnit) {
  9675. var xOffset = xData[0];
  9676. return xData.map(function (xValue) {
  9677. return (xValue - xOffset) / xAxisUnit;
  9678. });
  9679. };
  9680. /**
  9681. * Find the closest distance between points in the base series.
  9682. * @private
  9683. * @param {Array<number>} xData list of all x coordinates in the base series
  9684. * @return {number} - closest distance between points in the base series
  9685. */
  9686. LinearRegressionIndicator.prototype.findClosestDistance = function (xData) {
  9687. var distance,
  9688. closestDistance,
  9689. i;
  9690. for (i = 1; i < xData.length - 1; i++) {
  9691. distance = xData[i] - xData[i - 1];
  9692. if (distance > 0 &&
  9693. (typeof closestDistance === 'undefined' ||
  9694. distance < closestDistance)) {
  9695. closestDistance = distance;
  9696. }
  9697. }
  9698. return closestDistance;
  9699. };
  9700. // Required to be implemented - starting point for indicator's logic
  9701. LinearRegressionIndicator.prototype.getValues = function (baseSeries, regressionSeriesParams) {
  9702. var xData = baseSeries.xData,
  9703. yData = baseSeries.yData,
  9704. period = regressionSeriesParams.period,
  9705. lineParameters,
  9706. i,
  9707. periodStart,
  9708. periodEnd,
  9709. // format required to be returned
  9710. indicatorData = {
  9711. xData: [],
  9712. yData: [],
  9713. values: []
  9714. },
  9715. endPointX,
  9716. endPointY,
  9717. periodXData,
  9718. periodYData,
  9719. periodTransformedXData,
  9720. xAxisUnit = this.options.params.xAxisUnit ||
  9721. this.findClosestDistance(xData);
  9722. // Iteration logic: x value of the last point within the period
  9723. // (end point) is used to represent the y value (regression)
  9724. // of the entire period.
  9725. for (i = period - 1; i <= xData.length - 1; i++) {
  9726. periodStart = i - period + 1; // adjusted for slice() function
  9727. periodEnd = i + 1; // (as above)
  9728. endPointX = xData[i];
  9729. periodXData = xData.slice(periodStart, periodEnd);
  9730. periodYData = yData.slice(periodStart, periodEnd);
  9731. periodTransformedXData = this.transformXData(periodXData, xAxisUnit);
  9732. lineParameters = this.getRegressionLineParameters(periodTransformedXData, periodYData);
  9733. endPointY = this.getEndPointY(lineParameters, periodTransformedXData[periodTransformedXData.length - 1]);
  9734. // @todo this is probably not used anywhere
  9735. indicatorData.values.push({
  9736. regressionLineParameters: lineParameters,
  9737. x: endPointX,
  9738. y: endPointY
  9739. });
  9740. indicatorData.xData.push(endPointX);
  9741. indicatorData.yData.push(endPointY);
  9742. }
  9743. return indicatorData;
  9744. };
  9745. /**
  9746. * Linear regression indicator. This series requires `linkedTo` option to be
  9747. * set.
  9748. *
  9749. * @sample {highstock} stock/indicators/linear-regression
  9750. * Linear regression indicator
  9751. *
  9752. * @extends plotOptions.sma
  9753. * @since 7.0.0
  9754. * @product highstock
  9755. * @requires stock/indicators/indicators
  9756. * @requires stock/indicators/linearregression
  9757. * @optionparent plotOptions.linearregression
  9758. */
  9759. LinearRegressionIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  9760. params: {
  9761. /**
  9762. * Unit (in milliseconds) for the x axis distances used to
  9763. * compute the regression line paramters (slope & intercept) for
  9764. * every range. In Highstock the x axis values are always
  9765. * represented in milliseconds which may cause that distances
  9766. * between points are "big" integer numbers.
  9767. *
  9768. * Highstock's linear regression algorithm (least squares
  9769. * method) will utilize these "big" integers for finding the
  9770. * slope and the intercept of the regression line for each
  9771. * period. In consequence, this value may be a very "small"
  9772. * decimal number that's hard to interpret by a human.
  9773. *
  9774. * For instance: `xAxisUnit` equealed to `86400000` ms (1 day)
  9775. * forces the algorithm to treat `86400000` as `1` while
  9776. * computing the slope and the intercept. This may enchance the
  9777. * legiblitity of the indicator's values.
  9778. *
  9779. * Default value is the closest distance between two data
  9780. * points.
  9781. *
  9782. * @sample {highstock} stock/plotoptions/linear-regression-xaxisunit
  9783. * xAxisUnit set to 1 minute
  9784. *
  9785. * @example
  9786. * // In Liniear Regression Slope Indicator series `xAxisUnit`is
  9787. * // `86400000` (1 day) and period is `3`. There're 3 points in
  9788. * // the base series:
  9789. *
  9790. * data: [
  9791. * [Date.UTC(2020, 0, 1), 1],
  9792. * [Date.UTC(2020, 0, 2), 3],
  9793. * [Date.UTC(2020, 0, 3), 5]
  9794. * ]
  9795. *
  9796. * // This will produce one point in the indicator series that
  9797. * // has a `y` value of `2` (slope of the regression line). If
  9798. * // we change the `xAxisUnit` to `1` (ms) the value of the
  9799. * // indicator's point will be `2.3148148148148148e-8` which is
  9800. * // harder to interpert for a human.
  9801. *
  9802. * @type {number}
  9803. * @product highstock
  9804. */
  9805. xAxisUnit: void 0
  9806. },
  9807. tooltip: {
  9808. valueDecimals: 4
  9809. }
  9810. });
  9811. return LinearRegressionIndicator;
  9812. }(SMAIndicator));
  9813. extend(LinearRegressionIndicator.prototype, {
  9814. nameBase: 'Linear Regression Indicator'
  9815. });
  9816. SeriesRegistry.registerSeriesType('linearRegression', LinearRegressionIndicator);
  9817. /* *
  9818. *
  9819. * Default Export
  9820. *
  9821. * */
  9822. /**
  9823. * A linear regression series. If the
  9824. * [type](#series.linearregression.type) option is not specified, it is
  9825. * inherited from [chart.type](#chart.type).
  9826. *
  9827. * @extends series,plotOptions.linearregression
  9828. * @since 7.0.0
  9829. * @product highstock
  9830. * @excluding dataParser,dataURL
  9831. * @requires stock/indicators/indicators
  9832. * @requires stock/indicators/linearregression
  9833. * @apioption series.linearregression
  9834. */
  9835. ''; // to include the above in the js output
  9836. return LinearRegressionIndicator;
  9837. });
  9838. _registerModule(_modules, 'Stock/Indicators/LinearRegressionSlopes/LinearRegressionSlopes.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  9839. /**
  9840. *
  9841. * (c) 2010-2021 Kamil Kulig
  9842. *
  9843. * License: www.highcharts.com/license
  9844. *
  9845. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  9846. *
  9847. * */
  9848. var __extends = (this && this.__extends) || (function () {
  9849. var extendStatics = function (d,
  9850. b) {
  9851. extendStatics = Object.setPrototypeOf ||
  9852. ({ __proto__: [] } instanceof Array && function (d,
  9853. b) { d.__proto__ = b; }) ||
  9854. function (d,
  9855. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  9856. return extendStatics(d, b);
  9857. };
  9858. return function (d, b) {
  9859. extendStatics(d, b);
  9860. function __() { this.constructor = d; }
  9861. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9862. };
  9863. })();
  9864. var _a = SeriesRegistry.seriesTypes,
  9865. SMAIndicator = _a.sma,
  9866. LinearRegressionIndicator = _a.linearRegression;
  9867. var isArray = U.isArray,
  9868. extend = U.extend,
  9869. merge = U.merge;
  9870. /* *
  9871. *
  9872. * Class
  9873. *
  9874. * */
  9875. /**
  9876. * The Linear Regression Slope series type.
  9877. *
  9878. * @private
  9879. * @class
  9880. * @name Highcharts.seriesTypes.linearRegressionSlope
  9881. *
  9882. * @augments Highcharts.Series
  9883. */
  9884. var LinearRegressionSlopesIndicator = /** @class */ (function (_super) {
  9885. __extends(LinearRegressionSlopesIndicator, _super);
  9886. function LinearRegressionSlopesIndicator() {
  9887. var _this = _super !== null && _super.apply(this,
  9888. arguments) || this;
  9889. /* *
  9890. *
  9891. * Properties
  9892. *
  9893. * */
  9894. _this.data = void 0;
  9895. _this.options = void 0;
  9896. _this.points = void 0;
  9897. return _this;
  9898. }
  9899. /* *
  9900. *
  9901. * Functions
  9902. *
  9903. * */
  9904. LinearRegressionSlopesIndicator.prototype.getEndPointY = function (lineParameters) {
  9905. return lineParameters.slope;
  9906. };
  9907. /**
  9908. * Linear regression slope indicator. This series requires `linkedTo`
  9909. * option to be set.
  9910. *
  9911. * @sample {highstock} stock/indicators/linear-regression-slope
  9912. * Linear regression slope indicator
  9913. *
  9914. * @extends plotOptions.linearregression
  9915. * @since 7.0.0
  9916. * @product highstock
  9917. * @requires stock/indicators/indicators
  9918. * @requires stock/indicators/linearregression
  9919. * @optionparent plotOptions.linearregressionslope
  9920. */
  9921. LinearRegressionSlopesIndicator.defaultOptions = merge(LinearRegressionIndicator.defaultOptions);
  9922. return LinearRegressionSlopesIndicator;
  9923. }(LinearRegressionIndicator));
  9924. extend(LinearRegressionSlopesIndicator.prototype, {
  9925. nameBase: 'Linear Regression Slope Indicator'
  9926. });
  9927. SeriesRegistry.registerSeriesType('linearRegressionSlope', LinearRegressionSlopesIndicator);
  9928. /* *
  9929. *
  9930. * Default Export
  9931. *
  9932. * */
  9933. /**
  9934. * A linear regression intercept series. If the
  9935. * [type](#series.linearregressionslope.type) option is not specified, it is
  9936. * inherited from [chart.type](#chart.type).
  9937. *
  9938. * @extends series,plotOptions.linearregressionslope
  9939. * @since 7.0.0
  9940. * @product highstock
  9941. * @excluding dataParser,dataURL
  9942. * @requires stock/indicators/indicators
  9943. * @requires stock/indicators/linearregressionslope
  9944. * @apioption series.linearregressionslope
  9945. */
  9946. ''; // to include the above in the js output
  9947. return LinearRegressionSlopesIndicator;
  9948. });
  9949. _registerModule(_modules, 'Stock/Indicators/LinearRegressionIntercept/LinearRegressionIntercept.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  9950. /**
  9951. *
  9952. * (c) 2010-2021 Kamil Kulig
  9953. *
  9954. * License: www.highcharts.com/license
  9955. *
  9956. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  9957. *
  9958. * */
  9959. var __extends = (this && this.__extends) || (function () {
  9960. var extendStatics = function (d,
  9961. b) {
  9962. extendStatics = Object.setPrototypeOf ||
  9963. ({ __proto__: [] } instanceof Array && function (d,
  9964. b) { d.__proto__ = b; }) ||
  9965. function (d,
  9966. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  9967. return extendStatics(d, b);
  9968. };
  9969. return function (d, b) {
  9970. extendStatics(d, b);
  9971. function __() { this.constructor = d; }
  9972. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  9973. };
  9974. })();
  9975. var _a = SeriesRegistry.seriesTypes,
  9976. SMAIndicator = _a.sma,
  9977. LinearRegressionIndicator = _a.linearRegression;
  9978. var isArray = U.isArray,
  9979. extend = U.extend,
  9980. merge = U.merge;
  9981. /* *
  9982. *
  9983. * Class
  9984. *
  9985. * */
  9986. /**
  9987. * The Linear Regression Intercept series type.
  9988. *
  9989. * @private
  9990. * @class
  9991. * @name Highcharts.seriesTypes.linearRegressionIntercept
  9992. *
  9993. * @augments Highcharts.Series
  9994. */
  9995. var LinearRegressionInterceptIndicator = /** @class */ (function (_super) {
  9996. __extends(LinearRegressionInterceptIndicator, _super);
  9997. function LinearRegressionInterceptIndicator() {
  9998. var _this = _super !== null && _super.apply(this,
  9999. arguments) || this;
  10000. /* *
  10001. *
  10002. * Properties
  10003. *
  10004. * */
  10005. _this.data = void 0;
  10006. _this.options = void 0;
  10007. _this.points = void 0;
  10008. return _this;
  10009. }
  10010. /* *
  10011. *
  10012. * Functions
  10013. *
  10014. * */
  10015. LinearRegressionInterceptIndicator.prototype.getEndPointY = function (lineParameters) {
  10016. return lineParameters.intercept;
  10017. };
  10018. /**
  10019. * Linear regression intercept indicator. This series requires `linkedTo`
  10020. * option to be set.
  10021. *
  10022. * @sample {highstock} stock/indicators/linear-regression-intercept
  10023. * Linear intercept slope indicator
  10024. *
  10025. * @extends plotOptions.linearregression
  10026. * @since 7.0.0
  10027. * @product highstock
  10028. * @requires stock/indicators/indicators
  10029. * @requires stock/indicators/linearregressionintercept
  10030. * @optionparent plotOptions.linearregressionintercept
  10031. */
  10032. LinearRegressionInterceptIndicator.defaultOptions = merge(LinearRegressionIndicator.defaultOptions);
  10033. return LinearRegressionInterceptIndicator;
  10034. }(LinearRegressionIndicator));
  10035. extend(LinearRegressionInterceptIndicator.prototype, {
  10036. nameBase: 'Linear Regression Intercept Indicator'
  10037. });
  10038. SeriesRegistry.registerSeriesType('linearRegressionIntercept', LinearRegressionInterceptIndicator);
  10039. /* *
  10040. *
  10041. * Default Export
  10042. *
  10043. * */
  10044. /**
  10045. * A linear regression intercept series. If the
  10046. * [type](#series.linearregressionintercept.type) option is not specified, it is
  10047. * inherited from [chart.type](#chart.type).
  10048. *
  10049. * @extends series,plotOptions.linearregressionintercept
  10050. * @since 7.0.0
  10051. * @product highstock
  10052. * @excluding dataParser,dataURL
  10053. * @requires stock/indicators/indicators
  10054. * @requires stock/indicators/linearregressionintercept
  10055. * @apioption series.linearregressionintercept
  10056. */
  10057. ''; // to include the above in the js output
  10058. return LinearRegressionInterceptIndicator;
  10059. });
  10060. _registerModule(_modules, 'Stock/Indicators/LinearRegressionAngle/LinearRegressionAngle.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  10061. /**
  10062. *
  10063. * (c) 2010-2021 Kamil Kulig
  10064. *
  10065. * License: www.highcharts.com/license
  10066. *
  10067. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  10068. *
  10069. * */
  10070. var __extends = (this && this.__extends) || (function () {
  10071. var extendStatics = function (d,
  10072. b) {
  10073. extendStatics = Object.setPrototypeOf ||
  10074. ({ __proto__: [] } instanceof Array && function (d,
  10075. b) { d.__proto__ = b; }) ||
  10076. function (d,
  10077. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10078. return extendStatics(d, b);
  10079. };
  10080. return function (d, b) {
  10081. extendStatics(d, b);
  10082. function __() { this.constructor = d; }
  10083. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10084. };
  10085. })();
  10086. var _a = SeriesRegistry.seriesTypes,
  10087. SMAIndicator = _a.sma,
  10088. LinearRegressionIndicator = _a.linearRegression;
  10089. var extend = U.extend,
  10090. merge = U.merge;
  10091. /* *
  10092. *
  10093. * Class
  10094. *
  10095. * */
  10096. /**
  10097. * The Linear Regression Angle series type.
  10098. *
  10099. * @private
  10100. * @class
  10101. * @name Highcharts.seriesTypes.linearRegressionAngle
  10102. *
  10103. * @augments Highcharts.Series
  10104. */
  10105. var LinearRegressionAngleIndicator = /** @class */ (function (_super) {
  10106. __extends(LinearRegressionAngleIndicator, _super);
  10107. function LinearRegressionAngleIndicator() {
  10108. var _this = _super !== null && _super.apply(this,
  10109. arguments) || this;
  10110. /* *
  10111. *
  10112. * Properties
  10113. *
  10114. * */
  10115. _this.data = void 0;
  10116. _this.options = void 0;
  10117. _this.points = void 0;
  10118. return _this;
  10119. }
  10120. /* *
  10121. *
  10122. * Functions
  10123. *
  10124. * */
  10125. /**
  10126. * Convert a slope of a line to angle (in degrees) between
  10127. * the line and x axis
  10128. * @private
  10129. * @param {number} slope of the straight line function
  10130. * @return {number} angle in degrees
  10131. */
  10132. LinearRegressionAngleIndicator.prototype.slopeToAngle = function (slope) {
  10133. return Math.atan(slope) * (180 / Math.PI); // rad to deg
  10134. };
  10135. LinearRegressionAngleIndicator.prototype.getEndPointY = function (lineParameters) {
  10136. return this.slopeToAngle(lineParameters.slope);
  10137. };
  10138. /**
  10139. * Linear regression angle indicator. This series requires `linkedTo`
  10140. * option to be set.
  10141. *
  10142. * @sample {highstock} stock/indicators/linear-regression-angle
  10143. * Linear intercept angle indicator
  10144. *
  10145. * @extends plotOptions.linearregression
  10146. * @since 7.0.0
  10147. * @product highstock
  10148. * @requires stock/indicators/indicators
  10149. * @requires stock/indicators/linearregressionangle
  10150. * @optionparent plotOptions.linearregressionangle
  10151. */
  10152. LinearRegressionAngleIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  10153. tooltip: {
  10154. pointFormat: '<span style="color:{point.color}">\u25CF</span>' +
  10155. '{series.name}: <b>{point.y}°</b><br/>'
  10156. }
  10157. });
  10158. return LinearRegressionAngleIndicator;
  10159. }(LinearRegressionIndicator));
  10160. extend(LinearRegressionAngleIndicator.prototype, {
  10161. nameBase: 'Linear Regression Angle Indicator'
  10162. });
  10163. SeriesRegistry.registerSeriesType('linearRegressionAngle', LinearRegressionAngleIndicator);
  10164. /* *
  10165. *
  10166. * Default Export
  10167. *
  10168. * */
  10169. /**
  10170. * A linear regression intercept series. If the
  10171. * [type](#series.linearregressionangle.type) option is not specified, it is
  10172. * inherited from [chart.type](#chart.type).
  10173. *
  10174. * @extends series,plotOptions.linearregressionangle
  10175. * @since 7.0.0
  10176. * @product highstock
  10177. * @excluding dataParser,dataURL
  10178. * @requires stock/indicators/indicators
  10179. * @requires stock/indicators/linearregressionangle
  10180. * @apioption series.linearregressionangle
  10181. */
  10182. ''; // to include the above in the js output
  10183. return LinearRegressionAngleIndicator;
  10184. });
  10185. _registerModule(_modules, 'Stock/Indicators/ABands/ABandsIndicator.js', [_modules['Mixins/MultipleLines.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (MultipleLinesMixin, SeriesRegistry, U) {
  10186. /* *
  10187. *
  10188. * License: www.highcharts.com/license
  10189. *
  10190. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  10191. *
  10192. * */
  10193. var __extends = (this && this.__extends) || (function () {
  10194. var extendStatics = function (d,
  10195. b) {
  10196. extendStatics = Object.setPrototypeOf ||
  10197. ({ __proto__: [] } instanceof Array && function (d,
  10198. b) { d.__proto__ = b; }) ||
  10199. function (d,
  10200. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10201. return extendStatics(d, b);
  10202. };
  10203. return function (d, b) {
  10204. extendStatics(d, b);
  10205. function __() { this.constructor = d; }
  10206. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10207. };
  10208. })();
  10209. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  10210. var correctFloat = U.correctFloat,
  10211. extend = U.extend,
  10212. merge = U.merge;
  10213. /* eslint-disable valid-jsdoc */
  10214. /**
  10215. * @private
  10216. */
  10217. function getBaseForBand(low, high, factor) {
  10218. return (((correctFloat(high - low)) /
  10219. ((correctFloat(high + low)) / 2)) * 1000) * factor;
  10220. }
  10221. /**
  10222. * @private
  10223. */
  10224. function getPointUB(high, base) {
  10225. return high * (correctFloat(1 + 2 * base));
  10226. }
  10227. /**
  10228. * @private
  10229. */
  10230. function getPointLB(low, base) {
  10231. return low * (correctFloat(1 - 2 * base));
  10232. }
  10233. /* eslint-enable valid-jsdoc */
  10234. /**
  10235. * The ABands series type
  10236. *
  10237. * @private
  10238. * @class
  10239. * @name Highcharts.seriesTypes.abands
  10240. *
  10241. * @augments Highcharts.Series
  10242. */
  10243. var ABandsIndicator = /** @class */ (function (_super) {
  10244. __extends(ABandsIndicator, _super);
  10245. function ABandsIndicator() {
  10246. /* *
  10247. *
  10248. * Static Properties
  10249. *
  10250. * */
  10251. var _this = _super !== null && _super.apply(this,
  10252. arguments) || this;
  10253. /* *
  10254. *
  10255. * Properties
  10256. *
  10257. * */
  10258. _this.data = void 0;
  10259. _this.options = void 0;
  10260. _this.points = void 0;
  10261. return _this;
  10262. }
  10263. /* *
  10264. *
  10265. * Functions
  10266. *
  10267. * */
  10268. ABandsIndicator.prototype.getValues = function (series, params) {
  10269. var period = params.period,
  10270. factor = params.factor,
  10271. index = params.index,
  10272. xVal = series.xData,
  10273. yVal = series.yData,
  10274. yValLen = yVal ? yVal.length : 0,
  10275. // Upperbands
  10276. UB = [],
  10277. // Lowerbands
  10278. LB = [],
  10279. // ABANDS array structure:
  10280. // 0-date, 1-top line, 2-middle line, 3-bottom line
  10281. ABANDS = [],
  10282. // middle line, top line and bottom line
  10283. ML,
  10284. TL,
  10285. BL,
  10286. date,
  10287. bandBase,
  10288. pointSMA,
  10289. ubSMA,
  10290. lbSMA,
  10291. low = 2,
  10292. high = 1,
  10293. xData = [],
  10294. yData = [],
  10295. slicedX,
  10296. slicedY,
  10297. i;
  10298. if (yValLen < period) {
  10299. return;
  10300. }
  10301. for (i = 0; i <= yValLen; i++) {
  10302. // Get UB and LB values of every point. This condition
  10303. // is necessary, because there is a need to calculate current
  10304. // UB nad LB values simultaneously with given period SMA
  10305. // in one for loop.
  10306. if (i < yValLen) {
  10307. bandBase = getBaseForBand(yVal[i][low], yVal[i][high], factor);
  10308. UB.push(getPointUB(yVal[i][high], bandBase));
  10309. LB.push(getPointLB(yVal[i][low], bandBase));
  10310. }
  10311. if (i >= period) {
  10312. slicedX = xVal.slice(i - period, i);
  10313. slicedY = yVal.slice(i - period, i);
  10314. ubSMA = _super.prototype.getValues.call(this, {
  10315. xData: slicedX,
  10316. yData: UB.slice(i - period, i)
  10317. }, {
  10318. period: period
  10319. });
  10320. lbSMA = _super.prototype.getValues.call(this, {
  10321. xData: slicedX,
  10322. yData: LB.slice(i - period, i)
  10323. }, {
  10324. period: period
  10325. });
  10326. pointSMA = _super.prototype.getValues.call(this, {
  10327. xData: slicedX,
  10328. yData: slicedY
  10329. }, {
  10330. period: period,
  10331. index: index
  10332. });
  10333. date = pointSMA.xData[0];
  10334. TL = ubSMA.yData[0];
  10335. BL = lbSMA.yData[0];
  10336. ML = pointSMA.yData[0];
  10337. ABANDS.push([date, TL, ML, BL]);
  10338. xData.push(date);
  10339. yData.push([TL, ML, BL]);
  10340. }
  10341. }
  10342. return {
  10343. values: ABANDS,
  10344. xData: xData,
  10345. yData: yData
  10346. };
  10347. };
  10348. /**
  10349. * Acceleration bands (ABANDS). This series requires the `linkedTo` option
  10350. * to be set and should be loaded after the
  10351. * `stock/indicators/indicators.js`.
  10352. *
  10353. * @sample {highstock} stock/indicators/acceleration-bands
  10354. * Acceleration Bands
  10355. *
  10356. * @extends plotOptions.sma
  10357. * @mixes Highcharts.MultipleLinesMixin
  10358. * @since 7.0.0
  10359. * @product highstock
  10360. * @excluding allAreas, colorAxis, compare, compareBase, joinBy, keys,
  10361. * navigatorOptions, pointInterval, pointIntervalUnit,
  10362. * pointPlacement, pointRange, pointStart, showInNavigator,
  10363. * stacking,
  10364. * @requires stock/indicators/indicators
  10365. * @requires stock/indicators/acceleration-bands
  10366. * @optionparent plotOptions.abands
  10367. */
  10368. ABandsIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  10369. params: {
  10370. period: 20,
  10371. /**
  10372. * The algorithms factor value used to calculate bands.
  10373. *
  10374. * @product highstock
  10375. */
  10376. factor: 0.001,
  10377. index: 3
  10378. },
  10379. lineWidth: 1,
  10380. topLine: {
  10381. styles: {
  10382. /**
  10383. * Pixel width of the line.
  10384. */
  10385. lineWidth: 1
  10386. }
  10387. },
  10388. bottomLine: {
  10389. styles: {
  10390. /**
  10391. * Pixel width of the line.
  10392. */
  10393. lineWidth: 1
  10394. }
  10395. },
  10396. dataGrouping: {
  10397. approximation: 'averages'
  10398. }
  10399. });
  10400. return ABandsIndicator;
  10401. }(SMAIndicator));
  10402. extend(ABandsIndicator.prototype, {
  10403. drawGraph: MultipleLinesMixin.drawGraph,
  10404. getTranslatedLinesNames: MultipleLinesMixin.getTranslatedLinesNames,
  10405. linesApiNames: ['topLine', 'bottomLine'],
  10406. nameBase: 'Acceleration Bands',
  10407. nameComponents: ['period', 'factor'],
  10408. pointArrayMap: ['top', 'middle', 'bottom'],
  10409. pointValKey: 'middle',
  10410. toYData: MultipleLinesMixin.toYData,
  10411. translate: MultipleLinesMixin.translate
  10412. });
  10413. SeriesRegistry.registerSeriesType('abands', ABandsIndicator);
  10414. /* *
  10415. *
  10416. * Default Export
  10417. *
  10418. * */
  10419. /* *
  10420. *
  10421. * API Options
  10422. *
  10423. * */
  10424. /**
  10425. * An Acceleration bands indicator. If the [type](#series.abands.type) option is not
  10426. * specified, it is inherited from [chart.type](#chart.type).
  10427. *
  10428. * @extends series,plotOptions.abands
  10429. * @since 7.0.0
  10430. * @product highstock
  10431. * @excluding allAreas, colorAxis, compare, compareBase, dataParser, dataURL,
  10432. * joinBy, keys, navigatorOptions, pointInterval,
  10433. * pointIntervalUnit, pointPlacement, pointRange, pointStart,
  10434. * stacking, showInNavigator,
  10435. * @requires stock/indicators/indicators
  10436. * @requires stock/indicators/acceleration-bands
  10437. * @apioption series.abands
  10438. */
  10439. ''; // to include the above in jsdoc
  10440. return ABandsIndicator;
  10441. });
  10442. _registerModule(_modules, 'Stock/Indicators/TrendLine/TrendLineIndicator.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  10443. /* *
  10444. *
  10445. * License: www.highcharts.com/license
  10446. *
  10447. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  10448. *
  10449. * */
  10450. var __extends = (this && this.__extends) || (function () {
  10451. var extendStatics = function (d,
  10452. b) {
  10453. extendStatics = Object.setPrototypeOf ||
  10454. ({ __proto__: [] } instanceof Array && function (d,
  10455. b) { d.__proto__ = b; }) ||
  10456. function (d,
  10457. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10458. return extendStatics(d, b);
  10459. };
  10460. return function (d, b) {
  10461. extendStatics(d, b);
  10462. function __() { this.constructor = d; }
  10463. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10464. };
  10465. })();
  10466. var SMAIndicator = SeriesRegistry.seriesTypes.sma;
  10467. var extend = U.extend,
  10468. merge = U.merge,
  10469. isArray = U.isArray;
  10470. /* *
  10471. *
  10472. * Class
  10473. *
  10474. * */
  10475. /**
  10476. * The Trend line series type.
  10477. *
  10478. * @private
  10479. * @class
  10480. * @name Highcharts.seriesTypes.trendline
  10481. *
  10482. * @augments Highcharts.Series
  10483. */
  10484. var TrendLineIndicator = /** @class */ (function (_super) {
  10485. __extends(TrendLineIndicator, _super);
  10486. function TrendLineIndicator() {
  10487. var _this = _super !== null && _super.apply(this,
  10488. arguments) || this;
  10489. /* *
  10490. *
  10491. * Properties
  10492. *
  10493. * */
  10494. _this.data = void 0;
  10495. _this.options = void 0;
  10496. _this.points = void 0;
  10497. return _this;
  10498. }
  10499. /* *
  10500. *
  10501. * Functions
  10502. *
  10503. * */
  10504. TrendLineIndicator.prototype.getValues = function (series, params) {
  10505. var xVal = series.xData,
  10506. yVal = series.yData,
  10507. LR = [],
  10508. xData = [],
  10509. yData = [],
  10510. sumX = 0,
  10511. sumY = 0,
  10512. sumXY = 0,
  10513. sumX2 = 0,
  10514. xValLength = xVal.length,
  10515. index = params.index,
  10516. alpha,
  10517. beta,
  10518. i,
  10519. x,
  10520. y;
  10521. // Get sums:
  10522. for (i = 0; i < xValLength; i++) {
  10523. x = xVal[i];
  10524. y = isArray(yVal[i]) ? yVal[i][index] : yVal[i];
  10525. sumX += x;
  10526. sumY += y;
  10527. sumXY += x * y;
  10528. sumX2 += x * x;
  10529. }
  10530. // Get slope and offset:
  10531. alpha = (xValLength * sumXY - sumX * sumY) /
  10532. (xValLength * sumX2 - sumX * sumX);
  10533. if (isNaN(alpha)) {
  10534. alpha = 0;
  10535. }
  10536. beta = (sumY - alpha * sumX) / xValLength;
  10537. // Calculate linear regression:
  10538. for (i = 0; i < xValLength; i++) {
  10539. x = xVal[i];
  10540. y = alpha * x + beta;
  10541. // Prepare arrays required for getValues() method
  10542. LR[i] = [x, y];
  10543. xData[i] = x;
  10544. yData[i] = y;
  10545. }
  10546. return {
  10547. xData: xData,
  10548. yData: yData,
  10549. values: LR
  10550. };
  10551. };
  10552. /**
  10553. * Trendline (linear regression) fits a straight line to the selected data
  10554. * using a method called the Sum Of Least Squares. This series requires the
  10555. * `linkedTo` option to be set.
  10556. *
  10557. * @sample stock/indicators/trendline
  10558. * Trendline indicator
  10559. *
  10560. * @extends plotOptions.sma
  10561. * @since 7.1.3
  10562. * @product highstock
  10563. * @requires stock/indicators/indicators
  10564. * @requires stock/indicators/trendline
  10565. * @optionparent plotOptions.trendline
  10566. */
  10567. TrendLineIndicator.defaultOptions = merge(SMAIndicator.defaultOptions, {
  10568. /**
  10569. * @excluding period
  10570. */
  10571. params: {
  10572. /**
  10573. * The point index which indicator calculations will base. For
  10574. * example using OHLC data, index=2 means the indicator will be
  10575. * calculated using Low values.
  10576. *
  10577. * @default 3
  10578. */
  10579. index: 3
  10580. }
  10581. });
  10582. return TrendLineIndicator;
  10583. }(SMAIndicator));
  10584. extend(TrendLineIndicator.prototype, {
  10585. nameBase: 'Trendline',
  10586. nameComponents: false
  10587. });
  10588. SeriesRegistry.registerSeriesType('trendline', TrendLineIndicator);
  10589. /* *
  10590. *
  10591. * Default Export
  10592. *
  10593. * */
  10594. /**
  10595. * A `TrendLine` series. If the [type](#series.trendline.type) option is not
  10596. * specified, it is inherited from [chart.type](#chart.type).
  10597. *
  10598. * @extends series,plotOptions.trendline
  10599. * @since 7.1.3
  10600. * @product highstock
  10601. * @excluding dataParser, dataURL
  10602. * @requires stock/indicators/indicators
  10603. * @requires stock/indicators/trendline
  10604. * @apioption series.trendline
  10605. */
  10606. ''; // to include the above in the js output
  10607. return TrendLineIndicator;
  10608. });
  10609. _registerModule(_modules, 'masters/indicators/indicators-all.src.js', [], function () {
  10610. // eslint-disable-next-line max-len
  10611. // eslint-disable-next-line max-len
  10612. });
  10613. }));