Cosmetic Chart

The Cosmetic Chart category consists of methods you can use to plot shapes, images and various other annotations on the chart.  It also contains methods to control the colors of the bars and chart background.

BuyAtMarket

AnnotateBar

void AnnotateBar(string text, int bar, bool aboveBar, Color color, Color backgroundColor, Font font);
void AnnotateBar(string text, int bar, bool aboveBar, Color color, Color backgroundColor);
void AnnotateBar(string text, int bar, bool aboveBar, Color color);

Annotates the specified bar with the string passed in the text parameter, using the specified color for the font.  Use the aboveBar parameter to control if the text is displayed above or below the bar.  Using the version that accepts a backgroundColor parameter causes the text to be displayed over a filled background.  Calling AnnotateBar multiple times causes the annotations to be stacked one on top of another either above or below the bar.

Use the version of the method that accept a Font parameter to draw the text using a custom font.  If you use this version and do not want a colored background, specify Color.Empty for the backgroundColor parameter.


Example

protected override void Execute(){
    Font font = new Font("Arial", 12, FontStyle.Bold);
    // Demonstrates operation overload
    for(int bar = 200; bar < Bars.Count; bar++)
    {
        // Annotate a bar if it's a 200 day closing high
        if ( Bars.Close[bar] == Highest.Series( Close, 200 )[bar] )
            AnnotateBar( "High", bar, true, Color.DarkGreen );
        // Annotate a bar if it's a 200 day closing low
        if ( Bars.Close[bar] == Lowest.Series( Close, 200 )[bar] )
            AnnotateBar( "Low", bar, false, Color.DarkRed, Color.White );
        // Annotate the last bar 
        if ( bar == Bars.Count-1 )
            AnnotateBar( "Last", bar-3, false, Color.DarkRed, Color.White, font );
    }
}
BuyAtMarket

AnnotateChart

void AnnotateChart(ChartPane pane, string text, int bar, double value, Color color, Color backgroundColor, Font font, HorizontalAlignment alignment);
void AnnotateChart(ChartPane pane, string text, int bar, double value, Color color, Color backgroundColor, Font font);
void AnnotateChart(ChartPane pane, string text, int bar, double value, Color color, Color backgroundColor);
void AnnotateChart(ChartPane pane, string text, int bar, double value, Color color);

Annotates the chart with the specified text using the specified color at a location provided by the bar and value parameters.  The pane parameter determines which chart pane is annotated.  If you call the version of AnnotateChart that accepts a backgroundColor parameter, the text will be displayed over a filled background.

Use the version of the method that accept a Font parameter to draw the text using a custom font.  If you use this version and do not want a colored background, specify Color.Empty for the backgroundColor parameter.

Use the first overloaded version of the method, with the alignment parameter, to control the alignment of the text, relative to the bar.  Possible values are Left, Center or Right.

Remarks


Example

protected override void Execute(){
    // Define new font style
    Font font = new Font("Arial", 7, FontStyle.Regular);
    DataSeries smaVolume = SMA.Series( Volume, 50 );
    PlotSeries( VolumePane, smaVolume, Color.LightSalmon, WealthLab.LineStyle.Solid, 2 );
    // Demonstrates operator overload
    for(int bar = 50; bar < Bars.Count; bar++)
    {
        // Annotate the last bar if it demonstrates unusual volatility
        if ( bar == Bars.Count-1 )
        {
            if ( ATR.Series( Bars, 1 )[bar] >= 2 * ATR.Series( Bars, 14 )[bar] )
                AnnotateChart( PricePane, "Volatile!", bar-5, High[bar], Color.Green, Color.White, font, System.Windows.Forms.HorizontalAlignment.Left );
            if ( Volume[bar] >= 1.5 * smaVolume[bar] ) 
                AnnotateChart( VolumePane, "Volume is High", bar-10, Volume[bar], Color.Green, Color.White, font, System.Windows.Forms.HorizontalAlignment.Left );
        }
    }
}
BuyAtMarket

ChartStyle Property

ChartStyle ChartStyle

Returns the instance of the ChartStyle object that is currently being used to render the chart.  This is an object that derives from the base ChartStyle class, and is responsible for rendering the actual bars of the chart.  Some ChartStyle objects contain additional data structures and information that can be used in your Strategy.  Consult the specific ChartStyle documentation for any additional value that might be obtained.

