indicators-all.src.js 478 KB

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