# Compare Any Time Of Bar By Seconds

378

How to see time of bar and then see time of bar at like 45 seconds for example

if i had to write it out it would be something like this,

get time of bar in seconds(current time)

get time of last bar in seconds and add the time in seconds to it we want and then compare it

if the comparison results in the current time being higher then the desired time then output nothing

if the comparison results in the current time being lower than the desired time than output something

therefore it could it also be possible to output something when the comparison is equal ??
Moderator
10533

int seconds=45;
if(TimeCurrent()-Time[0]<=seconds)
{
//Do Something;
}
.
378

Like what about checking the order pool for orders taken from the current bar?

if(TimeDayOfYear(OrderOpenTime())==TimeDayOfYear(TimeCurrent()) &&
OrderSymbol()==_symbol && OrderMagicNumber()==newMagic && OrderComment()==_comment)

I think it might only work for the day .. but I would like to know if an order was placed on the current bar.
Moderator
10533

int bar_shift=iBarShift(Symbol(),0,OrderOpenTime());
if(bar_shift==0)
//Order was opened in the current bar
Moderator
2342

Keith Watford:

int bar_shift=iBarShift(Symbol(),0,OrderOpenTime());
if(bar_shift==0)
//Order was opened in the current bar

Or:

if(OrderOpenTime() >= Time[0])
Moderator
10533

honest_knave:

Or:

if(OrderOpenTime() >= Time[0])
Now I feel foolish. That didn't even occur to me.
378

excellent guys i like the iBarshift of OrderOpenTime() because what bar is the order from?
Moderator
2342

Keith Watford:
Now I feel foolish. That didn't even occur to me.
Your solution is more flexible i.e. other symbols and timeframes, or checking other bars like the OP now wants.
378

honest_knave:
Your solution is more flexible i.e. other symbols and timeframes, or checking other bars like the OP now wants.
i don't know how it even works ;)
Time[0] always incrementing, OrderOpenTime() older than Time[0]
if(OrderOpenTime() >Time[1]){//its bar 0}
Moderator
2342

Brian Lillard:
i don't know how it even works ;)
Time[0] always incrementing, OrderOpenTime() older than Time[0]

Time[0] is the open time of the current bar, not the latest time.

Example:

Time now is 12:03:47 (hh:mm:ss)

Time[0] on an M1 chart is 12:03:00

Moderator
10533

Brian Lillard:
i don't know how it even works ;)
Time[0] always incrementing, OrderOpenTime() older than Time[0]
if OrderOpenTime() older than Time[0] then it cannot gave been opened in the current bar.