iTime not returning the current bar open time - page 2

 
Lorentzos Roussos #:
SymbolInfoInteger(...,SYMBOL_TIME)

I just noticed there is one symbol among 22 that is always one bar late...  Precisely the one I am working with for testing. Must be a pure coincidence.

SymbolInfoInteger returns the same timestamp as the other symbols, give or take one second, but for some reason this one chart doesn't transition to the new bar.
 
dc3463456 #:

I just noticed there is one symbol among 22 that is always one bar late...  Precisely the one I am working with for testing. Must be a pure coincidence.

SymbolInfoInteger returns the same timestamp as the other symbols, give or take one second, but for some reason this one chart doesn't transition to the new bar.

Is not an offline symbol or anything ?

 
Vladislav Boyko #: Using time[] and Time[] does not require error checking

But using time[] does require setting as-series.

In MT4, buffers and MT4 predefined arrays are all ordered AsSeries. There is a difference between the arrays passed to OnCalculate (e.g. low[]) and the MT4 predefined variables (e.g. Low[].) The passed arrays have no default direction, just like MT5.

To determine the indexing direction of time[], open[], high[], low[], close[], tick_volume[], volume[] and spread[], call ArrayGetAsSeries(). In order not to depend on default values, you should unconditionally call the ArraySetAsSeries() function for those arrays, which are expected to work with.
          Event Handling Functions - Functions - Language Basics - MQL4 Reference

 
Lorentzos Roussos #:

Is not an offline symbol or anything ?

I don't know what you can possibly mean given the last quote is 0 second old.

Can someone explain why there is one chart that doesn't want to draw a new bar?

 
dc3463456 #:

Can someone explain why there is one chart that doesn't want to draw a new bar?

I don't think there are many telepaths here.

Forum on trading, automated trading systems and testing trading strategies

iTime not returning the current bar open time

Vladislav Boyko, 2023.08.16 21:35

  1. What is the value of Time[0]? (the same or not)
  2. From which event handling function are you calling iTime()?
  3. What does GetLastError() return after calling iTime()?
4. Code to reproduce
 
Vladislav Boyko #:

I don't think there are many telepaths here

You don't need telepathy. I asked the question with written words and I exposed the issue clearly. What do you don't understand?

As for the pseudo code:

1. Loop though array or symbols

2. Print(iTime(SYMBOLS[i],PERIOD_CURRENT,0)) 

3. Notice one symbol is always late

4. Look at the chart of said symbol

5. The quotes are coming in but the new bar has not been drawn, explaining why it is late.

That's not supposed to happen in my book and I don't know how it does, but you guys know better what could be going on.

 
dc3463456:

Should return the current bar open time, but I have an issue where it sometimes returns the previous bar time.

I didn't think it was possible.


Maybe if I RefreshRates() ? Edit: Nope. Still happenning. 

Try the prices buffer array after copying rates to it using copyrates() into the new double array and then extract the required info like time and price info using the desired candle in the array index like array[0].time
 
Zyad Nhra #:
Try the prices buffer array after copying rates to it using copyrates() into the new double array and then extract the required info like time and price info using the desired candle in the array index like array[0].time

I will look into it. Thanks for your help.

 

To recap, sometimes iTime(SYMBOLS[i],PERIOD_CURRENT,0) is late even though several new bars have appeared on the chart. Other times even the chart is late too.

Also, the chart is in use; I refresh quotes before each iTime call and GetlastError() reports no error.

I have greatly improved the situation by no longer using the demo account.

My best guess is that there is a problem with my broker's data. Funny how it only affects the symbol I'm working with while coding.

 
dc3463456 #:

You don't need telepathy. I asked the question with written words and I exposed the issue clearly. What do you don't understand?

As for the pseudo code:

1. Loop though array or symbols

2. Print(iTime(SYMBOLS[i],PERIOD_CURRENT,0)) 

3. Notice one symbol is always late

4. Look at the chart of said symbol

5. The quotes are coming in but the new bar has not been drawn, explaining why it is late.

That's not supposed to happen in my book and I don't know how it does, but you guys know better what could be going on.

You need to stop your attitude if you want help on this forum.

You didn't provide working code to reproduce the issue, you didn't answer to question asked by people.

This is a technical forum, we don't need words, we need facts and useful information. Code, logs, settings and the like.