Lets say that we have next inputs:

Master Balance = **100 000 USDT**
Slave Balance = **50 000 USDT**
Risk Coefficient = **1**

Step 1

You start from 0

Account Side Qty Symbol
Master Long 0 BTC/USDT
Slave Long 0 BTC/USDT

Step 2

Lets suppose you opened a position on master, then slave will open equivalent based on risk coef parameter:

Account Side Qty Symbol
Master Long 5 BTC/USDT
Slave Long 2.5 BTC/USDT

Step 3

You decided to close only slave, master will not be affected:

Account Side Qty Symbol
Master Long 5 BTC/USDT
Slave Long 0 BTC/USDT

Step 4

Then master increase position, slave will open new position based on amount of last order, in our case: 2.5 Long

Account Side Qty Symbol
Master Long 7.5 BTC/USDT
Slave Long 1.25 BTC/USDT

Step 5

Then master will decrease position on 3.25 BTC. In this behavior slave will be looking for amount of position was closed on master, and do the same. We see that 3.25 is 50% from original position, then slave will close the same 50% of its position:

Account Side Qty Symbol
Master Long 3.75 BTC/USDT
Slave Long 0.625 BTC/USDT

Step 6

Then master will increase position on 1.5 BTC. In this behavior slave will be looking for amount of position was closed on master, and do the same. We see that 1.5 is 40% from original position, then slave will open the same 40% of its position:

Account Side Qty Symbol
Master Long 5.25 BTC/USDT
Slave Long 0.875 BTC/USDT