- ago
Hello all,

I am trying to set up a strategy with indicators on a daily basis. The strategy itself works in a 10 minute time frame.
The data for the 10 minute time frame comes from IB. The idea is to compress it and sync it with the 10 minute data to get daily data that I use for the indicators (are there better methods to archive the goal?).
I have added a test program to show what I am trying to do (which does not mean the strategy makes sense).

1) My first problem is that I don't get the first 10 minutes bar at 0940 as expected, but only at 0950 when I check the "Filter Pre-/Post Market data" box.
2) To get around the problem I did not set the check mark and now I get all data also outside the main times. But now I have all data in the calculation of the daily data and can not tell the compress / synchronizer to use only the main trading hours.
3) When analyzing the data, it looks to me as if the compressor would integrate the last bar of the day at 2000 (upper chart) into the next day (lower chart) when using all 10 minute bars. The SMA between the main trading hours looks strange to me. I would expect, that the daily SMA is constant over the hole day. In my drawings the SMA is not stable before 1030, I would expect at least 0930 or on the first 10 minute bar of the day.





Any suggestions are welcome.

Regards,
Volker


0
1,129
Solved
9 Replies

Reply

Bookmark

Sort
Glitch8
 ( 12.74% )
- ago
#1
Hi Volker, let's sort through the first part of your question. Here's my chart of SPY for today powered by IB 10 minute data. The first bar is stamped 9:40 as expected. Can you post your similar screen shot so we might compare?

0
- ago
#2
Hi,

it looks very similar on my side.


0
Glitch8
 ( 12.74% )
- ago
#3
Ok, so the first bar begins at 9:40 as expected, agreed? When the issue you reported occurs again can you capture and post it here so we can take a look?
0
- ago
#4
I might have understood the problem. The order completion following that bar ist on the 0950 bar.

Do you have a suggestion on the topic with the sychronisation of the 10 minute / day data for the SMA (described earlier and also shown in the following picture)


0
Glitch8
 ( 12.74% )
- ago
#5
Yes, here is how you'd calculate and plot, for example, a 10-day SMA in a 10-minute strategy.

CODE:
//Initialize public override void Initialize(BarHistory bars) {          //convert to daily data          BarHistory daily = BarHistoryCompressor.ToDaily(bars);          //get 10-day MA          SMA sma10 = SMA.Series(daily.Close, 10);          //expand it back to the chart scale (10 minute)          TimeSeries expanded = TimeSeriesSynchronizer.Synchronize(sma10, bars);          //plot it          PlotTimeSeries(expanded, "10-day MA", "Price"); }


1
Best Answer
- ago
#6
Thank you, it works much better!
One remark I have. For me it looks, that the 1600 bar in the 10 minute time frame is in the wrong day frame. You can see ist also in your screen above.
0
Glitch8
 ( 12.74% )
- ago
#7
No, the daily data aligns with the final bar of the intraday scale because that’s when it would become available. It’s working as designed.
0
- ago
#8
Hi,
I struggle with a different kind of indicator. Suggestions what I'm doing wrong?`
The picture should show from my point of view a straight line for every new day, using 10 minute intraday data from IB.

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; using System.Collections.Generic; namespace WealthScript3 { public class MyStrategy : UserStrategyBase { public override void Initialize(BarHistory bars) {          dayBar = BarHistoryCompressor.ToDaily(bars);          synchDay = BarHistorySynchronizer.Synchronize(dayBar, bars);          dayPb = new ProjectionBandUpper(synchDay, 14);          PlotIndicator(dayPb, WLColor.FromArgb(255, 0, 0, 0));          // 14 days == 6.5 trading hours * 6 (10 Minute-Slots) per hour          StartIndex = (int) (14 * 6.5 * 6); } public override void Execute(BarHistory bars, int idx) {          WriteToDebugLog(bars.DateTimes[idx], true); }       private IndicatorBase pb;       private BarHistory synchDay;       private BarHistory dayBar;       private IndicatorBase dayPb; } }



0
Cone8
 ( 6.36% )
- ago
#9
The order is to compress, create the indicator in the compressed scale, then synchronize to a TimeSeries (or BarHistory) type, as required.

CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Indicators; using System.Drawing; using System.Collections.Generic; namespace WealthScript3 {    public class MyStrategy : UserStrategyBase    {       public override void Initialize(BarHistory bars)       {          dayBar = BarHistoryCompressor.ToDaily(bars);          dayPb = new ProjectionBandUpper(dayBar, 14);          dayPbSync = TimeSeriesSynchronizer.Synchronize(dayPb, bars);          PlotTimeSeriesLine(dayPbSync, "PBU", "Price", WLColor.FromArgb(255, 0, 0, 0));          // 14 days == 6.5 trading hours * 6 (10 Minute-Slots) per hour          StartIndex = (int)(14 * 6.5 * 6);       }       public override void Execute(BarHistory bars, int idx)       {          WriteToDebugLog(bars.DateTimes[idx], true);       }       private IndicatorBase pb;       private BarHistory dayBar;       private IndicatorBase dayPb;       private TimeSeries dayPbSync;    } }


0

Reply

Bookmark

Sort