Remarks


Example

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using WealthLab;
using WealthLab.Indicators;

namespace WealthLab.Strategies
{
    public class MyStrategy : WealthScript
    {
        bool IsStrategyMonitor()
        {
            return ChartStyle == null;
        }
        
        protected override void Execute()
        {
            if ( !IsStrategyMonitor() )
                System.Windows.Forms.MessageBox.Show( "Operating in Strategy window" ); else
                System.Windows.Forms.MessageBox.Show( "Running in Strategy Monitor" );
        }
    }
}
BuyAtMarket

CreatePane

ChartPane CreatePane(int height, bool abovePricePane, bool displayGrid);

Creates a new pane on the chart and returns the new pane as a ChartPane object.  The height parameter controls the height of the pane, which fluctuates as the chart is resized.  A value of 40 for height creates a pane with a standard height.  You can create panes either above or below the price pane through the abovePricePane parameter.  The displayGrid parameter controls whether the pane will display grid lines.  You can plot indicators in the pane using PlotSeries and the various other plotting methods.

Remarks

  • See the ChartPane object reference for more information about the properties and methods of ChartPanes.

Example

protected override void Execute(){
    //Create and plot Williams %R indicator
    WilliamsR wr = WilliamsR.Series( Bars, 20 );
    ChartPane wrPane = CreatePane( 40, true, true );
    PlotSeriesOscillator( wrPane, wr, 90, 10, Color.LightGreen, Color.LightCoral, Color.CadetBlue, LineStyle.Solid, 1);
}
BuyAtMarket

DrawCircle

void DrawCircle(ChartPane pane, int radius, int bar, double value, Color color, Color fillColor, LineStyle style, int width, bool behindBars);
void DrawCircle(ChartPane pane, int radius, int bar, double value, Color color, LineStyle style, int width, bool behindBars);

protected void DrawCircle(ChartPane pane, int bar1, double value1, int bar2, double value2, Color color, Color fillColor, LineStyle style, int width, bool behindBars);
protected void DrawCircle(ChartPane pane, int bar1, double value1, int bar2, double value2, Color color, LineStyle style, int width, bool behindBars);

The DrawCircle method provides two ways to draw (and optionally fill) circles on a chart, in the specified pane.  Each method accepts an optional fillColor parameter, that (if specified) causes the circle to be filled with a color.  The final parameter, behindBars, determines whether the circle will be plotted behind or in front of the bars of the chart.  The circle will be drawn using the specified color, style, and width.

The first method draws a circle with a radius specified in pixels, at the coordinates specified by the bar (X) and value (Y) parameters.

The second method draws a circle whose radius is a line specified by two points, bar1/value1 and bar2/value2.  In this way, your circles can be bound to actual bars/prices on the chart.

 

Remarks

  • Known issue: Zooming the chart may fail if DrawCircle() is applied to the chart if the price range exceeds $2,000,000.00
  • Workaround: Don't use DrawCircle() on bars where the price exceeds this figure:

for(int bar = 0; bar < Bars.Count; bar++)

{
if (Close[bar] < 2100000)
DrawCircle(PricePane, 9, bar, Close[bar]+ 0.05, Color.Empty, Color.Green, WealthLab.LineStyle.Solid, 1, true);
}

Example

protected override void Execute(){
    // Operator overload
    for(int bar = 200; bar < Bars.Count; bar++)
    {
        // Circle any 200 day High
        if ( High[bar] == Highest.Series( High, 200 )[bar] )
            DrawCircle( PricePane, 4, bar, High[bar], Color.Green, Color.DarkGreen, WealthLab.LineStyle.Solid, 1, true );
        // Circle any 200 day Low
        if ( Low[bar] == Lowest.Series( Low, 200 )[bar] )
            DrawCircle( PricePane, bar-1, Low[bar-1], bar, Low[bar-1], Color.Red, Color.DarkRed, WealthLab.LineStyle.Solid, 1, false );
    }
}
BuyAtMarket

DrawEllipse

void DrawEllipse(ChartPane pane, int bar1, double value1, int bar2, double value2, Color color, Color fillColor, LineStyle style, int width, bool behindBars);
void DrawEllipse(ChartPane pane, int bar1, double value1, int bar2, double value2, Color color, LineStyle style, int width, bool behindBars);

