How exactly is BarMaxSpreadInt calculated? I get different values when computing bars from ticks.

General discussion about the Tickstory Lite software package.
Post Reply
Floris
Posts: 3
Joined: Sun Dec 25, 2022 9:22 pm

How exactly is BarMaxSpreadInt calculated? I get different values when computing bars from ticks.

Post by Floris »

Hi everyone,

I noticed a difference in the value of BarMaxSpreadInt between how Tickstory calculates it, and how I thought it should be calculated:
I first exported all EURUSD ticks for a whole day (in this case Dec 19th, 2022) in MT5 format from Tickstory, then I exported 1 second bars from Tickstory for the same duration, then I looked at the resulting bars to try to understand how BarMaxSpreadInt is calculated.

The manual says here (https://tickstory.com/help/tickstorylit ... le_exports):
{BarMaxSpreadInt}: - The maximum spread that occurred within a bar, expressed as an integer. For a 4-digit symbol, this will appear as “2” for a 2.1 pip spread and for a 5-digit symbol, it would appear as “21”.

So with that definition, I assumed:
  • If a bar only contains 1 tick, the BarMaxSpreadInt of that bar should be the int spread of that tick, right? But that's not how Tickstory calculates it: All bars that contain only 1 tick have a BarMaxSpreadInt of 0 in Tickstory's output! See the blue rectangle here (https://i.imgur.com/g55pZwr.png)
    CSV Extract
    CSV Extract
    which is the only tick that happened during second 04 and the corresponding 1 second bar in Tickstory's output here on the left (https://i.imgur.com/cSSxbCF.png)
    Comparison
    Comparison
    which has a BarMaxSpreadInt 0. (You can verify this yourself, check any bar that contains only 1 tick, they all have BarMaxSpreadInt = 0.) Btw, that screenshot is from WinMerge, as you can see, all bar values between Tickstory's output and my own calculation are the same except BarMaxSpreadInt (the values I calculated from Tickstory's ticks are shown in the right column).
  • If a bar contains multiple ticks, then (in pseudo code)

    Code: Select all

    BarMaxSpreadInt = max(tick.ask - tick.bid) for tick in ticks
    That's apparently also not how Tickstory calculates it. Compare the red rectangle in the above two screenshots: The first image shows that there are 2 ticks within second 02, so the corresponding 1 second bar is made from 2 ticks. The int spread of the first tick is 105850-105844=6, and for the second tick it's 105850-105845=5. The max of 6 and 5 is 6. So I would think that the BarMaxSpreadInt of this bar should be 6, but Tickstory's 1 second bar output contains 5 as the value for BarMaxSpreadInt for this bar (see red rectangle in the other screenshot)!
(These are just two examples, you can see from the lines that WinMerge highlighted, that many bars have different BarMaxSpreadInt values between what Tickstory bar output says vs what I calculated from TIckstory's ticks.)

So, can you please explain to me what I'm getting wrong here? How is BarMaxSpreadInt calculated exactly? :)
I want to understand it, so that I interpret it correctly during backtesting.

(Btw, I also get these discrepancies for exports of any other symbol, any other day and any other bar size (e.g. M1). I just give this example so that you can follow my steps of how I arrived at these values / questions.)

tickstory
Posts: 4883
Joined: Sun Jan 06, 2013 12:27 am

Re: How exactly is BarMaxSpreadInt calculated? I get different values when computing bars from ticks.

Post by tickstory »

Hi Floris,

Thanks for taking the time to write up a concise summary of your question. It does indeed look like there is an issue with the 1-second bar spreads.
In particular, we agree that MaxBarSpread should be non-zero when there is a single tick in that second and also that the spreads should match what you have in your second screenshot.

We are just preparing a fix now and will give you a heads up once we have performed some testing on it before making it available to you.

Thanks.

tickstory
Posts: 4883
Joined: Sun Jan 06, 2013 12:27 am

Re: How exactly is BarMaxSpreadInt calculated? I get different values when computing bars from ticks.

Post by tickstory »

Hi Floris,

v1.9.7.6 has just been released and should correct the BarMaxSpread calculation. The results should match what you also have in your screenshots.

Please let us know if there are any issues.

Thanks.

Post Reply