Log in to see Cloud of Tags

Wealth-Lab Wiki

Indicators | How to Plot a Discontinuous Indicator

RSS
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 ( rsi[bar] > 70 ) SetSeriesBarColor( bar, rsi, Color.Red ); else if ( rsi[bar] < 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.

Important Disclaimer: The information provided by Wealth-Lab is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.  The owner of Wealth-Lab.com assumes no liability resulting from the use of the material contained herein for investment purposes. By using this web site, you agree to the terms of this disclaimer and our Terms of Use.


ScrewTurn Wiki. Some of the icons created by FamFamFam.