Barclose with Datetime bar update using Barmagnifier  [SOLVED]

Questions about MultiCharts and user contributed studies.
evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 124 times

Barclose with Datetime bar update using Barmagnifier

Postby evdl » 04 Nov 2015

When using Barmagnifier on 1 tick / IOG in a signal it will double the timestamp every barclose.

With the help of Datetime_bar_update I made a printout with this signal:

Code: Select all

Vars:
Intrabarpersist Bartime_value("");

// bar time per tick on ms
Bartime_value = datetimetostring_ms(datetime_bar_update);

// print to output
If (Date = currentdate) then begin // only print currentdate
Print(Bartime_value, " Close:", Close, " Barstatus:", Barstatus);
end;
  • 04-11-15 18:16:31.080 Close:10849.50 Barstatus: 1.00
    04-11-15 18:16:31.740 Close:10849.50 Barstatus: 1.00
    04-11-15 18:16:32.180 Close:10849.00 Barstatus: 1.00 => same timestamp
    04-11-15 18:16:32.180 Close:10849.00 Barstatus: 2.00 => barclose same timestamp

    04-11-15 18:16:32.840 Close:10849.00 Barstatus: 0.00
    04-11-15 18:16:33.740 Close:10849.00 Barstatus: 1.00
    04-11-15 18:16:34.400 Close:10849.00 Barstatus: 1.00
    04-11-15 18:16:44.300 Close:10849.50 Barstatus: 1.00
    04-11-15 18:16:45.400 Close:10849.50 Barstatus: 1.00
    04-11-15 18:16:46.100 Close:10849.50 Barstatus: 1.00
    04-11-15 18:16:48.860 Close:10849.50 Barstatus: 1.00
    04-11-15 18:17:05.500 Close:10849.50 Barstatus: 1.00
    04-11-15 18:17:11.290 Close:10849.50 Barstatus: 1.00
    04-11-15 18:17:14.960 Close:10849.00 Barstatus: 1.00
    04-11-15 18:17:15.620 Close:10849.00 Barstatus: 1.00
    04-11-15 18:17:16.020 Close:10849.00 Barstatus: 1.00
    04-11-15 18:17:16.920 Close:10849.00 Barstatus: 1.00
    04-11-15 18:17:18.970 Close:10848.50 Barstatus: 1.00
    04-11-15 18:17:19.850 Close:10848.00 Barstatus: 1.00
    04-11-15 18:17:20.530 Close:10848.00 Barstatus: 1.00
    04-11-15 18:17:22.790 Close:10848.00 Barstatus: 1.00
    04-11-15 18:17:23.670 Close:10848.00 Barstatus: 1.00
    04-11-15 18:17:23.890 Close:10848.50 Barstatus: 1.00
    04-11-15 18:17:26.550 Close:10848.50 Barstatus: 1.00
    04-11-15 18:17:27.450 Close:10848.50 Barstatus: 1.00
    04-11-15 18:17:28.240 Close:10848.50 Barstatus: 1.00
    04-11-15 18:17:29.800 Close:10847.00 Barstatus: 1.00
    04-11-15 18:17:30.690 Close:10847.00 Barstatus: 1.00
    04-11-15 18:17:31.810 Close:10847.50 Barstatus: 1.00
    04-11-15 18:17:32.240 Close:10847.00 Barstatus: 1.00
    04-11-15 18:17:34.500 Close:10847.00 Barstatus: 1.00
    04-11-15 18:17:34.940 Close:10846.50 Barstatus: 1.00
    04-11-15 18:17:35.160 Close:10846.50 Barstatus: 1.00
    04-11-15 18:17:35.380 Close:10846.00 Barstatus: 1.00 => same timestamp
    04-11-15 18:17:35.380 Close:10846.00 Barstatus: 2.00 => barclose same timestamp

    04-11-15 18:17:35.600 Close:10847.00 Barstatus: 0.00
    04-11-15 18:17:35.820 Close:10847.50 Barstatus: 1.00
In realtime, there is no same timestamp at barclose, which will cause a difference in (indicator) values (not in this simple example). And this results in difference between realtime and backtest.

Why or what can cause the timestamp to double at every barclose? Could it be Barmagnifier?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Barclose with Datetime bar update using Barmagnifier

Postby Henry MultiСharts » 18 Nov 2015

Hello Evdl,

Correct, this is how the calculation is done with the IOG and Bar Magnifier enabled.
You can learn more here: How Signals are Calculated.

evdl
Posts: 401
Joined: 19 Jan 2011
Location: Netherlands
Has thanked: 85 times
Been thanked: 124 times

Re: Barclose with Datetime bar update using Barmagnifier

Postby evdl » 19 Nov 2015

Hi Henry,

This is the situation we are talking about:
- Calculation on historical data. IOG enabled. Bar Magnifier enabled.
The script is calculated on the Open value of the main data series, then on the OHLC of each bar of the detailed data series selected in the Bar Magnifier, then on the Close of the main data series. An order can be generated on any of these calculations. It can be filled within this bar on the first price that meets the order execution logic. Only exact prices of the main bar and Bar Magnifier bars are used for filling the order.
What is the reason behind duplicating closes if main data series coincides with the BM data series. Why not use one close (it is the same) or only use the BM dataseries for calculating intrabar. Because that is what you expect and want, when you use BM to simulate lower timeframes. Especially because this will generate a difference between realtime and backtest.

The problem is, this is not that obvious, because it will not cause difference at every bar, or with every indicator. But once in a while it will put off calculations. So it is hard to spot and handle, this behaviour. Also working with textfiles and syncronise the bars is difficult this way.

Is there a particular reason for doubling the closes when using BM? And is there a way to handle the double closes, which will work in backtest and realtime?

User avatar
Henry MultiСharts
Posts: 9165
Joined: 25 Aug 2011
Has thanked: 1264 times
Been thanked: 2957 times

Re: Barclose with Datetime bar update using Barmagnifier  [SOLVED]

Postby Henry MultiСharts » 15 Dec 2015

Hello Evdl,

The calculation has been designed this way in order to ensure This Bar on Close and price order execution. In backtesting you can filter out the output generated on Barstatus: 2.00.


Return to “MultiCharts”