CommentaryWindow

Modified on 2013/05/11 09:59 by Eugene — Categorized as: Community Components

Syntax


public static void AddCommentary( this WealthScript obj, string line )
public static void Display( this WealthScript obj )

public void AddLine( string line ) public void Display()

Parameter Description

lineAny string of text, including HTML formatting

Description

Wealth-Lab 6 does not have the Commentary Viewer as its previous versions used to have. But with the power of .NET, it is pretty easy to bring it back. You can use any valid HTML tags in your commentary. For example, to force a line break end your string with the tag '<br>'.

Credit for this idea goes to Dave Aronow.


Example

Example using C# extension methods:


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() { for(int bar = Bars.Count-20; bar < Bars.Count; bar++) { // Add a line this.AddCommentary( "Bar Number: " + bar.ToString() ); } // Display Commentary Window this.DisplayCommentary(); } } }
Legacy syntax example:

Add the reusable code of the Commentary class to your Strategy (don't forget to include using System.IO line in the code) and call the methods like the example shows. .AddLine adds a string to the output, and .Display invokes the resulting Commentary in an Internet browser window.


using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;
using Community.Components; // CommentaryWindow here
/*** Requires installation of Community.Components Extension from www.wealth-lab.com > Extensions ***/

namespace WealthLab.Strategies { public class MyStrategy : WealthScript { protected override void Execute() { // Path to the resulting HTML file string path = @"C:\Commentary.html"; // Create an instance of the CommentaryWindow class CommentaryWindow cw = new CommentaryWindow( path );

for(int bar = Bars.Count-20; bar < Bars.Count; bar++) { // Add a line cw.AddLine( "Bar Number: " + bar.ToString() ); } // Display Commentary Window cw.Display(); } } }