how to store bid price?

motorola

Junior member
13 0
consider this piece of code:
Code:
int start(){

  doProcess();
  Alert(Bid);
  
  return(0);

}
when start is executed, Bid is 1.0000. let' say doProcess() took 2 seconds to complete before printing Bid, and in the two-second window, the Bid price changed to
1.0001
1.0002
1.0003
(three ticks within while doProcess() was executing). My question is, what would be printed? doProcess() executed 4 times and all four (1.0000 to 1.0003) printed, or doProcess() executed only once and only 1.0003 printed? thanks.
 

wackypete2

Legendary member
10,229 2,055
neither.
1.0000 would print 1 time. When the start() function is executed again then it would print whatever the last bid was at the time of the code execution.
During execution rates stored in the mt4 arrays for use in ea's will not update. To update rates while the code is running you need to use the MT4 RefreshRates(); function.

Peter
 

motorola

Junior member
13 0
thanks for the reply.
so, in short, 1.0001 until 1.0003 will never be printed and doProcess() will be executed only once?
also, if the code is modified to this:
Code:
int start(){

  Alert(Bid);
  doProcess();
  Alert(Bid);
  
  return(0);

}
and the case is the same, 3 ticks while doProcess() is executing (after doProcess() finished executing, Bid is 1.0003), is it always guaranteed that as long as Bid variable is called from the same start() function, the value will remain unchanged, even when in reality, the Bid has already changed three times.
1.0000 will be printed twice. is this correct? thanks
 
Last edited:

wackypete2

Legendary member
10,229 2,055
This will return the latest bid while in the same start function.

int start(){

Alert(Bid);
doProcess();
RefreshRates();
Alert(Bid);
doProcess();

return(0);

}
 
 
AdBlock Detected

We get it, advertisements are annoying!

But it's thanks to our sponsors that access to Trade2Win remains free for all. By viewing our ads you help us pay our bills, so please support the site and disable your AdBlocker.

I've Disabled AdBlock