CandleCountDown / Period() - TimeFrame M15 - page 2

 

GumRai:

candle close time - TimeCurrent() is the number of seconds remaining until the M15 candle closes

WHRoeder:
  1. Instead of _Period * 60 you can use PeriodSeconds - Common Functions - MQL4 Reference
  2. You have to use iTime - Timeseries and Indicators Access - MQL4 Reference not Time.


(Today I started again try to resolve this issue.) 

Big thanks for the great advices.

I already know (after you mentioned) I'd get next M15 Candle Close Time, I tried like below code in M1 Chart.

CandleCountDown  = Time[0] + PeriodSeconds( PERIOD_M15 ) - TimeCurrent();
convert_ToString = StringConcatenate( tab_size, StringSubstr( TimeToStr( CandleCountDown, TIME_MINUTES|TIME_SECONDS ), 3 ));

It's recounting each new minutes.

Please give me good advice, I several times read your advises. 

 
  1. Max-Enrik: It's recounting each new minutes. Please give me good advice, I several times read your advises.
    CandleCountDown  = Time[0] + PeriodSeconds( PERIOD_M15 ) - TimeCurrent();
    convert_ToString = StringConcatenate( tab_size, StringSubstr( TimeToStr( CandleCountDown, TIME_MINUTES|TIME_SECONDS ), 3 ));
    You read it but you didn't read it.
    What part was unclear?
    WHRoeder:
    1. Instead of _Period * 60 you can use PeriodSeconds - Common Functions - MQL4 Reference
    2. You have to use iTime - Timeseries and Indicators Access - MQL4 Reference not Time.
    What part was unclear?
    GumRai: You set a value for CandleCountDown, do nothing with that value and then immediately  assign another value to the variable
    datetime CandleCountDown = iTime ( Symbol(), PERIOD_M15, 0);

    gives you the time that the candle opened, you need the time that the candle will close

    so add PERIOD_M15*60 to get candle close time

    candle close time - TimeCurrent() is the number of seconds remaining until the M15 candle closes


  2. Attached is my indicator that uses OnTimer to make a continuous countdown (of chart period) with a bell.
Files:
 
Extremely thanks William.

Great question which one you asked (really thanks for your question): What part was unclear?


// PERIOD_M15 was Opened
datetime CandleCountDown_bar_Opened = iTime(Symbol(), timeframe_period, 0);

// PERIOD_M15 will Close
datetime CandleCountDown_bar_Closed = PeriodSeconds(timeframe_period);

// I am trying to Counting
datetime CandleCountDown_counting   =  CandleCountDown_bar_Opened + CandleCountDown_bar_Closed - TimeCurrent();

// Convert To String
convert_ToString = StringConcatenate( tab_spaces, StringSubstr( TimeToStr( CandleCountDown_counting, TIME_MINUTES|TIME_SECONDS ), 3 ));

 

So right now Market Closed, and is this code right?

Please let me know about that, after your answer I will strop researching about that.

Also really thanks for the attachment file.

(I tested it with 'Strategy Tester' so it looks like running good.)

Huge thanks WHRoederGumRai.

 

What can I say huge guys WHRoederGumRai - BIG THANKS!

It works perfectly.

Reason: