Search Framework:
ManuallyDrawnObject
Namespace: WealthLab.Backtest
Parent: Object

Represents a drawing object (such as a trend line, Fibonacci retracement, or note) that was placed on the chart. WL8 saves manually drawn chart objects by symbol and HistoryScale (Daily, Weekly, etc).

Members
Bars
public BarHistory Bars

The BarHistory instance that is associated with this drawing object.


DrawingObjectType
public string DrawingObjectType

The type of drawing object, for example "Line", "Fibonacci Retracement" or "Text Note." In WL8 chart you can determine a drawing object's type name by editing it (the name appears in the dialog title) or hovering over the drawing object's button in the drawing object toolbar.


ExtendLine
public double ExtendLine(int pt1, int pt2, int idx)

The parameters pt1 and pt2 represent two indices into the objects Points list. The parameter idx represents an index into the associated BarHistory that you want to project a line connecting the two points to. Returns the y-axis value at which the line intersects at position idx.


ExtendLineLog
public double ExtendLineLog(int pt1, int pt2, int idx)

The parameters pt1 and pt2 represent two indices into the objects Points list. The parameter idx represents an index into the associated BarHistory that you want to project a line connecting the two points to. Returns the y-axis value at which the line intersects at position idx. The line is calculated with the y-axis assuming a semi-log scale.

Example Code
using WealthLab.Backtest;
using System;
using WealthLab.Core;
using WealthLab.Data;
using WealthLab.Indicators;
using System.Collections.Generic;

namespace WealthScript1 
{
    public class MyStrategy : UserStrategyBase
    {
        //write out chart drawing objectw to debug log
        public override void Initialize(BarHistory bars)
        {
			List<ManuallyDrawnObject> mdos = GetChartDrawings(bars, null, null);
			WriteToDebugLog("Number of Drawing Objects found: " + mdos.Count);
			foreach (ManuallyDrawnObject mdo in mdos)
			{
				WriteToDebugLog("---------");
				WriteToDebugLog("Type=" + mdo.DrawingObjectType);
				WriteToDebugLog("Name=" + mdo.NameFromUser);
				for (int p = 0; p < mdo.Points.Count; p++)
					WriteToDebugLog("Point" + p + ": Index=" + mdo.Points[p].Index + ",Value=" + mdo.Points[p].Value);
				
				//it it's a line, write its end point to the debug log
				if (mdo.DrawingObjectType == "Line")
				{
					double lastVal = mdo.ExtendLineLog(0, 1, bars.Count - 1);
					WriteToDebugLog("Line ends at: " + lastVal);
				}
			}
        }

        //execute the strategy rules here, this is executed once for each bar in the backtest history
        public override void Execute(BarHistory bars, int idx)
        {
        }
    }
}

NameFromUser
public string NameFromUser

The name that you gave the drawing object (if any) during its creation or subsequent editing.


Pane
public string Pane

The name of the chart pane that the drawing object occupies. Returns "Price" for the price pane, "Volume" for the volume pane, and other strings such as "RSI" or "CMO" for indicator panes.


Points
public List<HistoricalDataPoint> Points

Returns a list of HistoricalDataPoint instances that represent the points of the drawing object. Different types of drawing objects have different numbers of Points. For example, a Line and Fibonacci Retracement have two Points, while a Text Note has one Point.