Drawing a horizontal or vertical line segment in past

Custom indicators, trading strategies, data export and recording and more...
rickbarlow
Posts: 43
Joined: Mon Feb 08, 2021 5:37 pm
Been thanked: 1 time

Drawing a horizontal or vertical line segment in past

Post by rickbarlow » Mon Nov 01, 2021 9:12 pm

I have a question about drawing a line between price points in the primary window that are in the past and future.

Examples :
1) I want to draw a horizontal line from 9:00AM - 4:15PM today at price = 4500.00. The current time is 1:00PM
2) I want to draw a vertical line at 10:00AM from 4500.00 to 4515.50. The current time is 1:00PM

I use the addpoint() method to draw lines on an interval basis, but that only works going forward.

I have a question about drawing a line between price points in the primary window that are in the past and future.

Examples :
1) I want to draw a horizontal line from 9:00AM - 4:15PM today at price = 4500.00. The current time is 1:00PM
2) I want to draw a vertical line at 10:00AM from 4500.00 to 4515.50. The current time is 1:00PM

I use the addpoint() method to draw lines on an interval basis, but that only works going forward.
I also use the addShape() method functionality that can draw at a time relative to the current time to put a shape on the screen, or absolute location based on location in the window. But I haven't figured out how to determine the exact point that equates to both price and time so that I can draw lines from one point to another, and have them persist (when changing the price / time scale).

If there's a sample app that does this that would be very helpful. 
Thanks
 

rickbarlow
Posts: 43
Joined: Mon Feb 08, 2021 5:37 pm
Been thanked: 1 time

Re: Drawing a horizontal or vertical line segment in past

Post by rickbarlow » Mon Nov 01, 2021 11:02 pm

Nevermind...
I figured it out with the use of examples already there.

        public void drawHorizontalLine(long t1, long t2, double price, Color color) {
            CompositeHorizontalCoordinate x1 = new CompositeHorizontalCoordinate(CompositeCoordinateBase.DATA_ZERO, 0, t1);
            CompositeVerticalCoordinate y1 = new CompositeVerticalCoordinate(CompositeCoordinateBase.DATA_ZERO,-1, price);
            CompositeHorizontalCoordinate x2 = new CompositeHorizontalCoordinate(CompositeCoordinateBase.DATA_ZERO, 0, t2);
            CompositeVerticalCoordinate y2 = new CompositeVerticalCoordinate(CompositeCoordinateBase.DATA_ZERO, 2, price);
       
            CanvasIcon icon = new CanvasIcon(DOT_PATTERN, x1, y1, x2, y2);
            heatmapCanvas.addShape(icon);
        }

Post Reply