Thanks for your reply.
Correct, you would want to use lock() in the same manner as shown in the help guide.
For reference, here is a link to C# lock: https://docs.microsoft.com/en-us/dot...lock-statement
In the help guide example, the first use of lock (in State.setDefaults) is to lock all accounts while your statement account = Account.All.FirstOrDefault(a => a.Name == AccountNametoTrade); searches for the account string found in AccountNameToTrade. Note that you are creating the object reference to account.
In the next use in the help guide, in State.DataLoaded, you should now use lock(account.Positions)
If I may suggest, I would not use account as an object name due to the many uses of account and it can also be confusing. The example uses myAccount to help differentiate.

Comment