I wonder if someone could help me out. It's driving me crazy.
I have the following code:
// Check previous candle and previous of previous candle
Print("bar1 "," Close: ",Close," - "," Open: ",Open," = ",Close-Open);
Print("bar2 "," Close: ",Close," - "," Open: ",Open," = ",Close-Open);
This is the print screen:
The values Open and Close for the previous candle and previous of previous candle are wrong.
If I stop the EA and run it again for same, it works as expected:
I initiate the code only once per bar:
static datetime Time0;
// Check for entry condidtions and set a stop order
Any idea why Open and Close values for  and  might be wrong? This doesn't happen always though, it happens randomly.
This can happen if start of your EA got a tick but has no history yet.
I check for Tickvalue to be greater 0 or check Bars > 100
What do you mean by "start of your EA got a tick but has no history yet"? The EA was running since Monday so the start of the EA is Monday, today is Wednesday when the error happened. I don't fully understand how no history yet. Can you please explain it?
Surely the chart has more than 100 bars. The EA worked before on same chart. The error happens randomly.
I mean if you start the terminal with charts with EAs and/or indicators. They all could get a tick while all the information from the server has not been loaded - kind of thread race.
If it happens randomly may be the quotes of the broke have 'wholes'?
Print(..) the necessary information in those cases!
Are you sure that you do not have a similar block of code elsewhere?
I don't believe that a print of a calculation using doubles can print as -0, it would be printed as something like -1e015, if it was exactly zero, it would print as 0.0
I can suggest nothing. The prints that you show should not be possible from that code.
Maybe you should show the whole code.
To add comments, please log in or register