data collection fields calculation

Hi
Need a little help to achieve fields calculation (maybe with Hooks?).
I need to take 2 or more fields, do some math and write the result to another data collection field (like excel sheet, field1 - field 3 = 5 than write the answer to field6.
Is there any way to do this with hooks?.
What is the trigger for the hook? I need it to do the calculation at any time that some field is changing.

Thanks a lot.

You can start by reading here about using hooks with calculations
https://support.wix.com/en/article/corvid-tutorial-calculating-and-displaying-collection-data

If you do a search in this forum you will find many previous posts about this and similar posts too.
https://www.wix.com/corvid/forum/community-discussion/adding-two-input-values
https://www.wix.com/corvid/forum/community-discussion/counting-the-sum-of-the-values-of-cells
https://www.wix.com/corvid/forum/community-discussion/sum-of-field-in-database
https://www.wix.com/corvid/forum/community-discussion/input-to-keep-adding-number-to-one-field-in-database

To just do it on a page without a datahook, then you can do something simple like this.
https://www.vorbly.com/Vorbly-Code/WIX-CODE-CALCULATIONS—SUM-NUMBERS

Hi
Thank you, i found a very simple way to solve it by using hooks:
export function mydataset_beforeInsert(item, context) {
var entry = item.entry
var stop = item.stop
item.risk = entry - stop;
//Adding sum value to the inserted record:
return item;
}

but now i have another problem, i can’t find a way to Update an existing field in a data collection.
my website can track users stock trading positions, so user will enter the entry price and once he close the position, he will write the current price and i will calculate the reward.
for example, the user buy a stock at 20$ and he add that data to the database.
few days later the user sold the stock at price of 25$.
the entry price (20$) is already in my database, how can i let the user to enter only the selling price and i will automatically calculate the selling price - entry price?.
I’m trying to use Hook but i can’t find a way to new record to an existing record.
Thank you!.