Used in tick bars, or at least not in time, to evaluate the duration of the bar in seconds.
Returns the number of seconds elapsed to complete each individual bar.
Could be useful to measure the market speed in non-time-dependent charts: ticks charts, range bars, renko bars, etc.
Code emerged from discussion here: Indicator for bar duration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
// utilizzato nelle barre a tick, o comunque non a tempo, per valutare la durata della barra in secondi // ritorna il numero di secondi trascorsi per il completamento di ogni singola barra ptime = Time[1] ctime = Time // estraggo la differenza in ore if ctime>=10000 then hend = (ctime - (ctime mod 10000))/10000 ctime = (ctime mod 10000) else hend = 0 endif if ptime>=10000 then hstart = (ptime - (ptime mod 10000))/10000 ptime = (ptime mod 10000) else hstart = 0 endif // estraggo la differenza in minuti if ctime>=100 then mend = (ctime - (ctime mod 100))/100 ctime = (ctime mod 100) else mend = 0 endif if ptime>=100 then mstart = (ptime - (ptime mod 100))/100 ptime = (ptime mod 100) else mstart = 0 endif secstarttime = hstart*3600+mstart*60+ptime secendtime = hend*3600+mend*60+ctime barsec = secendtime-secstarttime // correggo l'eventuale cambio di giorno if barsec<0 then barsec = 3600*24-secstarttime+secendtime endif return barsec as "seconds/bar" |
Share this
No information on this site is investment advice or a solicitation to buy or sell any financial instrument. Past performance is not indicative of future results. Trading may expose you to risk of loss greater than your deposits and is only suitable for experienced investors who have sufficient financial means to bear such risk.
ProRealTime ITF files and other attachments :PRC is also on YouTube, subscribe to our channel for exclusive content and tutorials