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

The ManuallyDrawnObject class represents a drawing object, such as a trend line, Fibonacci retracement, or text note, that was manually placed on a WL9 chart. WL9 associates manually drawn chart objects with a symbol and HistoryScale.

Members
Bars
public BarHistory Bars

The BarHistory instance associated with this drawing object.


DrawingObjectType
public string DrawingObjectType

The type of drawing object, for example "Line", "Fibonacci Retracement", or "Text Note".


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

Projects a linear line through two points in the drawing object's Points collection and returns the y-axis value where that line intersects the BarHistory index specified in idx. The pt1 and pt2 parameters are indices into the Points List. If either point index is outside the bounds of the Points List, the method throws an ArgumentException.


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

Projects a logarithmic line through two points in the drawing object's Points collection and returns the y-axis value where that line intersects the BarHistory index specified in idx. The pt1 and pt2 parameters are indices into the Points List. If either point index is outside the bounds of the Points List, the method throws an ArgumentException.


NameFromUser
public string NameFromUser

The name assigned to the drawing object by the user, if any.


Pane
public string Pane

The name of the chart pane occupied by the drawing object. Typical values include "Price", "Volume", or the pane tag of an indicator such as "RSI" or "CMO".


Points
public List<HistoricalDataPoint> Points

Contains the HistoricalDataPoint instances that define the drawing object. Different drawing object types use different numbers of points. For example, a Line or Fibonacci Retracement typically uses two points, while a Text Note uses one.

Example Code
using WealthLab.Backtest;
using WealthLab.Core;
using System.Collections.Generic;
namespace WealthScript1
{
    public class MyStrategy : UserStrategyBase
    {
        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);
                }
                if (mdo.DrawingObjectType == "Line")
                {
                    double lastVal =
                        mdo.ExtendLineLog(0, 1, bars.Count - 1);
                    WriteToDebugLog("Line ends at: " + lastVal);
                }
            }
        }
        public override void Execute(BarHistory bars, int idx)
        {
        }
    }
}