what wrong with my While Loop

Back to topics list  | 1 2 3 To post a new topic, please log in or register
avatar
Moderator
3423
GumRai 2016.01.26 09:16 #
 

Ovo:
According to the code he issued it was used in an indicator.

 

In that case, the sleep function doesn't work in an indicator, so it is stuck in a loop that probably repeats millions of times per second. This causes the platform to freeze. Probably the print gets stuck in a queue and as the loop is using 100% cpu, nothing happens.

There is nothing to gain with this code.

Hardly any resources are used by simply checking for a new bar at every new tick and returning if a new bar is not found. 

avatar
126
Demos 2016.01.26 13:57 #
 

GumRai:

 

In that case, the sleep function doesn't work in an indicator, so it is stuck in a loop that probably repeats millions of times per second. This causes the platform to freeze. Probably the print gets stuck in a queue and as the loop is using 100% cpu, nothing happens.

There is nothing to gain with this code.

Hardly any resources are used by simply checking for a new bar at every new tick and returning if a new bar is not found. 

Yep, Sleep is of course the problem here, because it is inside an indicator :) But concerning the loop, it may be brutal without Sleep, but it is not infinite. It will use all the available core of the CPU, but given the presence of RefreshRates(), at some time it will report the new bar

 

best regards 

 

Back to topics list   | 1 2 3  

To add comments, please log in or register