Issue with Multiple Time Frame Data Alignment

Novatago

New member
Joined
Feb 28, 2023
Posts
3
Likes
1
I'm a developer experimenting with the motivewave sdk. In particular, I'm trying to build Studies that have access to multiple timeframes (BarSize)s at the same time.

I've noticed an issue with the way that MotiveWave handles data alignment when there are multiple timeframes shown on the same chart.

As a simple example, I've created a 1min OHLC chart of QQQ, and then added an SMA(C,1) with its Options/BarSize set to 1 Hour. I know this is a contrived example because 1 period SMA isn't useful, but it's helpful to illustrate the issue.

Using this setup, the SMA takes 60 minutes (or 60 bars of 1min spacing on the chart) in order to calculate its value. So to be clear, the value of the SMA at 8:00am on the 1 min bar chart will be based on data only available at 8:00am and not a minute before.

If I open the CursorData window and scrub through the 1min chart between 7:00am and 8:00am, I can see the SMA(C,1) value is the one that is calculated at 8:00am. This means that MotiveWave is making the 8:00am data available in the chart available in the hour prior! Unless I'm misunderstanding something fundamentally about how MotiveWave deals with aligning multiple time frames, this is a major future leak issue - looking at charts, one could be fooled into thinking that the indicator values have more predictive power than they actually do because the data is leaking from the 'future'.

In addition to the future leak that is evident in the Cursor Data box, the actual SMA(C,1) plot overlay on the 1 min chart is leaking future data too, but in a different way - visually, the SMA is plotted as a straight line between each 60 minute period. So, for example, if you look half way between any 60 minute period, the SMA is already trending towards a 'future' value which should not be known at that point. The plot of a larger time frame indicator on a smaller time frame chart rather should look like a stair step, where the indicator holds it's value flat until it calculates a new one. So, in the case of the SMA(C,1) using 60 minutes, it should have the same value for 60 1 minute bars, until it has calculated a new value, in which case it should jump (or stair-step) up/down to the new value.

Because of this time alignment issue, I'm unable to use MotiveWave at all for any studies or strategies that rely on simultaneous multiple timeframes on a single chart.

Hopefully, I've just misunderstood MotiveWave's approach, but if not, I hope a fix can be provided soon.

Screenshot 2023-03-01 at 8.06.49 AM.png
 

Attachments

  • Screenshot 2023-03-01 at 8.08.31 AM.png
    Screenshot 2023-03-01 at 8.08.31 AM.png
    714.7 KB · Views: 13

Novatago

New member
Joined
Feb 28, 2023
Posts
3
Likes
1
After some experimentation, I've figured out how to manually align multiple time frame data inside of a single study.

The issue at hand, is that MotiveWave DataSeries timestamps represent the start of the bar instead of the end. (an end of bar timestamp is available in code). When aligning data from multiple time frames, for instance 15m and 60m, alignment on the chart happens at the start of the bar instead of the end.

So, for instance, assume a 15m bar marked at 9:00am, and a 60m bar marked at 9:00am. In real-time, the 15m bar won't be complete until 9:15am while the 60m bar won't be complete until 10am.

To align these two time frames, it's necessary to align by the end of bar timestamps, so as an example, the 15m 9:45am bar would complete at the same time as a 60m 9:00am bar.

Other platforms, NinjaTrader or QuantConnect for example set their primary timestamp to the 'end' of the bar instead of the start, so aligning mutiple time frames is easy - just match the timestamps.

In any case, it's not that big of an issue - it just takes some additional thinking in study code to ensure real-time alignment.
 

spider64

Member
Joined
Nov 5, 2022
Posts
15
Likes
3
After some experimentation, I've figured out how to manually align multiple time frame data inside of a single study.

The issue at hand, is that MotiveWave DataSeries timestamps represent the start of the bar instead of the end. (an end of bar timestamp is available in code). When aligning data from multiple time frames, for instance 15m and 60m, alignment on the chart happens at the start of the bar instead of the end.

So, for instance, assume a 15m bar marked at 9:00am, and a 60m bar marked at 9:00am. In real-time, the 15m bar won't be complete until 9:15am while the 60m bar won't be complete until 10am.

To align these two time frames, it's necessary to align by the end of bar timestamps, so as an example, the 15m 9:45am bar would complete at the same time as a 60m 9:00am bar.

Other platforms, NinjaTrader or QuantConnect for example set their primary timestamp to the 'end' of the bar instead of the start, so aligning mutiple time frames is easy - just match the timestamps.

In any case, it's not that big of an issue - it just takes some additional thinking in study code to ensure real-time alignment.
I have a process that uses 3 different time frame EMAs both for signals and trade size. I use 5m, 15m, and 60m time frames so it is possible to watch it manually, but not reliable. Appreciate you explaining the issue and possible fix. Now I'll see if I can figure out how to make the adjustment.
 

spider64

Member
Joined
Nov 5, 2022
Posts
15
Likes
3
I built a 5m MES chart with a 5m, 15m, and 60m 3 period EMA. I checked the values at the same time with the 5m, then 15m and then 60m bar setting. The "natural" time frame value for the 15m and 60m EMAs matched the ones on the 5m chart and using the other bar set at 15m and 60m. My process only uses bar close values so although the graph should be a stairstep, I think the close values are correct. I did back testing using intrabar values when I was first developing this process and found that created too much whipsaw. It may have been I was using inaccurate data the way you are seeing it and didn't even know it.

I see and agree with the issue you presented if you are using intrabar values where MW is displaying a MA before it should.

I'm not a developer and have been using Strategy Builder from Trading Indicators to create my own strategies. I think I'm OK without changing the timestamp but will be checking carefully. This has been a long term project to try and automate some of my trading so still a WIP.
 
Top