Bar[0] and current open bar confusion

 
Hi, can someone please clarify the name convention for bars in an array of type Open, Close, High, Low. If bar[0] is the current open bar on the chart, then how can it have a close price, since it's not closed yet? Or is bar[0] the last closed bar before the current open bar?
 
Close[0] is the current price
 
Keith Watford:
Close[0] is the current price

I know it says that in the array definition. But if it's the current price, how can the bar be closed? Isn't the current bar an open bar? Sorry if this is obvious to everyone else. Or to put another way, if I want to reference the most recent closed bar, is that Close[1] or Close[0]?

 
clinteas2:
Hi, can someone please clarify the name convention for bars in an array of type Open, Close, High, Low. If bar[0] is the current open bar on the chart, then how can it have a close price, since it's not closed yet? Or is bar[0] the last closed bar before the current open bar?

watch out for what type of array you are analyzing - Did you use ArraySetAsSeries() to true? - if so, your bar[0] is your current bar, and so, the close price is the last traded price. You will only have the real bar close price when a new bar is open, obviously, so you canl access bar[1] to have that real closing price...

;)

 
clinteas2:

if I want to reference the most recent closed bar, is that Close[1] or Close[0]?

Close[0] == current price of the current filling bar; can change

Close[1] == the close price of the first fully filled bar; does not change

Close[2] == the close price of the second fully filled bar; does not change

Close[3] . . .

 
Anthony Garot:

Close[0] == current price of the current filling bar; can change

Close[1] == the close price of the first fully filled bar; does not change

Close[2] == the close price of the second fully filled bar; does not change

Close[3] . . .

Thanks all, that's cleared it up. So essentially, Close[0] is the current bid price in the open candle, and Close[1] is the close price of the most recent candle. Got it!
 
clinteas2:
So essentially, Close[0] is the current bid price in the open candle

You are close, but look here:

https://www.mql5.com/en/forum/298917#comment_10233717

Close price & Bid Price
Close price & Bid Price
  • 2019.01.11
  • www.mql5.com
Hi, What is the different between Close price and Bid Price? Thanks...
 
So essentially, Close[0] is the current bid price in the open candle,

I would treat that value as undefined since it has no logical meaning as you well understood before. Since it makes no sense to have a closing value in a bar that is still not closed, just do not use that value at all. Anything may be stored there, and it will be a wrong value whatever it is.

 
//Check what is the Current Candle Trend
  if(Close[0]>Open[0] || Bid>Open[0])
    {
     //Current Candle is Bullish
     Print("Current Candle is BUY Trend UP ");
    }else
     if(Close[0]<Open[0] || Bid<Open[0])
       {
        //Current Candle is Bearish
        Print("Current Candle is SELL Trend Down ");
       }
  //=====================================
You can try this to check what is the current candle behavior