ww58
- ago
I used ScaleInd and faced a situation when weekly bar collected from 30m bars does not coincide with the one collected from daily bars, because of bad 30m quotes. One of the solutions I see is a feature request to add source of bars for this indicator (may be to SymbolInd too), that it would be possible to specify the daily timeframe in it. Are there any other solutions?
0
435
Solved
10 Replies

Reply

Bookmark

Sort
Cone8
 ( 4.98% )
- ago
#1
Re: "bad 30m quotes".
I guess you mean bad data for a 30 minute bar. Why was the data bad?
The solution to bad data is good data.

Also, what do you mean by "coincide"? The Intraday close of a session will OFTEN not equal the Daily close because the latter is the settled close and the former is simply the last full-lot trade for the session. They're often the same, but the values can be different, by design.
1
ww58
- ago
#2
I'll explain it better with an example. Suppose we want to get a weekly pivot for ENPH on April 2, which is (H+L+C)/3 of the previous weekly bar = 118.21 on wealth-data quotes. This is the price we also get using ScaleInd from 30m bars using Alpaca quotes, but on IB quotes the price is 117.31. This is a problem in the IB quotes, but since we have great wealth-data quotes I would like to be able to use them in such case.
0
Cone8
 ( 4.98% )
- ago
#3
IB's intraday data for ENPH on 3/28 looks bad - doesn't reflect reality, and, it doesn't even match IB's own Daily data. If you're looking for something in the Weekly scale, it would be better to use Daily anyway.

The question is what are your constraints?

If your using C# Code, you can use the WLHost.Instance.GetHistory() to get the history from a Daily source, and pass that to your ScaleInd for the Weekly bars. Actually, you can just specify the Weekly Scale in that call and it should automatically create it from Daily bars.

This should work -
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; namespace WealthScript123 { public class MyStrategy : UserStrategyBase {       private TimeSeries _pivot;        public override void Initialize(BarHistory bars) {          BarHistory wkly = WLHost.Instance.GetHistory(bars.Symbol, HistoryScale.Weekly, DateTime.MinValue, DateTime.MaxValue, 0, null);          _pivot = TimeSeriesSynchronizer.Synchronize(wkly.AveragePriceHLC, bars);          PlotTimeSeriesLine(_pivot, "Pivot", "Price");           } public override void Execute(BarHistory bars, int idx) {       } } }
1
Best Answer
ww58
- ago
#4
For strategies, it works. For custom indicators WLHost.Instance.GetHistory works only on the chart, when adding indicator with this code inside to the block an exception occurs. Any workaround?
0
Cone8
 ( 4.98% )
- ago
#5
It's probably a bug in your indicator code. You need to properly sync the indicator series.
0
ww58
- ago
#6
This code
CODE:
public override void Populate() {          BarHistory source = Parameters[0].AsBarHistory;          DateTimes = source.Close.DateTimes;          BarHistory wkly = WLHost.Instance.GetHistory(source.Symbol, HistoryScale.Weekly, DateTime.MinValue, DateTime.MaxValue, 0, null);          BarHistory wklySync = BarHistorySynchronizer.Synchronize(wkly, source);          TimeSeries _pivot = TimeSeriesSynchronizer.Synchronize(wkly.AveragePriceHLC, source);                    for (int n = 0; n < source.Close.Count; n++)          { Values[n] = source.Close[n];          } }
0
Cone8
 ( 4.98% )
- ago
#7
Assuming you really wanted to use _pivot as the indicator, it works fine for me.

0
ww58
- ago
#8
QUOTE:
Assuming you really wanted to use _pivot as the indicator, it works fine for me.
For chart it works for me too. Does it work when you add this indicator to "Indicator compare to value" block?
0
Glitch8
 ( 10.62% )
- ago
#9
Open the BB Strategy as a C# coded and let's see what line is causing the error.
0
Cone8
 ( 4.98% )
- ago
#10
Yes, I get the error there. We'll look into it.
0

Reply

Bookmark

Sort