How I Can Sleep() My Robot

Created at 13 Jan 2014, 18:08
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
waddahattar's avatar

waddahattar

Joined 01.10.2013

How I Can Sleep() My Robot
13 Jan 2014, 18:08


Where Is the Sleep() Function in cAlgo API.

 

Thanks


@waddahattar
Replies

Spotware
14 Jan 2014, 10:23

To suspend the current thread for a specified number of milliseconds:

int milliseconds = 1000;
System.Threading.Thread.Sleep(milliseconds);

We do not recommend that you do this. What is the logic you need implemented?


@Spotware

waddahattar
14 Jan 2014, 14:18

I need some Idea for make cRobot works like metatrader script .

 

I try to make loop while(true) into cRobot with Sleep() to allow cAlgo to work without interruption


@waddahattar

Cerunnos
14 Jan 2014, 14:44

If I want to execute a function with 2 seconds delay to set a new SL, how can I code that. Should I use Timer class, or is there a better alternative?


@Cerunnos

Spotware
14 Jan 2014, 14:45

We recommend that you add all logic in the OnTick method instead of using a while loop. Using a while loop with the Sleep method will affect performance. 


@Spotware

waddahattar
14 Jan 2014, 16:35

RE:

Spotware said:

We recommend that you add all logic in the OnTick method instead of using a while loop. Using a while loop with the Sleep method will affect performance. 

Is there a way to force the cAlg to trigger OnTick() event from outside cAlgo with some API function .

 

I Want sometimes to Buy or Sell without wait the Price to change in cAlgo .


@waddahattar

Spotware
16 Jan 2014, 17:28

You could code the logic in the OnStart method and then start the cBot whenever it is necessary. This way you may run script-like cBots that do not depend on incoming ticks.
Very soon cBots will be included in cTrader, so you may attach multiple cBots to a chart and then start and stop whichever one you choose at any given moment.


@Spotware

jani
11 Mar 2020, 23:55

 

 

 

 


@jani