How To Get Current Time From The Current Candle?

 

Hello everybody,


I need a little help and I don't know where to start.

I need to know the current time from the candle and know if it's in it's midle life.

For example, a timeframe of 5 minutes, I wanna know when this candle passes it's 2:30 minutes. Same as 10 timeframe, where I wan't to do something when it passes 5 minutes.

I wan't to try to make decisions, on the OnTick function, only when the candle passes 50% of it's life..

I don't know if it's clear what I'm trying to achieve here.

I'm sorry about my english and if did something wrong.


Thanks in advance.

 
bruno_shady: I need to know the current time from the candle and know if it's in it's midle life.
  1. You know when the candle begins. Time[0] or the MT5 equivalent.
  2. You know when the candle ends. begins + PeriodSeconds(_Period)
  3. You know the middle. (Begin+End)/2
What's the problem?
 
William Roeder #:
You know the middle. (Begin+End)/2

You made a typo, it doesn't look like the middle of a candle.


   bool permission = TimeCurrent() > Time[0] + PeriodSeconds(_Period) / 2;
   //...
   if(permission)
      makeDecisions();

This is for MQL4. For MQL5, replace Time[0] with the current candle open time.

(I haven't tested it)