Understanding of the state of bot.Positions if there is trade occur in the loop
Understanding of the state of bot.Positions if there is trade occur in the loop
07 Jun 2021, 18:44
Hi, I will like to understand more when we execute bot.Positions.
Example:
foreach (var pos in this.bot.Positions.Where(x => x.SymbolName == this.symbol.Name))
{
TradeResult res = this.bot.ExecuteMarketOrder(this.currDirection, this.symbol.Name, inputLot, this.symbol.VolumeInUnitsToQuantity(inputLot).ToString());
// INSIDE HERE
}
What will happen to the Positions state if we perform close trade/execute trade/modify trade during the looping?
Will the looping immediately include the newly opened trade into the Positions? And will the Positions count will increase?
OR
The Positions state still remains as previous(before closing the trade until I exited the loop?
Thanks
amusleh
08 Jun 2021, 12:04
Hi,
The positions collections will be updated immediately after sending a position execution request, try this sample code:
@amusleh