using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators;namespace WealthLab.Strategies { public class MyStrategy : WealthScript { // Plots the percent change of the charted symbol and the benchmark symbols in a new pane public void PlotBenchMarkPct(string">"> bmSymbols, Color[ colors, DateTime fromDate) { int bar = Bars.ConvertDateToBar(fromDate, false); SetBackgroundColor(bar, Color.Pink); ChartPane cp = CreatePane(60, true, true); DrawLabel(cp, "Percent Change since " + fromDate.ToShortDateString(), Color.Navy); int c = 0; foreach (string sym in bmSymbols) { Bars bmBars = GetExternalSymbol(sym, true); double refPrice = bmBars.Closebar; DataSeries dsPctChange = 100 * (bmBars.Close/refPrice - 1); dsPctChange.Description = sym; PlotSeries(cp, dsPctChange, colorsc, WealthLab.LineStyle.Solid, 2); c++; } } protected override void Execute() { // Show the percent change from a list of symbols from a specified date (1/1/2006) string[] benchMarkSymbols = {Bars.Symbol, "MSFT", ".DJI", ".SPX"}; Color[] colors = {Color.Black, Color.Blue, Color.Red, Color.Green}; PlotBenchMarkPct(benchMarkSymbols, colors, new DateTime(2006, 1, 1)); } } }
using System; using System.Collections.Generic; using System.Text; using System.Drawing; using WealthLab; using WealthLab.Indicators;namespace WealthLab.Strategies { public class MyStrategy : WealthScript { Random r = new Random(); private Color RandomColor() { Color randomColor = Color.FromArgb(r.Next(255), r.Next(255), r.Next(255)); return randomColor; } protected override void Execute() { string clickedSym = Bars.Symbol; List rocList = new List(); int StartBar = Math.Max( Bars.Count - 260, 0 ); foreach( string ds in DataSetSymbols ) { DataSeries extClose = GetExternalSymbol( DataSetSymbolsDataSetSymbols.IndexOf(ds), true ).Close; rocList.Add( ( extClose - (extClose>>StartBar) ) / (extClose>>StartBar) * 100.0 ); } HideVolume(); ChartPane rocPane = CreatePane( 100, true, true ); foreach( DataSeries ds in rocList ) PlotSeries( rocPane, rocListrocList.IndexOf(ds), RandomColor(), LineStyle.Solid, 1 ); } } }
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.