Intraday / Multi-Time Frame | Compressed price series alignment

Modified on 2015/06/03 14:55 by Eugene — Categorized as: Knowledge Base

To align data from higher time frames within a chart, previous versions of Wealth-Lab had a special "Synchronization" dialog with these three options:

  1. Compressed Bar Available on Last Bar of Period (default behavior)
  2. Compressed Bar Available on the First Bar of Period
  3. PREVIOUS Compressed Bar Available on the First Bar of Period


As the familiar Synchronization dialog was left out of Wealth-Lab 6 for the purpose of simplification, here's an example by the Wealth-Lab author, Dion Kurczek, that demonstrates how synchronization can be performed in the Strategy. Paste this code in a new Strategy window and run it on a minute-based chart to see all the three synchronization options:


using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
 
namespace WealthLab.Strategies
{
	public class MyStrategy : WealthScript
	{
		protected override void Execute()
		{
			if( Bars.Scale == BarScale.Minute )
			{
				SetScaleDaily();
				DataSeries option2 = Bars.High; 	option2.Description = "High (option2)";
				DataSeries option3 = option2 >> 1;	option3.Description = "High (option3)";
				RestoreScale();
				option2 = Synchronize( option2 );
				option3 = Synchronize( option3 );
				DataSeries option1 = option3 << 1;	option1.Description = "High (option1)";
				option1[Bars.Count-1] = option2[Bars.Count-1];
				PlotSeries( PricePane, option2, Color.Blue, LineStyle.Solid, 4 );
				PlotSeries( PricePane, option3, Color.Red, LineStyle.Solid, 2 );
				PlotSeries( PricePane, option1, Color.Black, LineStyle.Solid, 1 );
			} else
			{
				DrawLabel( PricePane, "Switch to minutes" );
			}
		}
	}
}