Hello There ! How could I code using For loop but end it with break(); method instead of defind end index in the first place.

Created at 12 Apr 2021, 19:55
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!
IM

imrealfighter

Joined 09.11.2020

Hello There ! How could I code using For loop but end it with break(); method instead of defind end index in the first place.
12 Apr 2021, 19:55


Hello There Everyone.
I have a little problem with the coding issue can't figure it out. 
hope someone could guide me or give me some hint.


I would like to use for loop once and I don't know where the loop gonna end and it only ends when reaches some condition in for loop 
(such as when the current price reach or beyond 1.777) we're calling break(); 
instead of using for(int i = 1;i < 10;i++){} like that

normally if we use a normal for loop we know where it's gonna end. but with OnTick(){} and Price movement, we don't know yet where and when the price is gonna meet our 
condition so is there a way to code for loop and don't know where it's gonna end? 

P.S. I try to write a method with for loop in it and put it on OnTick(){} 
but doesn't work like I expect, It starts from the first Index to The lastIndex every new tick occurs.
I just want to use for loop only once and when it reaches the condition it break(); the loop that's it.


Thank you in advance. 
 


 


@imrealfighter
Replies

imrealfighter
12 Apr 2021, 20:05

Bring it in a nutshell 

I want my for loop to run when a new tick occurs until it reaches a condition that has been set in the for loop.


@imrealfighter

PanagiotisCharalampous
13 Apr 2021, 09:37

Hi imrealfighter,

Check While Loops.

Best Regards,

Panagiotis 

Join us on Telegram


@PanagiotisCharalampous

imrealfighter
13 Apr 2021, 11:21

RE:

PanagiotisCharalampous said:

Hi imrealfighter,

Check While Loops.

Best Regards,

Panagiotis 

Join us on Telegram

 

Hello PanagiotisCharalampous Nice to meet you again and thank for your kind as always.

Thank you. I'll try it.


@imrealfighter