Simply:
Store your initial balance to a variable, initial_balance
0_1551628675874_463188c0-2e3f-4214-9d33-0b3e6cd69205-image.png
Before buying, check how much the balance has grown (or fallen) from the start:
0_1551628843844_0dfdea52-db10-4f2a-8b58-8d8427140b48-image.png
Then we can update our lot value by that ratio, (current equity / initial balance) times our standard lot amount (0.01). AccountEquity() is a standard mql4 formula that returns equity
Then we can just insert the variable lot to "buy now":
0_1551628961569_4b65b44d-6a19-4647-8562-4fffbf1b58c0-image.png