function make_signal(e){let n,r;return r=fs_strength(e,w=20,sigma=1,s_size=5),n=fs_trend(e,w=10),[r[5],trend_arr=n]}function make_signal_last(e){const n=make_signal(e);return last.Strength=n[0].slice(-1)[0],last.Trend=n[1].slice(-1)[0],signal_to_colors(last.Strength,last.Trend)}function make_signal_arr(e,n){const r=make_signal(n);strength_arr=r[0].slice(-500),e=e.slice(-strength_arr.length),n=n.slice(-strength_arr.length),trend_arr=r[1].slice(-strength_arr.length);let t=[];for(let e=0;e50&&trend_arr[e]>0?t[e]="L":strength_arr[e]<0&&trend_arr[e]<0?t[e]="S":t[e]="N";return[e,n,t,strength_arr,trend_arr]}function cal_price_estimation(e,n){return e+2*n[10]*n[13]+.01*(n[23]-50)*n[13]}function signal_to_colors(e,n){return colors=e>50&&n>0?{red:"#1a0000",orange:"#1a1400",green:"#33cc33"}:e<0&&n<0?{red:"#ff0000",orange:"#1a1400",green:"#051405"}:{red:"#1a0000",orange:"#ffcc00",green:"#051405"},colors}function signal_to_value(e,n){return e>50&&n>0?"L":e<0&&n<0?"S":"N"}function light_on(e,n="L"){document.getElementById("red_"+n).style.backgroundColor=e.red,document.getElementById("orange_"+n).style.backgroundColor=e.orange,document.getElementById("green_"+n).style.backgroundColor=e.green}function fs_strength(e,n=24,r=1,t=5){const a=rolling(e,n).map(mean),l=rolling(e,n).map(stdev),o=a.map((e,n)=>e+r*l[n]),s=a.map((e,n)=>e-r*l[n]),m=e.slice(n-1).map((e,n)=>(e-s[n])/(o[n]-s[n])*100),c=rolling(m,t).map(mean);return[a,l,o,s,m,c]}function fs_trend(e,n=10){return rolling(e.map((n,r)=>100*(n/e[0]-1)),n).map(get_trend).map(e=>e.slice(2,3)[0])}function macd(e,n=12,r=26,t=9){const a=ema(e,n),l=ema(e,r),o=a.map((e,n)=>e-l[n]),s=ema(o,t),m=o.map((e,n)=>e-s[n]);return[a,l,o,s,m]}function rsi(e,n=14){let r=e.map((n,r)=>n-e[r-1]);const t=rolling(r,n).map(e=>e.filter(e=>e>0).reduce((e,n)=>e+n,0)/n),a=rolling(r,n).map(e=>Math.abs(e.filter(e=>e<0).reduce((e,n)=>e+n,0)/n));r=r.slice(n-1);const l=t.map((e,a)=>(t[a-1]*(n-1)+(r[a]>0?r[a]:0))/n),o=a.map((e,t)=>(a[t-1]*(n-1)+(r[t]<0?Math.abs(r[t]):0))/n);return[l.map((e,n)=>e/(e+o[n])*100)]}function envelope(e,n=20,r=.05){const t=rolling(e,n).map(mean),a=t.map(e=>e*(1+r)),l=t.map(e=>e*(1-r)),o=e.slice(n-1).map((e,n)=>(e-l[n])/(a[n]-l[n])*100);return[t,a,l,o]}function stochastic(e,n,r,t=14,a=3,l=3){let o=rolling(e,t).map(e=>Math.max(...e)),s=rolling(n,t).map(e=>Math.min(...e)),m=r.slice(t-1).map((e,n)=>(e-s[n])/(o[n]-s[n])*100),c=rolling(m,a).map(mean);return[m,c,rolling(c,l).map(mean)]}function atr(e,n,r,t=20){let a=[],l=[],o=[],s=[];for(let t=0;te/Math.max.apply(null,m)*100);return[m,c]}function volume_analysis(e,n=5,r=1){const t=rolling(e,n).map(mean),a=rolling(e,n).map(stdev),l=t.map((e,n)=>e+r*a[n]),o=t.map((e,n)=>e-r*a[n]);return[e.slice(n-1).map((e,n)=>(e-o[n])/(l[n]-o[n])*100)]}function stats(e){const n=e.reduce((e,n)=>e+n),r=n/e.length,t=e.map(e=>e-r),a=t.map(e=>Math.pow(e,2)).reduce((e,n)=>e+n)/e.length,l=Math.sqrt(a);return[n,m,t,a,l]}function rolling(e,n){return e.map((e,r,t)=>t.slice(r,r+n)).slice(0,1-n)}function sum(e){return e.reduce((e,n)=>e+n)}function mean(e){return e.reduce((e,n)=>e+n)/e.length}function stdev(e){const n=e.reduce((e,n)=>e+n)/e.length,r=e.map(e=>e-n).map(e=>Math.pow(e,2)).reduce((e,n)=>e+n)/e.length;return Math.sqrt(r)}function get_trend(e){let n=e.length;const r=Array.from({length:n},(e,n)=>n);let t=0,a=0,l=0,o=0,s=0,m=0,c=0;for(let i=0;i