Reading Async trades after execution
            
                 14 Nov 2019, 07:59
            
                    
Hi,
When I run the code below, ReadMyTrades() does not print anything.
Could async experts provide some guidence on what can I do to read my trades after Async execution please?
         protected override void OnStart()
        {
            ExecuteMyOrder();
            ReadMyTrades();
        }
        private void ExecuteMyOrder()
        {
            for (int i = 1; i <= 5; i++)
            {
                ExecuteMarketOrderAsync(TradeType.Buy, Symbol.Name, Symbol.QuantityToVolumeInUnits(i));
            }
        }
        private void ReadMyTrades()
        {
            foreach (var position in Positions)
            {
                Print(position.Id);
            }
        }

PanagiotisCharalampous
14 Nov 2019, 08:29
Hi eofe,
This happens because you execute the order asynchronously. ReadMyTrades() is executed before the position opens.
Best Regards,
Panagiotis
@PanagiotisCharalampous