Does RefreshRates() update OrdersTotal()?

 

Does RefreshRates() update OrdersTotal()?

I used below code to restrict no.of trades. But I got 11 trades. So I doubt whether I have to update OrdersTotal() before checking the condition.

Thanks in advance. 

if(Bid>=next_trade && OrdersTotal()<=10)
 
krishna_gopal_2:

Does RefreshRates() update OrdersTotal()?

No.  RefreshRates() only updates predefined variables.

I used below code to restrict no.of trades. But I got 11 trades. So I doubt whether I have to update OrdersTotal() before checking the condition.

if(Bid>=next_trade && OrdersTotal()<=10)
If you have 11 market/pending orders, then your IF statement shouldn't execute.  So you must have an error somewhere else.
 
krishna_gopal_2:

Does RefreshRates() update OrdersTotal()?

I used below code to restrict no.of trades. But I got 11 trades. So I doubt whether I have to update OrdersTotal() before checking the condition.

Thanks in advance. 

Read the documentation for RefreshRates() it says  "Refreshing of data in pre-defined variables and series arrays. "  these data are nothing to do with the Order pool.

If you have the code that you post and following this you have code to open 2 orders then you will end up with a max of 12 Orders . . .  but you don't show that code so it's impossible for anyone other than you to know. 

 

krishna_gopal_2:

I used below code to restrict no.of trades. But I got 11 trades. So I doubt whether I have to update OrdersTotal() before checking the condition.

if(Bid>=next_trade && OrdersTotal()<=10)

I assume it's if(condition) { open }

So when you have 10 orders you allow opening the eleventh.

 
WHRoeder:

I assume it's if(condition) { open }

So when you have 10 orders you allow opening the eleventh.


Sorry. I don't understand. Please elaborate.
 
krishna_gopal_2:

Sorting:

First trade is initiated and flags are set accordingly using indicator signal. Here I'm trying to add BUYs at an interval about 100pips. But second trade initiated by above if_statement places more than one order at a time (Like 3,4,7 orders). And there are 11 orders some times. Can you please find the errors?

Thanks in advance. 

if(OrdersTotal() > 0 && OrdersTotal() <= 10)

 means,  if OrdersTotal() is greater than 0 AND   less than or equal to 10 . . .  so 10 is greater than 0 and equal to 10 . . .  then you open a new Order so now you have 11.

 
RaptorUK:

 means,  if OrdersTotal() is greater than 0 AND   less than or equal to 10 . . .  so 10 is greater than 0 and equal to 10 . . .  then you open a new Order so now you have 11.

 


Thanks. I got it.

One more doubt. Does change in Ask/Bid in the middle of a loop or if_statement will re-initiate the start() function from there itself?

 
krishna_gopal_2:

One more doubt. Does change in Ask/Bid in the middle of a loop or if_statement will re-initiate the start() function from there itself?

No.  The documentation (see here) states that:

At incoming of new quotes, the start() function of the attached experts and custom indicators will be executed. If the start() function launched at the preceding quote was running when a new quote came, the new quote will be skipped by the expert. All new quotes income while the program was being executed are skipped by the program until the current execution of the start() function has been completed. After that, the start() function will be run only when a successive new quote incomes.

However, at times, it might be useful to use RefreshRates() to update the Ask/Bid prices (among other predefined variables).

Reason: