Wealth-Lab Wiki

API ChartStyles Community Components Community Indicators IndexDefinitions Knowledge Base Misc Optimizers Pending Deletion PosSizers Providers Standard Indicators TASC Traders Tips TASCIndicators Tutorial Videos Visualizers


Quick Search
Advanced Search »

Gain and Drawdown



public class GainAndDrawdown(WealthScript ws, Bars bars, DateTime start, DateTime end, string dividenditemstring)

Parameter Description

wsA WealthScript instance (pass this)
barsBars from a secondary series must be synchronized
startStarting date
endEnding date
dividenditemstringPer share dividend fundamental item used to calculate total return


This class helps chart the total return (% gain/loss plus dividends, % peak gain, % gain after DD Low) and % drawdown (max DD%) of multiple symbols over some duration.



Code below illustrates the class usage. The script demonstrates comparing the clicked symbol with the "SPY" benchmark:

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using Community.Components;

namespace WealthLab.Strategies { public class PerformanceDataDemo : WealthScript { protected override void Execute() { /* Edit string according to your dividend source */ string dividenditemstring = "Dividend (Yahoo! Finance)"; GainAndDrawdown pd = new GainAndDrawdown(this, Bars, Date[0], Date[Bars.Count - 1], dividenditemstring); pd.DisplayData(PricePane); ChartPane ddPane = CreatePane(40, true, true); ChartPane gainPane = CreatePane(60, true, true); PlotSeries(gainPane, pd.GainSeries, Color.Green, LineStyle.Histogram, 1); PlotSeries(gainPane, pd.TotalReturnSeries, Color.Blue, LineStyle.Solid, 2); PlotSeries(ddPane, pd.DrawdownSeries, Color.Red, LineStyle.Histogram, 1); // Compare to a benchmark. Make sure to use sync'd Bars Bars bmbars = GetExternalSymbol("SPY", true); GainAndDrawdown bm = new GainAndDrawdown(this, bmbars, Date[0], Date[bmbars.Count - 1], dividenditemstring); PlotSeries(gainPane, bm.TotalReturnSeries, Color.Black, LineStyle.Solid, 2); PlotSeries(ddPane, bm.DrawdownSeries, Color.Black, LineStyle.Solid, 2); } } }

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.

Used under license from FMR Corp. Copyright 2008 FMR Corp. All rights reserved.

ScrewTurn Wiki. Some of the icons created by FamFamFam.