create account

Programming My Own Trading Chart - Part 31 - Technical Indicators on WebWorkers by leoplaw

View this thread on: hive.blogpeakd.comecency.com
· @leoplaw ·
$8.88
Programming My Own Trading Chart - Part 31 - Technical Indicators on WebWorkers
![Screenshot_20231007_125400.png](https://files.peakd.com/file/peakd-hive/leoplaw/23t79FD1oBzNrTZ8E2ZdcoYoLwdfbfr4F9oWAyccmKiHKsMW4pwQrquScqQQ8QZrJKWrC.png)


In the quest for performance improvements, work is currently being done on how the chart calculates indicators.

The first improvement is having the chart only calculate the required indicator data instead of the entire price history when new chunk of back history data is added.

The chart currently uses [talib-web](https://github.com/ancheGT/talib-web) for indicator calculation. It is a port of the technical analysis library written in C, ported to WebAssembly. The current release of TradeX uses this library on the main thread. If there is a large price history to process, this can lead to the main JavaScrpt loop (thread) being blocked and causing the browser tab to unresponsive. So the option of moving the indicator calculation to a web worker, a separate thread to free up the main thread is being explored.

I now have the TALib-web wasm initializing on a web worker. This was quite a challenge and required a good deal of research and trying numerous options before a solution was found. In the end the simplest was best.

Next step is to call the TALib functions in the worker and have the results returned.
If that works, then I can finally do the following test comparisons:

1.    talib-web funciton calls on main thread vs  worker
1a.  browser comparisons of the above
2.    technicalindicators function calls on main thread vs worker
2.a  browser comparisons
3.    compare 1 and 2.

technicalindicators is another library, but is pure JavaScript (now wasm)
I want to see the wasm vs JS performance comparison.
The results might be surprising.
👍  , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , and 576 others
properties (23)
authorleoplaw
permlinkprogramming-my-own-trading-chart-part-31-technical-indicators-on-webworkers
categoryhive-169321
json_metadata{"app":"peakd/2023.9.2","format":"markdown","tags":["programming","development","crypto","trade"],"users":[],"image":["https://files.peakd.com/file/peakd-hive/leoplaw/23t79FD1oBzNrTZ8E2ZdcoYoLwdfbfr4F9oWAyccmKiHKsMW4pwQrquScqQQ8QZrJKWrC.png"]}
created2023-10-07 10:56:33
last_update2023-10-07 10:56:33
depth0
children1
last_payout2023-10-14 10:56:33
cashout_time1969-12-31 23:59:59
total_payout_value4.438 HBD
curator_payout_value4.440 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length1,723
author_reputation189,628,210,789,149
root_title"Programming My Own Trading Chart - Part 31 - Technical Indicators on WebWorkers"
beneficiaries
0.
accounthive-169321
weight200
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id127,782,832
net_rshares22,808,965,670,933
author_curate_reward""
vote details (640)
@hivebuzz ·
Congratulations @leoplaw! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

<table><tr><td><img src="https://images.hive.blog/60x70/http://hivebuzz.me/@leoplaw/upvotes.png?202310082356"></td><td>You distributed more than 18000 upvotes.<br>Your next target is to reach 19000 upvotes.</td></tr>
</table>

<sub>_You can view your badges on [your board](https://hivebuzz.me/@leoplaw) and compare yourself to others in the [Ranking](https://hivebuzz.me/ranking)_</sub>
<sub>_If you no longer want to receive notifications, reply to this comment with the word_ `STOP`</sub>



**Check out our last posts:**
<table><tr><td><a href="/hive-122221/@hivebuzz/pum-202309-delegations"><img src="https://images.hive.blog/64x128/https://i.imgur.com/fg8QnBc.png"></a></td><td><a href="/hive-122221/@hivebuzz/pum-202309-delegations">Our Hive Power Delegations to the September PUM Winners</a></td></tr></table>
properties (22)
authorhivebuzz
permlinknotify-leoplaw-20231009t001719
categoryhive-169321
json_metadata{"image":["http://hivebuzz.me/notify.t6.png"]}
created2023-10-09 00:17:18
last_update2023-10-09 00:17:18
depth1
children0
last_payout2023-10-16 00:17:18
cashout_time1969-12-31 23:59:59
total_payout_value0.000 HBD
curator_payout_value0.000 HBD
pending_payout_value0.000 HBD
promoted0.000 HBD
body_length953
author_reputation369,203,152,993,686
root_title"Programming My Own Trading Chart - Part 31 - Technical Indicators on WebWorkers"
beneficiaries[]
max_accepted_payout1,000,000.000 HBD
percent_hbd10,000
post_id127,824,104
net_rshares0