Indicators | How to Plot a Discontinuous Indicator

Modified on 2008/06/14 10:37 by Eugene — Categorized as: Knowledge Base

A DataSeries is the basic data structure that represents a historical series. One of their key characteristics is that all DataSeries contain the same number of values as bars in the chart (when synchronized).

However, sometimes there can be a need to plot discontinuous indicators where certain timestamps do not have a value associated with the Y coordinate.

With Wealth-Lab .NET you can do it, here's a code snippet.

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() { // Color Bars of the indicator based on oversold/overbought levels DataSeries rsi = RSI.Series( Close, 14 ); ChartPane rsiPane = CreatePane( 60, true, true ); PlotSeries( rsiPane, rsi, Color.Gray, WealthLab.LineStyle.Solid, 2 ); for(int bar = 50; bar < Bars.Count; bar++) { if ( rsibar > 70 ) SetSeriesBarColor( bar, rsi, Color.Red ); else if ( rsibar < 30 ) SetSeriesBarColor( bar, rsi, Color.Blue ); else SetSeriesBarColor( bar, rsi, Color.Transparent ); } } } }


Notice the setting of bar series color to Color.Transparent. What we did was simply hiding a null value from being plotted - leaving white space on the chart instead.