Plots an ellipse on the pane using the specified color, style and width.  If the version using fillColor is called, also fills the ellipse using the specified fillColor.  The ellipse is bound by a rectangle defined by the points bar1, value1 and bar2, value2.  The behindBars parameter controls whether the ellipse is plotted behind, or in front of the bars of the chart.


Example

protected override void Execute(){
    int Bar = (int)TroughBar.Value( Bars.Count-1, Low, 5, WealthLab.Indicators.PeakTroughMode.Percent );
    double Price = Low[Bar];
    DrawEllipse( PricePane, Bar-4, Price*1.02, Bar+4, Price*0.98, Color.Red, Color.LightCoral, WealthLab.LineStyle.Solid, 1, false );
    Bar = (int)PeakBar.Value( Bars.Count-1, High, 5, WealthLab.Indicators.PeakTroughMode.Percent );
    Price = High[Bar];
    DrawEllipse( PricePane, Bar-4, Price*1.02, Bar+4, Price*0.98, Color.Green, Color.LightGreen, WealthLab.LineStyle.Solid, 1, true );
}
BuyAtMarket

DrawHorzLine

void DrawHorzLine(ChartPane pane, double value, Color color, LineStyle style, int width);

Draws a horizontal line on a pane, and plots an accompanying label marking the value in the right margin of the chart.  The line is drawn using the specified color, style and width.


Example

protected override void Execute(){
    // Plot RSI and draw horizontal lines at 30/70 levels
    ChartPane rsiPane = CreatePane( 50, true, false );
    PlotSeries( rsiPane, RSI.Series(Close,20), Color.Brown, WealthLab.LineStyle.Solid, 1 );
    DrawHorzLine( rsiPane, 30, Color.Green, WealthLab.LineStyle.Solid, 1 );
    DrawHorzLine( rsiPane, 70, Color.Red, WealthLab.LineStyle.Solid, 1 );
}
BuyAtMarket

DrawImage

void DrawImage(ChartPane pane, Image image, int bar, double value, bool behindBars);

Draws the passed image object onto the specified pane.  The image is centered on the specified bar and value in the pane.  The behindBars parameter controls whether the image is rendered behind or in front of the chart bars and plotted indicators.


Example

protected override void Execute(){
    Image image = Image.FromFile("C:\\temp\\image.jpg");
    DrawImage( PricePane, image, Bars.Count-50, Close[Bars.Count-50], false );
}
BuyAtMarket

DrawLabel

void DrawLabel(ChartPane pane, string text, Color color);
void DrawLabel(ChartPane pane, string text);

Draw a text label on the chart, on the specified pane.  Optionally, you can provide a color for the font of the text.  The label will be displayed in the upper left corner of the pane (below the security name if drawn on the price pane.)  Calling DrawLabel multiple times will cause the labels to be stacked one on top of another.


Example

protected override void Execute(){
    for(int bar = 0; bar < Bars.Count; bar++)
    {
        // Check for negative price values
        if ( ( Close[bar] < 0 ) | ( Close[bar] < 0 ) |
        ( Close[bar] < 0 ) | ( Close[bar] < 0 ) )
            DrawLabel(PricePane, Bars.Date[bar].ToString());
    }
}
BuyAtMarket

DrawLine

void DrawLine(ChartPane pane, int bar1, double value1, int bar2, double value2, Color color, LineStyle style, int width);

Draws a line on the specified pane, between the two points identified by bar1, value1 and bar2, value2.  The line is drawn using the specified color, style and width.


Example

protected override void Execute(){
    // Draw a line between the last 2 peaks
    int Bar = Bars.Count-1;
    double p1 = Peak.Value( Bar, High, 4, WealthLab.Indicators.PeakTroughMode.Percent );
    int pb1 = (int) PeakBar.Value( Bar, High, 4, WealthLab.Indicators.PeakTroughMode.Percent );
    double p2 = Peak.Value( pb1, High, 4, WealthLab.Indicators.PeakTroughMode.Percent );
    int pb2 = (int) PeakBar.Value( pb1, High, 4, WealthLab.Indicators.PeakTroughMode.Percent );
    DrawLine( PricePane, pb1, p1, pb2, p2, Color.Red, WealthLab.LineStyle.Dotted, 1 );
}
BuyAtMarket

