Time per bar on tick chart

Questions about MultiCharts and user contributed studies.
User avatar
joebone
Posts: 175
Joined: 05 Sep 2018
Has thanked: 53 times
Been thanked: 4 times

Time per bar on tick chart

Postby joebone » 30 Nov 2022

Hello,
I have this indicator running on a tick chart. I may be missing something very stupid but I dont understand why this jumps up when ever the bar contains an hour change.
  • My goal here is to get the Time per bar on a tick chart.

Code: Select all

//Time per bar Vars: Time_per_bar(0), Rolling_Time(0); If Date<> Date[1] then Time_per_bar = Time_s else Time_per_bar = Time_s - Time_s[1]; Rolling_Time = Rolling_Time+Time_per_bar; Plot1(Time_per_bar);

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Time per bar on tick chart

Postby ABC » 01 Dec 2022

joebone,

Time_s is in HHmmss format i.e. every new hour will add 10000 to the value. This causes the jump you are seeing.
Depending on the chart settings you are working with you could consider converting Time_s to seconds and building the difference with that.

Regards,

ABC
Hello,
I have this indicator running on a tick chart. I may be missing something very stupid but I dont understand why this jumps up when ever the bar contains an hour change.
  • My goal here is to get the Time per bar on a tick chart.

Code: Select all

//Time per bar Vars: Time_per_bar(0), Rolling_Time(0); If Date<> Date[1] then Time_per_bar = Time_s else Time_per_bar = Time_s - Time_s[1]; Rolling_Time = Rolling_Time+Time_per_bar; Plot1(Time_per_bar);

User avatar
joebone
Posts: 175
Joined: 05 Sep 2018
Has thanked: 53 times
Been thanked: 4 times

Re: Time per bar on tick chart

Postby joebone » 01 Dec 2022

Thanks for reply ABC,

How would you convert to seconds?

User avatar
ABC
Posts: 718
Joined: 16 Dec 2006
Location: www.abctradinggroup.com
Has thanked: 125 times
Been thanked: 408 times
Contact:

Re: Time per bar on tick chart

Postby ABC » 02 Dec 2022

joebone,

using the built-in function TimeToSeconds could be one idea.

Regards,

ABC
Thanks for reply ABC,

How would you convert to seconds?


Return to “MultiCharts”