iClose, iHigh, iLow, iOpen provide the value of previous candle or current candle

 

Hello,

Article : https://www.mql5.com/en/docs/series/iclose

iClose, iHigh, iLow, iOpen these values provide the current/Live/real-time candle information or previously closed candle information?. How can iClose value is possible for Current candle because ones the candle is closed, it became previous candle. ?

 
anuj71:
How can iClose value is possible for Current candle because ones the candle is closed, it became previous candle. ?

The close price of the current candle is always equal to the bid

 
Gerard William G J B M Dinh Sy #:
https://www.mql5.com/en/docs/series/iclose
I already given the same link in my original question. My question is, Is this values are for Current candle or Previous Candle?
Vladislav Boyko #:

The close price of the current candle is always equal to the bid

Thanks for confirming. 
 
Vladislav Boyko #:

The close price of the current candle is always equal to the bid

this is not true in a live sense, the bid price is activated via a line, it is often distant from the current candle close price. The bid and ask can be very similar in price but the tick price moves away from close price during high volatility and positions can hit stop loss away from the candle close price
 
Conor Mcnamara #:
this is not true in a live sense, the bid price is activated via a line, it is often distant from the current candle close price. The bid and ask can be very similar in price but the tick price moves away from close price during high volatility and positions can hit stop loss away from the candle close price

I don't quite understand what you're talking about. Have you ever seen those prices not being equal to each other?


 
Vladislav Boyko #:

I don't quite understand what you're talking about. Have you ever seen those prices not being equal to each other?


Yes, especially when the bid-ask spread is high. Have you seen what a bid price can be compared to the current close price during news events with extremely high volume?

FYI, every single OHLC price is lagging, on every timeframe as well.  A 1 tick timeframe is actually going to give more accurate representation of the market than a 1 second timeframe, and this is why tick charts are valid and respected in the software

 

I may not understand exactly what you mean but I think you are talking about different things.

The second bar is static , the first bar is dynamic and reflects the movement of the ontick and is in a state of flux until the time comes for a new bar to form, after which the bar is fixed as the second bar and becomes static. 

 
anuj71:

Hello,

Article : https://www.mql5.com/en/docs/series/iclose

iClose, iHigh, iLow, iOpen these values provide the current/Live/real-time candle information or previously closed candle information?. How can iClose value is possible for Current candle because ones the candle is closed, it became previous candle. ?

back to the original question: iClose, iHigh, iLow, iOpen provides both. The first bar is real-time and the others are historical. 

But for fast live trading it makes more sense to look bid and ask prices also. iXXX functions are very good for looking at historical timeseries data starting from the second (the first closed) bar.  

 
In MQL5, functions iClose, iOpen, iHigh, and iLow retrieve price values from historical data, not live or real-time updates. However how they work depends on the shift parameter you provide.

Understanding the shift Parameter:
  • shift = 0 → Refers to the current (unfinished) candle.
  • shift = 1 → Refers to the last closed candle.
  • shift = 2 → Refers to the candle before the last closed candle.

Example:
double close_price = iClose(Symbol(), PERIOD_M1, 0);

- This retrieves the closing price of the current candle (shift=0).
- But, since the current candle is still forming, the "close" price is actually the last known tick price (the most recent price update).
- Once the candle closes, the final close price is fixed and moved to shift = 1.

You might think that iClose should only work for closed candles. However, when requesting the closing price of an ongoing candle (shift = 0), MQL5 returns the last updated price.

It's not the actual close price but the current price, which will become the close price when the candle finishes.

For the current (unfinished) candle (shift=0):

  • iClose → Last updated price (not final close price yet).
  • iHigh → Highest price reached so far.
  • iLow → Lowest price reached so far.
  • iOpen → Open price (fixed at the start of the candle).

For a closed candle (shift=1, 2, ...):

  • iClose → Final closed price.
  • iHigh, iLow, iOpen → Fixed values for that completed candle.

If you need real-time tick data, use SymbolInfoDouble(Symbol(), SYMBOL_BID) or SymbolInfoDouble(Symbol(), SYMBOL_ASK).
 
Moh Royhan Nahado #:
In MQL5, functions iClose, iOpen, iHigh, and iLow retrieve price values from historical data, not live or real-time updates. However how they work depends on the shift parameter you provide.

Understanding the shift Parameter:
  • shift = 0 → Refers to the current (unfinished) candle.
  • shift = 1 → Refers to the last closed candle.
  • shift = 2 → Refers to the candle before the last closed candle.

Example:

- This retrieves the closing price of the current candle (shift=0).
- But, since the current candle is still forming, the "close" price is actually the last known tick price (the most recent price update).
- Once the candle closes, the final close price is fixed and moved to shift = 1.

You might think that iClose should only work for closed candles. However, when requesting the closing price of an ongoing candle (shift = 0), MQL5 returns the last updated price.

It's not the actual close price but the current price, which will become the close price when the candle finishes.

For the current (unfinished) candle (shift=0):

  • iClose → Last updated price (not final close price yet).
  • iHigh → Highest price reached so far.
  • iLow → Lowest price reached so far.
  • iOpen → Open price (fixed at the start of the candle).

For a closed candle (shift=1, 2, ...):

  • iClose → Final closed price.
  • iHigh, iLow, iOpen → Fixed values for that completed candle.

If you need real-time tick data, use SymbolInfoDouble(Symbol(), SYMBOL_BID) or SymbolInfoDouble(Symbol(), SYMBOL_ASK).

exactly like that - very accurate review :) !