DrawPolygon

void DrawPolygon(ChartPane pane, Color color, Color fillColor, LineStyle style, int width, bool behindBars, params double[] coords);
void DrawPolygon(ChartPane pane, Color color, LineStyle style, int width, bool behindBars, params double[] coords);

The DrawPolygon allows you to draw a variety of shapes on the chart, optionally filled if you call the version that accepts a fillColor parameter.  The shape will be drawn on the specified pane, using the color, style, and width that you pass as parameters.  The behindBars parameter controls whether the shape will be drawn in front of or behind the bars of the chart.

The actual shape that will be drawn is defined in the coords parameter.  You should pass a series of pairs of doubles, bar/value, that define the points of the polygon.  For example, to draw a triangle, you would pass a total of 6 values, logically representing bar1, value1, bar2, value2, bar3, value3.


Example

protected override void Execute(){
    // Draw a rectangle outlining recent 10% peak and trough
     
    int Bar = Bars.Count-1;
    int b1 = (int)PeakBar.Value( Bar, Close, 10, WealthLab.Indicators.PeakTroughMode.Percent );
    int b2 = (int)TroughBar.Value( Bar, Close, 10, WealthLab.Indicators.PeakTroughMode.Percent );
    double p1 = Close[b1];
    double p2 = Close[b2];
    double[] rectangle = { b1, p1, b1, p2, b2, p2, b2, p1 }; // counter-clockwise
    
    DrawPolygon( PricePane, Color.Blue, Color.LightSteelBlue, WealthLab.LineStyle.Solid, 2, true, rectangle );
}
BuyAtMarket

DrawText

void DrawText(ChartPane pane, string text, int x, int y, Color color, Color backgroundColor, Font font);
void DrawText(ChartPane pane, string text, int x, int y, Color color, Color backgroundColor);
void DrawText(ChartPane pane, string text, int x, int y, Color color);

Draws the specified text in the chart pane, at the x, y pixel coordinates.  The coordinates are expressed as the number of pixels from the upper left corner of the pane.  The text is drawn using the specified color.  If you use the version that accepts a backgroundColor parameter, the text is drawn over a rectangle filled with that color.

Use the version of the method that accept a Font parameter to draw the text using a custom font.  If you use this version and do not want a colored background, specify Color.Empty for the backgroundColor parameter.

Remarks

  • To draw text on the price pane, use PricePane for the pane parameter.
  • To draw text on the volume pane, use VolumePane for the pane parameter.

Example

protected override void Execute(){
    // Prints RSI value over the PricePane
    DrawText( PricePane, "14-period RSI is " + ( RSI.Series( Close, 14 )[Bars.Count-1] ), 0, 40, Color.Black, Color.Empty );
}
BuyAtMarket

EnableTradeNotes

void EnableTradeNotes(bool Text, bool Arrow, bool Circle);

Controls the visibility of a trade tooltip, buy/sell arrows and intrabar entry/exit points on the chart.

The Text parameter controls whether or not a trade tooltip and a line to connect a trade's entry point to its associated exit point (if applicable) are drawn on the chart. Arrow controls whether or not buy and sell arrows appear above/below the bar where trades are opened and closed. Circle controls whether the circles are drawn at the exact spot where trades occur on the bar.

Remarks

  • Disabling arrows will also make trade notes disappear even if Text is true.

Example

protected override void Execute(){
for(int bar = 1; bar < Bars.Count; bar++)
            {
                if (IsLastPositionActive)
                    SellAtMarket( bar+1, LastPosition );
                else
                    BuyAtMarket( bar+1 );
            }
            
            /* Turn off those pesky notes if there 
            are many trades, show arrows only */
            
            if( Positions.Count > 20 )
                EnableTradeNotes( false, true, false );
        }
    }
}
BuyAtMarket

HidePaneLines

void HidePaneLines();

Causes the lines separating the panes in a chart to not be displayed.


Example

protected override void Execute(){
    HidePaneLines();
}
BuyAtMarket

HideVolume

void HideVolume();

Renders the volume pane invisible, providing more room to the Prices Pane in the chart.

