Hi HellGhost - not quite what I wanted to do, but it got me a little closer. Thank you for the inspiration. I still have an error that I cannot get past.
Noting that you made a list of ChartPoints, I made my list of IRectangleObjects, and that allowed me to access the Properties of the rectangles (ie: Begin, End, etc)
Here's my toy code that shows what I want to do:
Code: Select all
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
using System.Collections.Generic; // Added for List
namespace PowerLanguage.Indicator
{
[SameAsSymbol(true)]
public class _TEST_ChartObjects_Stacks : IndicatorObject
{
public _TEST_ChartObjects_Stacks(object _ctx) : base(_ctx) { }
private List<IRectangleObject> myDrawings;
protected override void Create() {
Output.Clear();
}
protected override void StartCalc()
{
myDrawings = new List<IRectangleObject>();
}
protected override void CalcBar()
{
if (Bars.FullSymbolData.Current == Bars.FullSymbolData.Count - 1)
{
myDrawings.Add(DrwRectangle.Create(new ChartPoint(Bars.Time[55], Bars.Low[55]), new ChartPoint(Bars.Time[45], Bars.High[45])));
if(myDrawings.Count > 0){
IRectangleObject robj = myDrawings.Last<IRectangleObject>();
// This writes to Output successfully
Output.WriteLine("End point {0}", robj.End.ToString());
ChartPoint cp = new ChartPoint(Bars.Time[2], Bars.High[2]);
robj.End = cp; // This fails with "System.ApplicationException: This was never displayed!"
Output.WriteLine("End point {0}", robj.End.ToString());
}
}
}
}
}
The error that occurs when I try to assign a new chartpoint to an existing End property is this:
"System.ApplicationException: This was never displayed!"
I also tried accessing the individual parameters of the chartpoint:
Code: Select all
robj.End.Time = Bars.Time[2];
robj.End.Price = Bars.High[2];
But that was no more successful. All of these properties should be both Get and Set according to the documentation:
So, it seems that the
methods and properties are available to use, but something about my syntax is preventing me from updating a pre-existing rectangle. Of course, I could:
Code: Select all
<pseudocode>
Capture the Begin point of the last rectangle to a ChartPoint variable
Delete the last rectangle
Add a new Rectangle using the old Begin chartpoint and an updated End chartpoint
</pseudocode>
But,
if I can update the existing rectangle, that
should be the easier, better option.
Can it be done?