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?
Rename
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.
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.
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.
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 -
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) { } } }
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?
It's probably a bug in your indicator code. You need to properly sync the indicator series.
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]; } }
Assuming you really wanted to use _pivot as the indicator, it works fine for me.
QUOTE:For chart it works for me too. Does it work when you add this indicator to "Indicator compare to value" block?
Assuming you really wanted to use _pivot as the indicator, it works fine for me.
Open the BB Strategy as a C# coded and let's see what line is causing the error.
Yes, I get the error there. We'll look into it.
Your Response
Post
Edit Post
Login is required