Remarks

  • Non-programmatically (and excluding the main chart) you can minimize and maximize panes by clicking the - and + next to the label in the pane's upper left corner. If the labels are not shown, enable them by clicking the "Show Indicators Labels on Chart" button in the chart toolbar.

Example

protected override void Execute(){
    // Some cosmetics
    HideVolume(); 
    HidePaneLines();
    //Plot Microsoft data on the same pane as the symbol being charted
    Bars msft = GetExternalSymbol("MSFT", true);
    ChartPane msftPane = CreatePane( 100, false, true);
    PlotSymbol( msftPane, msft, Color.Silver, Color.Silver);
}
BuyAtMarket

PadBars

void PadBars(int numberOfBars);

Pads the right of the chart with empty space.  The amount of space padded is based on the number specified in the numberOfBars parameter.  New "pseudo-bars" are not created, but the current bar spacing selected and the numberOfBars determines how much empty space is padded to the right of the chart.


Example

protected override void Execute(){
    PadBars( 10 );
}
BuyAtMarket

PlotFundamentalItems

void PlotFundamentalItems(ChartPane pane, string symbol, string itemName, Color color, LineStyle style, int width);
void PlotFundamentalItems(ChartPane pane, string itemName, Color color, LineStyle style, int width)

Plots historical fundamental data items onto the chart, on the specified pane.  The desired items to plot are specified by the itemName parameter.  If the desired items are symbol-specific, then use the version of the method that accepts a symbol parameter, and pass the stock symbol whose items you want to plot.  The fundamental data is plotted in a special filled style, where the demarcation of each item is outlined in the specified color.  When a new fundamental data item occurs, it can be clearly seen because this range is outlined using the color.  The interior of the plotted area is filled with semi-transparent version of the color specified.  Finally, plotted ranges are outlined using the indicated width.


Example

protected override void Execute(){
    ChartPane fPane1 = CreatePane( 25, true, false );
    ChartPane fPane2 = CreatePane( 25, true, false );

    // Plot IBM dividends on the chart of another stock
    
    if( (string)Bars.Symbol != "IBM" )
    {
        PlotFundamentalItems( fPane1, "IBM", "dividend", Color.Red, WealthLab.LineStyle.Solid, 1 ); 
    } else
    Abort();
    
    DataSeries divIBM = FundamentalDataSeries( "IBM", "dividend" );
    PlotSeries( fPane2, divIBM, Color.Red, WealthLab.LineStyle.Solid, 1 );
}
BuyAtMarket

PlotSeries

void PlotSeries(ChartPane pane, DataSeries series, Color color, LineStyle style, int width);
void PlotSeries(ChartPane pane, DataSeries series, Color color, LineStyle style, int width, string label);

Plots the specified DataSeries (series) in the specified pane of the chart.  The cosmetic appearance of the plotted DataSeries is controlled by the color, style, and width parameters.

Remarks

  • When using the Histogram LineStyle, the width parameter determines the maximum width that each histogram bar is allowed to grow to.  So, specify large values (such as 20) to allow the histogram bars to grow as you increase bar spacing.
  • By default, the Description of the DataSeries is drawn as a label in the upper left corner of the pane.  You can set the DataSeries' Description property to change this label, or use the overloaded version of the method.

Example

protected override void Execute(){
    // Plots KAMA series of Average prices
    PlotSeries( PricePane, KAMA.Series( ((High+Low)/2), 20 ), Color.Chocolate, WealthLab.LineStyle.Solid, 2 );
}
BuyAtMarket

PlotSeriesDualFillBand

void PlotSeriesDualFillBand(ChartPane pane, DataSeries series1, DataSeries series2, Color fillColor1, Color fillColor2, Color color, LineStyle style, int width);
void PlotSeriesDualFillBand(ChartPane pane, DataSeries series1, DataSeries series2, Brush brush1, Brush brush2, Color color, LineStyle style, int width);

Plots and fills bands composed of two DataSeries (series1 and series2) that periodically cross over each other, on the specified pane.  Each individual DataSeries is plotted using the specified color, style, and width.  The band between each DataSeries is filled with alternating colors (or brushes).  fillColor1 (or brush1) is used when series1 is above series2, and fillColor2 (or brush2) when series2 is above series1.

