ww58
- ago
In case of Futures Electronic Trading Hours BarHistoryCompressor method compresses bars correctly, however when displayed the lines are refreshed at midnight, which is wrong, since they have to refresh at IsFirstBarOfDay.

Also, the documentation says that IsFirst/Last BarOfDay and related methods should only be used for regular trading session, as far as I see it works for extended. Should I use them or something else, if so, how?

CODE:
namespace WealthScript2 {    public class BarHistoryToDailyScaleExample : UserStrategyBase    {       TimeSeries _dailyLows, _dailyHighs;       public override void Initialize(BarHistory bars)       {          BarHistory dayBar = BarHistoryCompressor.ToDaily(bars);          _dailyHighs = TimeSeriesSynchronizer.Synchronize(dayBar.High, bars.Close);          PlotTimeSeries(_dailyHighs, "Daily High", "Price", WLColor.Red, PlotStyle.Dots);          _dailyLows = TimeSeriesSynchronizer.Synchronize(dayBar.Low, bars.Close);          PlotTimeSeries(_dailyLows, "Daily Low", "Price", WLColor.Green, PlotStyle.Dots);       }       public override void Execute(BarHistory bars, int idx)       {          if (bars.IsFirstBarOfDay(idx))             SetBackgroundColor(bars, idx, WLColor.Green);          if (bars.IsLastBarOfDay(idx))             SetBackgroundColor(bars, idx, WLColor.Red);       }    } }
0
189
Solved
2 Replies

Reply

Bookmark

Sort
ww58
- ago
#1
Further research led to the fact that this only applies to TimeSeriesSynchronizer.Synchronize, which I took from the example, but not to BarHistorySynchronizer.Synchronize

So this code shows divergence
CODE:
      public override void Initialize(BarHistory bars)       {          BarHistory dayBar = BarHistoryCompressor.ToDaily(bars);          BarHistory dayBarSynched = BarHistorySynchronizer.Synchronize(dayBar, bars);          _dailyHighs = TimeSeriesSynchronizer.Synchronize(dayBar.High, bars.Close);          PlotTimeSeries(_dailyHighs, "Daily High", "Price", WLColor.Red, PlotStyle.Dots);          _dailyLows = TimeSeriesSynchronizer.Synchronize(dayBar.Low, bars.Close);          PlotTimeSeries(_dailyLows, "Daily Low", "Price", WLColor.Green, PlotStyle.Dots);          PlotTimeSeries(dayBarSynched.High, "Daily High", "Price", WLColor.Magenta, PlotStyle.Dots);          PlotTimeSeries(dayBarSynched.Low, "Daily Low", "Price", WLColor.Violet, PlotStyle.Dots);       }



0
Cone8
 ( 3.17% )
- ago
#2
Add the MarketDetails parameter to TimeSeriesSynchronizer() instead of leaving it as null. Example -
CODE:
_dailyHighs = TimeSeriesSynchronizer.Synchronize(dayBar.High, bars.Close, null, bars.Market);

Or, with Build 111, use a BarHistory as the TimeSeries master parameter for synchronizing. Example -
CODE:
_dailyHighs = TimeSeriesSynchronizer.Synchronize(dayBar.High, bars);
The trick is to let WealthLab know which market you're synchronizing to (that's why it works for BarHistorySynchronizer).
1
Best Answer

Reply

Bookmark

Sort