Download MetaTrader 5

Indicators: Renko Time and Time Between Candles Indicator

To add comments, please log in or register
Automated-Trading
Admin
100917
Automated-Trading 2015.02.27 10:33 

Renko Time and Time Between Candles Indicator:

A very simple indicator to display the difference in time between candles in seconds.

RenkoTime on a 1 minute chart.

Author: pabloroacho

pabloroacho
563
pabloroacho 2015.03.01 15:08  

Small change, I changed...

   SetIndexLabel(0,"RenkoTime v 1.0");

To...

   SetIndexLabel(0,"Seconds");

So the indicator label is better. Thanks.

Alberto Cioccarelli
2647
Alberto Cioccarelli 2015.03.02 12:33  
the idea and 'good
I also use indicators with renko
now I try your idea and then tell you if valid
pabloroacho
563
pabloroacho 2015.03.02 16:32  

cool thanks spacca


I have looked at this a bit more. I should have looked harder for existing code already written by other people, it would have saved me writing this! I should acknowledge thrdel https://www.mql5.com/61481/forum and the person that wrote the RenkoAM_v2.0.mq4 indicator code, which you can find with a google search. Seems there is a bit more to this than first glance. My indicator bars dont match the bars made by the code or indicator they wrote. My code at present puts the length of time between the start of the previous bar and the start of the current bar under the current bar. The others put this value under the previous bar, which is, I think, a better indication as to how long any particular bar took to complete, and this then matches values given by the mt4 volumes indicator etc, as per thrdel's posts. I changed my code to match this but then it becomes evident, a problem as to what to assign to the current bar since it has not yet completed or the next bar started, to calculate the time value the same way. The bar can be left uncalculated (0) until it finishes and there is a next bar.

There is another way, which is to subtract the current bar start time from TimeCurrent();. When I changed the code to show this, I found another interesting fact. The current bar on a minute chart frequently takes more than 60 seconds to complete, as the feed is poor quality and time stamp frequently stalls and then jumps. The time returned as current time is the broker time, which is the same time that is stalling and jumping. Only if the next bar is missed will it show as a taller bar (say 120 seconds) on the minute chart. Otherwise, say, time stalls at 11:59:50, then at 12:00:20 the next minute bar magically appears 20 seconds late but saying it started at 12:00:00 so the previous bars time is till 60 seconds.

What started as a simple idea to get an idea how long renko bricks take to form has become much more complicated. If the computers local clock time could be accessed and syncronized to broker time, without the stalling, then that difference could be calculated. You would find that most minute chart candles actually start after the beginning of the minute and last till past the minute due to time jumps but then display the exact start and end of the minute as the times. Seems that there is a TimeLocal(); function so maybe that could be used.

Maybe it is possible to create an independant internal counter or clock within the code that would count seconds without the broker feed stutters. The indicator still gives a good rough and ready impression of timescales for renko bricks of a reasonable large enough size.

One last thing I noticed was that the place where the period seperator is displayed on renko live chart seems odd to me. A brick starts at, say, 11 pm and doesn't complete until the next brick starts at 1 am the next day, and yet the separator is through the one that started at 1 am. Seems the seperator goes through the first brick or candle of the day, regardless. idk not sure lol.

Any opinions or comments would be appreciated thanks.

Time indicator - MQL4 forum
  • www.mql5.com
Time indicator - MQL4 forum
pabloroacho
563
pabloroacho 2015.03.02 17:32  

hmm, I tried TimeLocal(); it does return the local computer clock time, but... the whole indicator seems to only update on a fresh time stamp or tick or something from the broker so it is still jumpy!!! grrr.

Seems now I need a way to get the indicator to update itself every real second and not as per jumpy broker time. Maybe something to do with ticks and maybe I can force it.

Any advice or suggestions welcome, thanks.

Ex Ovo Omnia
3191
Ex Ovo Omnia 2015.03.02 18:42  
pabloroacho:

cool thanks spacca