Remarks

  • Use fillColors and brushes that are semi-transparent, so that the chart bars can show up behind the filled bands.
  • Histogram style does not make sense for filled bands, this style is treated as Solid by PlotSeriesDualFillBand.
  • By default, the Description of the DataSeries is drawn as a label in the upper left corner of the pane.  You can set the DataSeries' Description property to change this label.

Example

protected override void Execute(){
    // Plots and fills bands composed of Average Price and KAMA series that cross over each other. 
    PlotSeriesDualFillBand( PricePane, KAMA.Series( Close, 10 ), ((High+Low)/2), Color.Red, Color.Blue, Color.Black, LineStyle.Solid, 1 );
}
BuyAtMarket

PlotSeriesFillBand

void PlotSeriesFillBand(ChartPane pane, DataSeries upper, DataSeries lower, Color color, Color fillColor, LineStyle style, int width);
void PlotSeriesFillBand(ChartPane pane, DataSeries upper, DataSeries lower, Color color, Brush fillBrush, LineStyle style, int width);

Plots and fills an upper and lower band of two DataSeries, in the specified chart pane.  The upper and lower bands are plotted using the specified color, style and width.  The interior of the band is filled using the specified fillColor, or the specified fillBrush.

Remarks

  • Use fillColors and fillBrushes that are semi-transparent, so that the chart bars can show up behind the filled band.
  • Histogram style does not make sense for filled bands, this style is treated as Solid by PlotSeriesFillBand.
  • By default, the Description of the DataSeries is drawn as a label in the upper left corner of the pane.  You can set the DataSeries' Description property to change this label.

Example

protected override void Execute(){
    BBandLower bbL = BBandLower.Series( Close, 20, 2 );
    BBandUpper bbU = BBandUpper.Series( Close, 20, 2 );
    SolidBrush shadowBrush = new SolidBrush(Color.FromArgb(50, Color.Violet));
    PlotSeriesFillBand(PricePane, bbU, bbL, Color.Silver, shadowBrush, LineStyle.Solid, 2);
}
BuyAtMarket

PlotSeriesOscillator

void PlotSeriesOscillator(ChartPane pane, DataSeries source, double overbought, double oversold, Color overboughtColor, Color oversoldColor, Color color, LineStyle style, int width);
void PlotSeriesOscillator(ChartPane pane, DataSeries source, double overbought, double oversold, Brush overboughtBrush, Brush oversoldBrush, Color color, LineStyle style, int width);

Plots the specified DataSeries (source) in the specified pane, using the provided color, style and width.  Additionally, it allows you to define overbought and oversold levels.  When the source moves below the oversold area, this area of the chart is filled using the oversoldColor (or oversoldBrush).  Conversely, when the source moves above the overbought area, that area of the chart is filled with the overboughtColor (or overboughtBrush).

Remarks

  • By default, the Description of the DataSeries is drawn as a label in the upper left corner of the pane.  You can set the DataSeries' Description property to change this label.

Example

protected override void Execute(){
    //Create and plot RSI indicator
    RSI rsi = RSI.Series( Close, 14 );
    ChartPane rsiPane = CreatePane( 40, true, true );
    PlotSeriesOscillator( rsiPane, rsi, 70, 30, Color.Green, Color.Red, Color.CadetBlue, LineStyle.Solid, 1 );
}
BuyAtMarket

PlotStops

void PlotStops();

Call PlotStops to cause stop and limit orders to be plotted on the chart.  Stop and limit orders will appear as small colored dots on the chart, drawn at the appropriate bar and price levels.  The stop/limit plots are color coded by order type:

  • Buy = blue
  • Sell = red
  • Short = fuchsia
  • Cover = green

Example

protected override void Execute(){
    // Displays Stop and Limit orders
    PlotStops();
    for(int bar = 20; bar < Bars.Count; bar++)
    {
        if (IsLastPositionActive)
        {
            if ( SellAtLimit( bar+1, LastPosition, Highest.Series( High, 20 )[bar] ) == null )
                SellAtStop( bar+1, LastPosition, Lowest.Series( Low, 20 )[bar] );
        }
        else
        {
            if ( BuyAtLimit( bar+1, Low[bar]-ATR.Series(Bars,5)[bar] ) == null )
                BuyAtStop( bar+1, High[bar]+ATR.Series(Bars,5)[bar] );
        }
    }
}
BuyAtMarket

