Why is Open[0] the same value as Close[0], High[0] & Low[0]??

 

Hello all,


My first time post to the forum, would really like someone to explain what I'm doing wrong here.


I have an custom written EA using M30. Currently when I try and get the value of Open[0] for the current candle lets say it returns 1.4578. Then I go for the value of Close[0] and its the same value 1.4578. So I think ok, its a doji, but then High[0] and Low[0] also return the same value 1.4578.....


So I did a little test: (borrowed code below from this forum)

datetime barTime=0;
int start()
{
  if( barTime < Time[0] )
  {
    //ONLY get here IF *new bar*
    // we have a new bar opened
    barTime = Time[0]; // keep the new bar open time
    //now we do ALL new bar work...
    Print(Open[0]," ",Close[0]," ",High[0]," ",Low[0]);
  }
  return(0);  //exit EA back to Terminal

}

This then prints the following:

2009.05.27 23:57:50	2005.03.17 11:30  MY_EA EURUSD,M30: 1.3381 1.3381 1.3381 1.3381
2009.05.27 23:57:50	2005.03.17 11:00  MY_EA EURUSD,M30: 1.3397 1.3397 1.3397 1.3397
2009.05.27 23:57:50	2005.03.17 10:30  MY_EA EURUSD,M30: 1.3398 1.3398 1.3398 1.3398
2009.05.27 23:57:50	2005.03.17 10:00  MY_EA EURUSD,M30: 1.3401 1.3401 1.3401 1.3401
2009.05.27 23:57:50	2005.03.17 09:30  MY_EA EURUSD,M30: 1.3407 1.3407 1.3407 1.3407
2009.05.27 23:57:50	2005.03.17 09:00  MY_EA EURUSD,M30: 1.3396 1.3396 1.3396 1.3396


As you can see, 100% of the time the Open, Close, High & Low are the same values...


What I would like to do is on every 30 minute bar, My EA gets the current candle prices for Open, Close, High and Low - AND they are the real prices :)

 
You are looking at only the first tick in the new bar. You need to look at subsequent ticks if you want to see other values
 
FXtrader2008:
You are looking at only the first tick in the new bar. You need to look at subsequent ticks if you want to see other values

OK, so let me get this straight.


Every 30 Minutes my EA gets invoked. A number of ticks get passed in, is it 30 ticks - 1 for each minute?


My current thinking is the following:


Every 30 minutes my EA gets invoked.

Close[0] = the current tick

Close[1] = the previous 30 minute tick

and so on...


If that not correct?

 
johnfilo:

OK, so let me get this straight.


Every 30 Minutes my EA gets invoked. A number of ticks get passed in, is it 30 ticks - 1 for each minute?


My current thinking is the following:


Every 30 minutes my EA gets invoked.

Close[0] = the current tick

Close[1] = the previous 30 minute tick

and so on...


If that not correct?


A tick is a change in the price within a candle. The number of ticks in a candle is not a constant number.

When a new candle begins Open[0], Close[0], Low[0], High[0] are equal. If you wait some time (some ticks) and check them again they will differ.

 

Every 30 Minutes my EA gets invoked.

if( barTime < Time[0] 
No, your EA gets invoked each tick. You are ignoring all of them except the first tick per bar.