Are threads ok in cBots?
            
                 15 Apr 2019, 20:28
            
                    
Is it safe to create a Thread from within a cBot?
My problem is that putting my logic within OnTick() is not fast enough always since it depends on the speed of the tick
So I'm thining about putting it in a Thread or some kind of Timer, does cTrader supply a timer mechansim?
Replies
                     AlgoCorner
                     15 Apr 2019, 21:52
                                    
You can do:
 
         protected override void OnStart()
        {
            Timer.Start(TimeSpan.FromMilliseconds(100));
        }
        
        protected override void OnTimer()
        {
            Print("Test");
        }
If you need more timers you could use the Timer inside System.Windows.Forms, I read that is also single threaded, read the documentation here:
https://docs.microsoft.com/en-us/dotnet/api/system.windows.forms.timer?view=netframework-4.7.2
The timers inside System.Timers are not single threaded and I think they're not safe.
@AlgoCorner
                     AlgoCorner
                     17 Apr 2019, 18:09
                                    
My bad tho, I tried it and it doesn't work outside forms, the one built in cTrader is enough for most tasks I think.
@AlgoCorner

dalinar
15 Apr 2019, 20:29
note: I'm not going to open or close trades from within the thread
@dalinar