PlotSymbol

void PlotSymbol(ChartPane pane, Bars bars, Color upColor, Color downColor);

Plots the Bars object specified in the bars parameter onto the chart, in the indicated pane.  To superimpose another symbol onto the price pane, use the PricePane property as the value of the pane parameter.  The pane that is selected is automatically rescaled to support the range of the plotted data.  The upColor and downColor parameters determine the colors that will be used to plot "up" bars (close greater than open) and "down" bars (close less than or equal to open).

Remarks

  • The Bars object that is being plotted must be synchronized to the symbol being charted, or PlotSymbol will fail.
  • Since it's not possible to align the x-axis for multiple charts, PlotSymbol will not work with the Trending Chart Styles.

Example

protected override void Execute(){    // Some cosmetics
    HideVolume(); 
    HidePaneLines();
    
    //Plot Microsoft data in a new pane
    Bars msft = GetExternalSymbol("MSFT", true);
    ChartPane msftPane = CreatePane( 100, false, true);
    PlotSymbol( msftPane, msft, Color.Silver, Color.Silver);

}
BuyAtMarket

PlotSyntheticSymbol

void PlotSyntheticSymbol(ChartPane pane, string symbol, DataSeries open, DataSeries high, DataSeries low, DataSeries close, DataSeries volume, Color upBarColor, Color downBarColor);

Allows you to plot a synthetic symbol on the chart, in the specified pane.  A synthetic symbol is composed of a group of DataSeries that represent the symbol's open, high, low, close and volume.  The symbol parameter indicates a string that represents the name that should be applied to the synthetic symbol, this is plotted as a label on the chart.  The upBarColor and downBarColor parameters determine the color to use when plotting up bars (close greater than open) and down bars (close less than or equal to open).

Remarks

  • In order to plot a synthetic symbol, its constituent DataSeries must by synchronized to the main chart data that is already being plotted.  If this is not the case, call Synchronize on each of the underlying DataSeries to synchronize them before plotting.
  • Since it's not possible to align the x-axis for multiple charts, PlotSyntheticSymbol will not work with the Trending Chart Styles.

Example

protected override void Execute(){
    // Plot candle which consists of average Open/High/Low/Close values
    ChartPane SMAPane = CreatePane( 100, true, true );
    DataSeries O = SMA.Series( Open, 20 );
    DataSeries H = SMA.Series( High, 20 );
    DataSeries L = SMA.Series( Low, 20 );
    DataSeries C = SMA.Series( Close, 20 );
    PlotSyntheticSymbol( SMAPane, "SMACandle", O, H, L, C, null, Color.Blue, Color.Red );
}
BuyAtMarket

PricePane Property

ChartPane PricePane

Returns the ChartPane where the Bars of the chart are plotted.  You can use this pane to plot other indicators, such as moving averages and Bollinger Bands, or as a parameter to many other WealthScript cosmetic chart methods such as AnnotateBar and DrawPolygon.

Remarks

  • Even if the Strategy is operating in a context that is not charted (such as the Strategy Monitor), this property will not return null.
  • See the documentation on the ChartPane object for more information about its properties and methods.
BuyAtMarket

SetBackgroundColor

SetBackgroundColor(int bar, Color color);

Sets the color that will be used to render the background of the chart at the individual bar.  The background is colored from top to bottom, encompassing all panes on the chart.

Remarks

  • Use SetPaneBackgroundColor to color the background of individual panes.

Example

protected override void Execute(){
    // Plot the weekly MACD in our daily chart
    SetScaleWeekly();
    DataSeries smaWeekly = SMA.Series( Close, 52 );
    RestoreScale();
    smaWeekly = Synchronize( smaWeekly );
    for(int bar = 52; bar < Bars.Count; bar++)
    {
        if ( Close[bar] > smaWeekly[bar] )
        {
            SetBackgroundColor( bar, Color.LightGreen );
        }
        else
        {
            SetBackgroundColor( bar, Color.LightPink );
        }
    }
}
BuyAtMarket

SetBarColor

SetBarColor(int bar, Color color);

