infinite loop

Created at 13 Nov 2017, 15:52
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!
ZE

zendoo

Joined 23.10.2017

infinite loop
13 Nov 2017, 15:52


Hi ,

I was testing a bit of code, and got stuck in an infinite "WHILE LOOP"...

... and as the code was applied to a chart, Calgo became irresponsive. I had to kill the task and manually delete the files in the cAlgo\sources\Indicators\... folder.

Is there a quicker way 'out of infinity' than kill_task/delete file ? :)

...or do i just need to add a failsafe inside the WHILE condition that could look like :
 

var failsafe = 5000;
var i = 1;
...
while (condition && i < failsafe)
{
    // some code here ...
    i++;
}

 

Thanks for any help.


@zendoo
Replies

PanagiotisCharalampous
20 Nov 2017, 11:03

Hi zendoo,

Your question is very general for somebody to give a more specific answer to it. In principle, you should write your code in a way that it does not fall into infinite loops. If you could share your code with us then we could maybe give you a more specific advice.

Best Regards,

Panagiotis


@PanagiotisCharalampous