Get bar replay to step through n hourly bars instead of 1-hourly bar

I recently discovered this useful "bar replay" feature. My data is in hourly bars. I would like to set the step interval to 4 hours or 2 hours. However, the option available are hourly, daily, weekly ...

Is it possible to somehow step through using 2 or 4 hourly bars?

@thankyou18 AFAIK there is no way to do it with the native Bar Replay tool.

Take a look at this alternative by @Milosz..

If you like it and is enough for your purposes, you should define your "custom" bar intervals in the Preferences ("Intraday" tab), apply it to your chart an then execute the proposed formula.


Thanks for the link. Tomasz has provided some design reasons on why there is a limitation on the flexibility in that link.

Moderator comment: Step interval has nothing to do with computer speed. So this is irrelevant

@thankyou18 this is the reason for what I wrote: "If you like it and it is enough for your purposes".

If you need to run a bar replay on a single chart this may be enough. If you need to synchronize tens of charts probably not.

In any case, the supplied formula may give you ideas to write your own "custom" bar replay, if you do not find better solutions.


@thankyou18 Here you can find a little improved version of my above code:


@beppe @thankyou18 - the quote is irrelevant to the question. Question was about "step interval" (the amount of time bar replay goes between steps) not stepping speed (how fast steps are taken). Computer speed has nothing to do with step size (interval).

One has to keep in mind that Bar Replay plays back ENTIRE DATABASE (ALL SYMBOLS) at once. I.e. ALL symbols data are played, not just single selected chart.

Therefore step size can be chosen from some "human friendly" units, i.e. minutes, hours, days. And units are stepped one by one (not two at once). It is not "limitation" of any kind. It is well-thought design decision (to make replay time stepping in "human-friendly" units).

But... Bar replay step size is totally independent from chart interval. So you can just select 2-hour interval for your CHART. And bar replay would replay your 2-hour chart (using two hourly steps per single candle).

On a side note: Custom codes are discouraged. Why? Because they can't do what Bar Replay does.
Bar Replays makes future data (past 'playback time') UNAVAILABLE. For example if you use say LastValue(MACD()) you will get the value of the bar at 'playback time'. No matter what function you try you won't be able to get data from any symbol past 'playback time'. Custom formulas don't give you that guarantee.


Of course I agree with you Tomasz (for the reasons quoted above). I discourage anybody to perform any tests using my code. It should be rather treated as a simple tool (or a gadget :wink: ) allowing to quickly and automatically scroll the chart on demand (i.e. quicker than the native solution - like 20-30 1-second bars per second). This code by default makes use of 1 future bar.

Step = 1;
SetBarsRequired( MinBars, Step );

Actually it originates from another thread ( Alert driven Bar Replay ) in which I was trying to help Herman ( @Beaver ) but I've failed and in the end we both agreed, that custom solutions can not replace built-in Bar Replay:

1 Like

@Tomasz, thanks for joining the thread and explaining to us why it is a lot better to stick to the built-in Bar-Replay.

And bar replay would replay your 2-hour chart (using two hourly steps per single candle).

My original answer was simply pointing to a formula that allows the OP to "simulate" (with all the limitations of the case) the bar replay using a single step per displayed candle, that I perceived - may be wrongly - like the OP's goal.

(The speed replay factor is something that I did not consider since, if needed, the user can set it as per the in-built tool; the quote was from @thankyou18).

Thanks again for making us fully aware of the issues and limitations of a custom solution for this task.


@thankyou18 in case you didn't know, if you want to select custom chart interval (like 2h, 4h, 20m, 2D etc.) as adviced by Tomasz:

... the simplest way is to type 2h, 4h, 20m, 2D etc.. and hit Enter:


1 Like

@Milosz and @Tomasz, selecting custom chart interval(like 2h, 4h) solved my problem. There's only a small inconvenience of clicking the mouse multiple times since each step is hourly.

@beppe, Sorry about the quote which was wrongly attributed to you. I copied and pasted the content from another thread. When I realised the mistake and wanted to correct it, I could not because edits are not allowed because the post has passed certain time window for edit.

Why click the mouse multiple times? Just press "PLAY" (green arrow) button. It will play back automatically.

1 Like

Just in case you prefer clicking , remember you can use space bar instead. Click once and then use space