I have looked at this a bit more. I should have looked harder for existing code already written by other people, it would have saved me writing this! I should acknowledge thrdel https://www.mql5.com/61481/forum and the person that wrote the RenkoAM_v2.0.mq4 indicator code, which you can find with a google search. Seems there is a bit more to this than first glance. My indicator bars dont match the bars made by the code or indicator they wrote. My code at present puts the length of time between the start of the previous bar and the start of the current bar under the current bar. The others put this value under the previous bar, which is, I think, a better indication as to how long any particular bar took to complete, and this then matches values given by the mt4 volumes indicator etc, as per thrdel's posts. I changed my code to match this but then it becomes evident, a problem as to what to assign to the current bar since it has not yet completed or the next bar started, to calculate the time value the same way. The bar can be left uncalculated (0) until it finishes and there is a next bar.

There is another way, which is to subtract the current bar start time from TimeCurrent();. When I changed the code to show this, I found another interesting fact. The current bar on a minute chart frequently takes more than 60 seconds to complete, as the feed is poor quality and time stamp frequently stalls and then jumps. The time returned as current time is the broker time, which is the same time that is stalling and jumping. Only if the next bar is missed will it show as a taller bar (say 120 seconds) on the minute chart. Otherwise, say, time stalls at 11:59:50, then at 12:00:20 the next minute bar magically appears 20 seconds late but saying it started at 12:00:00 so the previous bars time is till 60 seconds.

What started as a simple idea to get an idea how long renko bricks take to form has become much more complicated. If the computers local clock time could be accessed and syncronized to broker time, without the stalling, then that difference could be calculated. You would find that most minute chart candles actually start after the beginning of the minute and last till past the minute due to time jumps but then display the exact start and end of the minute as the times. Seems that there is a TimeLocal(); function so maybe that could be used.

Maybe it is possible to create an independant internal counter or clock within the code that would count seconds without the broker feed stutters. The indicator still gives a good rough and ready impression of timescales for renko bricks of a reasonable large enough size.

One last thing I noticed was that the place where the period seperator is displayed on renko live chart seems odd to me. A brick starts at, say, 11 pm and doesn't complete until the next brick starts at 1 am the next day, and yet the separator is through the one that started at 1 am. Seems the seperator goes through the first brick or candle of the day, regardless. idk not sure lol.

Any opinions or comments would be appreciated thanks.

Your indi is quite OK, just the time is offset by one candle. I would not worry about the huge value at the session close, as you cannot detect it directly on the Renko. Though there are possible ways, they are not worth effort.
pabloroacho
563
pabloroacho 2015.03.02 19:41  

Hi Ovo,


yes, it is currently offset. i will correct this. it depends how you look at the time and what time you are really counting. look carefully at the renko bricks where the period seperator is over a weekend with the indicator, it is confusing!

right, until it is a bit more refined, i will not try and deduct the weekend or overnight close values. Nor divide it by the chart time value, although that makes sense as the way candles work it would always be a multiple of the chart time interval value.

pabloroacho
563
pabloroacho 2015.03.03 15:55  
pabloroacho:

Hi Ovo,


yes, it is currently offset. i will correct this. it depends how you look at the time and what time you are really counting. look carefully at the renko bricks where the period seperator is over a weekend with the indicator, it is confusing!

right, until it is a bit more refined, i will not try and deduct the weekend or overnight close values. Nor divide it by the chart time value, although that makes sense as the way candles work it would always be a multiple of the chart time interval value.


I have now made some corrections to the calculations. Please see Version 2 when it gets put up. Thanks.

pabloroacho
563
pabloroacho 2015.03.05 14:01  

version 2 has been put on :) array of bars lines up right now and the current bar time is taken from TimeCurrent();

I may add another array / bar or two for the number of seconds under or over the candle took to form, from its stated start and finish times. This might have to be a sperate thing as it isn't logical for renko.

Also might move the whole indicator to inside an OnTimer(){ event to make it update better.

Any suggestions or comments would be great, thanks.

Alberto Cioccarelli
2647
Alberto Cioccarelli 2015.03.07 00:26  
uff
Edu
9
Edu 2015.06.12 22:11  
Can you add a simple moving average option so it can gives the average time base on a number of bars?
12
To add comments, please log in or register