function chart_init(e,t="1D"){fetch("https://api.binance.com/api/v3/klines?symbol="+e+"USDT&interval="+{"1D":"5m","1W":"15m","1M":"1h","1Y":"12h","5Y":"1w"}[t]+"&limit="+{"1D":288,"1W":672,"1M":744,"1Y":730,"5Y":260}[t],{method:"GET",credentials:"same-origin"}).then((function(e){return e.json()})).then((function(e){show_chart(e,t)})).catch((function(e){console.log(e)}))}function show_chart(e,t="1M"){periods.forEach((function(e){document.getElementById(e).style.textDecoration="none",document.getElementById(e).style.backgroundColor="transparent",document.getElementById(e).style.color="silver",document.getElementById(e).innerHTML=e})),document.getElementById(t).style.backgroundColor="silver",document.getElementById(t).style.color="black";const n=e.map((e=>e[0])),r=e.map((e=>parseFloat(e[4])));let a=parseInt(document.getElementById("price_chart").offsetWidth);height=a>800?parseInt(.4*a):parseInt(1*a),document.getElementById("price_chart").innerHTML=draw_chart(x=n,arr=r,w=a,h=height,f=10,size=250,trendline=!0,log=!0)}function price_init(e){fetch("https://api.binance.com/api/v3/ticker/24hr?symbol="+e+"USDT",{method:"GET",credentials:"same-origin"}).then((function(e){return e.json()})).then((function(e){price=parseFloat(e.lastPrice),e.priceChange>=0?(document.getElementById("price").style.color="#ccff33",document.getElementById("price_chg").style.color="#ccff33",document.getElementById("price_chg_pct").style.color="#ccff33",document.getElementById("price_chg").innerHTML="+"+add_commas(parseFloat(e.priceChange)),document.getElementById("price_chg_pct").innerHTML="+"+add_commas(parseFloat(e.priceChangePercent),dec=2)+"%"):(document.getElementById("price").style.color="#ff9933",document.getElementById("price_chg").style.color="#ff9933",document.getElementById("price_chg_pct").style.color="#ff9933",document.getElementById("price_chg").innerHTML=add_commas(parseFloat(e.priceChange)),document.getElementById("price_chg_pct").innerHTML=add_commas(parseFloat(e.priceChangePercent),dec=2)+"%"),document.getElementById("price").innerHTML="$"+add_commas(price)})).catch((function(e){console.log(e)}))}function analysis_init(e,t="L",n,r){fetch("https://api.binance.com/api/v3/klines?symbol="+e+"USDT&interval="+{L:"1h",S:"5m"}[t]+"&limit=1000",{method:"GET",credentials:"same-origin"}).then((function(e){return e.json()})).then((function(e){show_analysis(e,t,n,r)})).catch((function(e){console.log(e)}))}function show_analysis(e,r="L",a,i){const s={L:24,S:12},o=e.map((e=>e[0])),c=(e.map((e=>parseFloat(e[1]))),e.map((e=>parseFloat(e[2])))),l=e.map((e=>parseFloat(e[3]))),p=e.map((e=>parseFloat(e[4]))),d=e.map((e=>parseFloat(e[5]))),g=make_signal_last(p,r,a,i);light_on(g,r);let u=rsi(p,window=14*s[r]),_=envelope(p,window=20*s[r],spread=.05),y=stochastic(c,l,p,n=14*s[r],m=3*s[r],t=3*s[r]),I=(volume_analysis(d,window=7*s[r],sigma=1),atr(c,l,p,window=s[r]));const T=u[0],E=_[3].map((e=>Math.max(Math.min(e,100),0))),M=y[0],v=I[1];ind_arr.time=o,ind_arr.RSI=u[0],ind_arr.Envelope=_[3].map((e=>Math.max(Math.min(e,100),0))),ind_arr.Stochastic=y[0],ind_arr.ATR=I[1],last.RSI=T.slice(-1)[0],last.Envelope=E.slice(-1)[0],last.Stochastic=M.slice(-1)[0],last.ATR=v.slice(-1)[0];let S={};S.Strength=Math.max(Math.min(last.Strength,100),0),S.Trend=Math.max(Math.min(100*last.Trend+50,100),0),S.RSI=last.RSI,S.Envelope=Math.max(Math.min(last.Envelope,100),0),S.Stochastic=last.Stochastic,S.ATR=last.ATR,S["F Open Interest"]=Math.max(Math.min(last["F Open Interest"],100),0),S["F Long"]=Math.max(Math.min(last["F Long"],100),0);let L=parseInt(.95*document.getElementById("price_chart").offsetWidth);L>500?(L=parseInt(L/2),height=parseInt(.25*L)):height=parseInt(.4*L),src=draw_summary_chart(S,w=L-25,h=height-10,f=10),document.getElementById("summary_"+r).innerHTML=src,signals=make_signal_arr(o,p,r,a,i),ind_arr.Strength=signals[3].map((e=>Math.max(Math.min(.5*e+30,100),0))),ind_arr.Trend=signals[4].map((e=>Math.max(Math.min(30*e+50,100),0))),src=draw_signal_chart(x=signals[0],arr=signals[1],signal=signals[2],w=L,h=height,f=10),document.getElementById("signal_chart_"+r).innerHTML=src,src=draw_simple_chart(x=o,ind_arr.Strength,"Strength",w=L,h=150,f=10,size=300,score_100=!0),document.getElementById("strength_"+r).innerHTML=src,src=draw_simple_chart(x=o,ind_arr.Trend,"Trend",w=L,h=150,f=10,size=300,score_100=!0),document.getElementById("trend_"+r).innerHTML=src,src=draw_simple_chart(x=o,ind_arr.RSI,"RSI",w=L,h=150,f=10,size=300,score_100=!0),document.getElementById("rsi_"+r).innerHTML=src,src=draw_simple_chart(x=o,ind_arr.Envelope,"Envelope",w=L,h=150,f=10,size=300,score_100=!0),document.getElementById("envelope_"+r).innerHTML=src,src=draw_simple_chart(x=o,ind_arr.Stochastic,"Stochastic",w=L,h=150,f=10,size=300,score_100=!0),document.getElementById("stochastic_"+r).innerHTML=src,src=draw_simple_chart(x=o,ind_arr.ATR,"ATR",w=L,h=150,f=10,size=300,score_100=!0),document.getElementById("atr_"+r).innerHTML=src}function f_open_interest(e,t="L"){fetch("https://fapi.binance.com/futures/data/openInterestHist?symbol="+e+"USDT&period="+{L:"1h",S:"5m"}[t]+"&limit=500",{method:"GET",credentials:"same-origin"}).then((function(e){return e.json()})).then((function(e){let n=[];for(var r=0;re[0])),i=(n.map((e=>parseFloat(e[1]))),n.map((e=>parseFloat(e[2]))));ind_arr["F Open Interest"]=i.map((e=>(e-Math.min.apply(null,i))/(Math.max.apply(null,i)-Math.min.apply(null,i))*100)),last["F Open Interest"]=(i.slice(-1)[0]-Math.min.apply(null,i))/(Math.max.apply(null,i)-Math.min.apply(null,i))*100;let s=parseInt(.95*document.getElementById("price_chart").offsetWidth);s>500?(s=parseInt(s/2),height=parseInt(.25*s)):height=parseInt(.4*s),src=draw_simple_chart(x=a,i,"F Open Interest",w=s,h=150,f=10,size=200),document.getElementById("f_open_interest_"+t).innerHTML=src})).catch((function(e){console.log(e)}))}function f_long_short_ratio(e,t="L"){fetch("https://fapi.binance.com/futures/data/globalLongShortAccountRatio?symbol="+e+"USDT&period="+{L:"1h",S:"5m"}[t]+"&limit=500",{method:"GET",credentials:"same-origin"}).then((function(e){return e.json()})).then((function(e){let n=[];for(var r=0;re[0])),i=n.map((e=>parseFloat(e[2])));ind_arr["F Long"]=i.map((e=>100*e)),last["F Long"]=100*i.slice(-1)[0];let s=parseInt(.95*document.getElementById("price_chart").offsetWidth);s>500?(s=parseInt(s/2),height=parseInt(.25*s)):height=parseInt(.4*s),src=draw_long_short_chart(x=a,i,"F Long vs. Short",w=s,h=150,f=10,size=200),document.getElementById("f_long_short_"+t).innerHTML=src})).catch((function(e){console.log(e)}))}function show_info(e){const t={Strength:"A measure of price growth strength for N period. The market is strong when S>60, weak when S<30.",Trend:"An indicator of price movement trend for N period. The trend is in up when T>50, down when T<50.",RSI:"Relative strength index. The market is strong when R>70, weak when R<30.",Envelope:"A measure to find where the price exist in P% price range. The price is over the range when E>100, below the range when E<0.",Stochastic:"A momentum indicator comparing a particular close price of a security to a range of its prices over N period. Stochastic oscillators tend to vary around some mean price level, since they rely on an asset's price history.",ATR:"Average True Range is a market volatility indicator. It is typically derived from the N periods simple moving average of a series of true range indicators.","F Open Interest":"Open interest is the total number of outstanding derivative contracts, such as options or futures that have not been settled for an asset. The investors are positive when OI is increasing.","F Long vs. Short":"Long is buy position and short is sell position in derivatives market. The investors are positive when L>50%."};e in t&&alert(t[e])}