Sets the color that will be used to render the individual bar on the chart that is specified by the bar parameter.


Example

protected override void Execute(){
    // Color bars green when RSI < 20, otherwise
    // color up days blue and down days red }
    DataSeries hRSI = RSI.Series( Close, 14 );
    for(int bar = 50; bar < Bars.Count; bar++)
    {
        if ( hRSI[bar] < 60 )
            SetBarColor( bar, Color.Green );
        else
        if ( Close[bar] > Close[bar-1] )
        SetBarColor( bar, Color.Blue );
        else
        SetBarColor( bar, Color.Red );
    }
}
BuyAtMarket

SetBarColors

void SetBarColors(Color colorUpBars, Color colorDownBars);

Changes that colors that will be used to plot the bars of the chart.  "Up" bars are defined as close greater than open, and these bars will be colored using colorUpBars.  Bars where close is less than or equal to open will be colored using colorDownBars.


Example

protected override void Execute(){
    SetBarColors( Color.Navy, Color.Maroon );
}
BuyAtMarket

SetLogScale

void SetLogScale(ChartPane pane, bool logScale);

Turns semi-log scaling on or off for the specified pane.  The logScale parameter indicates whether semi-logarithmic scaling should be applied to the pane.


Example

protected override void Execute(){
    SetLogScale( PricePane, true );
}
BuyAtMarket

SetPaneBackgroundColor

void SetPaneBackgroundColor(ChartPane pane, int bar, Color color);

Changes the background color of the specified pane, for the specified bar, to the color indicated.


Example

protected override void Execute(){
    // Plot RSI and CMO, color backgrounds to show overbought/oversold levels
    ChartPane RSIPane = CreatePane( 30, true, true );
    ChartPane CMOPane = CreatePane( 30, true, true );
    PlotSeries( RSIPane, RSI.Series( Close, 14 ), Color.DarkBlue, WealthLab.LineStyle.Solid, 2 ); 
    PlotSeries( CMOPane, CMO.Series( Close, 14 ), Color.Blue, WealthLab.LineStyle.Solid, 2 ); 
    for(int bar = 20; bar < Bars.Count; bar++)
    {
        if ( RSI.Series( Close, 14 )[bar] < 30 )
            SetPaneBackgroundColor( RSIPane, bar, Color.LightGreen );
        else if ( RSI.Series( Close, 14 )[bar] > 70 )
            SetPaneBackgroundColor( RSIPane, bar, Color.LightPink );
        if ( CMO.Series( Close, 14 )[bar] < -50 )
            SetPaneBackgroundColor( CMOPane, bar, Color.LightGreen );
        else if ( CMO.Series( Close, 14 )[bar] > 50 )
            SetPaneBackgroundColor( CMOPane, bar, Color.LightPink );
    }
}
BuyAtMarket

SetPaneMinMax

void SetPaneMinMax(ChartPane pane, double min, double max);

Allows you to set the scale of a particular pane manually.  The minimum and maximum (min and max) values that you supply will be used to define the visible range of the pane.  The actual visible scale of the pane will still dynamically adjust if the chart or plotted indicators extend beyond the range that you specify.


Example

protected override void Execute(){
    // Make sure a certain RSI range is always visible in the pane
    ChartPane RSIPane = CreatePane( 60, true, true );
    PlotSeries( RSIPane, RSI.Series( Close, 14 ), Color.Navy, WealthLab.LineStyle.Solid, 1 );
    SetPaneMinMax( RSIPane, 30, 70 );
}
BuyAtMarket

SetSeriesBarColor

void SetSeriesBarColor(int bar, DataSeries ds, Color color);

Allows you to specify colors for individual bars of a specific DataSeries (ds) that is plotted on the chart.


Example

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] > 60 )
            SetSeriesBarColor( bar, rsi, Color.Red );
        else if ( rsi[bar] < 40 )
            SetSeriesBarColor( bar, rsi, Color.Blue );
    }
}
BuyAtMarket

VolumePane Property

ChartPane VolumePane

Returns the ChartPane that the volume is being plotted in.

Remarks

  • Even if the Strategy is operating in a context that is not charted (such as the Strategy Monitor), this property will not return null.
  • See the documentation on the ChartPane object for more information about its properties and methods.