Problem
Wealth-Lab 5 does not include functions like
GetIntradayBar or
GetWeeklyBar, previously used to access compressed Data Series in a higher time frame. The purpose of these functions was to take a Bar number and convert it to the corresponding bar in the compressed Data Series interval. For example, it allowed to get the correct bar of data in a 15 minute compressed Data Series from a 1 minute chart.
Referencing the synchronized series on a bar-by-bar basis in Version 5 could simply be done using
RestoreScale and
Synchronize - the WL6 equivalents to RestorePrimarySeries and IntradayFromCompressed. Nonetheless, if you need those functions for compatibility when porting a ChartScript from Wealth-Lab 4, you'll find the code snippets below helpful:
Code Example 1: GetIntradayBar
Font font = new Font("Arial", 7, FontStyle.Regular);
SetScaleCompressed(15);
DataSeries CompBar = new DataSeries(Bars, "Compressed Bar Numbers"); // initialize a DataSeries
for (int bar = 0; bar < Bars.Count; bar++) // load the bar numbers
CompBarbar = bar;
DataSeries CompressedClose = Close; // Compressed series for test
RestoreScale();
// Synch the bar numbers with the base time frame (here's your "function")
DataSeries GetIntradayBar = Synchronize(CompBar);
for(int bar = 0; bar < Bars.Count; bar++)
{
int b = (int)GetIntradayBarbar;
AnnotateBar(b.ToString("0"), bar, true, Color.Black, Color.Transparent, font);
AnnotateBar(CompressedCloseb.ToString("0.00"), bar, false, Color.Black, Color.Transparent, font);
}
Code Example 2: GetWeeklyBar
// Workaround for GetWeeklyBar
SetScaleWeekly();
DataSeries CompBar = new DataSeries(Bars, "Compressed Bar Numbers"); // initialize a DataSeries
for (int bar = 0; bar < Bars.Count; bar++)
CompBarbar = bar;
// Weekly EMA
DataSeries wk_ema = EMA.Series( Bars.Close, 10, EMACalculation.Modern );
RestoreScale();
DataSeries wk_ema_synchedToIntraday = Synchronize( wk_ema );
DataSeries GetWeeklyBar = Synchronize(CompBar);
PlotSeries( PricePane, wk_ema_synchedToIntraday, Color.Blue, LineStyle.Solid, 1 );
SetBarColors( Color.Silver, Color.Silver );
HideVolume();
Font font = new Font("Courier", 7, FontStyle.Regular);
for(int bar = 30; bar < Bars.Count; bar++)
{
int gwb = (int)GetWeeklyBarbar;
AnnotateBar(gwb.ToString(), bar, false, Color.Black,Color.Transparent, font);
if( wk_emagwb > wk_emagwb-1 )
SetBarColor( bar, Color.Blue );
}