Ultimate goal is an indicator which plots where all rays extending into the future intersect with the present moment so orders can be attached to them. Need multiple rays to attach multiple varied entries, stops, targets, etc.
Below code is almost there. It plots the EndAnchor.Price. Eventually, I'll put a slope calculation in to MoveAnchor to the intercept at the present moment.
The code gets all rays pointing to the future. Filters those which are user drawn. And for each pulls the EndAnchor.Price.
Below code compiles, but does not plot anything or expose any values to the databox.
Previous versions of the code, where I added a single plot and put a single ray anchor's price into a single value worked fine.
Leads me to believe the hang-up is with the way the plots are dynamically added. I've tried dynamically adding them in State.SetDefaults, State.Configure, and OnBarUpdate(), all to no avail.
My search of other NT8 threads suggests my code is doing it correctly, just not sure why it's not plotting.
Any suggestions?
public class Raycator : Indicator
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Grabs the price where any ray crosses the current market time.";
Name = "Raycator";
Calculate = Calculate.OnEachTick;
IsOverlay = true;
DisplayInDataBox = true;
//DrawOnPricePanel = true;
IsSuspendedWhileInactive = true;
}
else if (State == State.Configure)
{
int i=0;
foreach (DrawingTool draw in DrawObjects)
{
if (draw.IsUserDrawn && draw is DrawingTools.Ray)
{
DrawingTools.Ray tempRay = draw as DrawingTools.Ray;
if (tempRay.StartAnchor.Time < tempRay.EndAnchor.Time)
{
AddPlot(Brushes.Green, tempRay.Tag);
}
}
i++;
}
}
}
protected override void OnBarUpdate()
{
int i=0;
foreach (DrawingTool draw in DrawObjects)
{
if (draw.IsUserDrawn && draw is DrawingTools.Ray)
{
DrawingTools.Ray tempRay = draw as DrawingTools.Ray;
if (tempRay.StartAnchor.Time < tempRay.EndAnchor.Time)
{
Values[i][0] = tempRay.EndAnchor.Price;
}
}
i++;
}
}
}
}
Comment