Candles are repainting on 'bar replay'

Hi all,

When I use bar replay to replay on a 1 hour step (on an hourly candle chart), the candles will sometimes repaint. I can’t work out why this is happening. What am I doing wrong? Thanks.

I am not sure what you mean with 'repainting" because technically the word ‘repaint’ means just drawing in response to WM_PAINT message. But if you mean that you charts modify past candles it only may mean that your formulas look into the future.

1 Like

I am facing a similar problem. My database is a 1min database with entries starting at 9:16 and database created with "$TIMESHIFT -0.016666667".

On bar replay with 5min step interval, on clicking Next, a bar appears capturing data for 1minute i.e. say, 9:31am. When I click Next again, 9:31am bar completes with data from 9:31-9:35am and a new bar appears with data for 9:36am.

How can I overcome this issue? Thanks in advance.

Hi @shaleen, and Welcome to the forum.

Please Search and follow the instructions to get your "Verified Badge".

You need to be verified to post questions.

Also, as a new member, you should read the "How to use this site", for lots of helpful tips.

Solution to Problem:- if we replace $TIMESHIFT -0.016666667 by $TIMESHIFT -0.016 while importing data, the error goes away.

SURPRISING!!! Can somebody point out why this happens?

Lastly, I have verified my license and read the basic stuff on this portal. Thanks.

It just means that your source data file had incorrect timestamps.

Source file data seems to be correct, sample below:-


The timestamps are wrong, forward looking. They should start at 9:15, if trading starts at 9:15.

What is to be done if Market closing & opening time changes / differs once or couple of times every year.
Indian National Stock Exchange follow official time form 9.15am to 3.30pm.
However every year there is an auspicious festival day when market trades just for one hour as per auspicious time which can change from 2pm onwards till 8pm.
Also recently there was problem of network so market was stand still from 10.40am till 3.45pm
But later same day from 3.45pm to 5pm special time was given to exit positions.

It does not matter when trading starts. What matters is that your bars have correct timestamp. Five-minute bar that covers 9:00:00..9:04:59 should have timestamp of 9:00, not 9:05.

@Tomasz, following your suggestion in other thread, I did a quick test, using the above "BANKNIFTY_F1" sample, ASCII data, importing it applying a $TIMESHIFT -0.0166667 and the resulting timestamp in the Quote editor are starting at 09:15:00.

I wonder if using such a fractional number (approx. corresponding to 1-M) will give correct results also importing a large dataset, or if there is the risk of misalignments in the long run?

I have multiple years of 1M data where the timestamp is at the bar's close)*.
Up to now I used an external script to offset my timestamps, but if you confirm that $TIMESHIFT will work correctly also for a 1-M (using a rounded value with repeating decimals) I may save some time importing these series directly.

* The data I plan to use does not start each day simultaneously for all the tickers (it includes Outside RTH), so a misalignment may not be easy to spot visually.

Don't worry.
Internally AmiBroker uses double precision floating point for timeshift. It means 64-bits.
The dates in Windows are also stored as double precision floating point (64-bit).

So we don't lose any precision. Approximate resolution of this format is 1 microsecond.

You just need to make sure you specify MORE than few digits because double precision is actually 15 significant digits, so for one minute shift backwards you should use:

-0.0166666666666667 // correct timeshift for 1-minute
1 Like