Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw.VerticalLine redrawing.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Draw.VerticalLine redrawing.

    Hello.

    I'm trying to redraw two existing vertical lines using this code:

    Code:
    		protected override void OnBarUpdate()
    		{
    			if (Bars.IsFirstBarOfSession && ToDay(Time[0]) == ToDay(DateTime.Now)) {
    				line1 = Draw.VerticalLine(this, "Line1", new DateTime([B]2016,9,15,10,29,43[/B]), Brushes.Red, DashStyleHelper.Solid, 2, true);
    				line2 = Draw.VerticalLine(this, "Line2", new DateTime([B]2016,9,15,10,30,07[/B]), Brushes.Blue, DashStyleHelper.Solid, 2, true);
    				
    			}	
    		}
    
    		protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    		{
    			if(!chartScale.IsVisible)
    			    return;
    				
    			DateTime timeToCheck = new DateTime(2016,9,15,12,30,00);
    			 
    			// Find the chart-canvas x-coordinate of the bar at the specified time
    			int xCoordinate = chartControl.GetXByTime(timeToCheck);
    			DateTime dt1 = chartControl.GetTimeByX(xCoordinate-2);
    			DateTime dt2 = chartControl.GetTimeByX(xCoordinate+2);
    			
    			// Print the x-coordinate value
    			Print("xCoordinate " + xCoordinate);
    			Print("Time-2 " + dt1);
    			Print("Time+2 " + dt2);
    			
    			[B]line1.StartAnchor.Time[/B] 	= dt1;
    			[B]line2.StartAnchor.Time[/B] 	= dt2;
    			
    		}
    As you can see on screenshot Anchor Time has been changed, but the lines 1and 2 are situated at the centre of a bars.

    If you comment the lines with StartAnchor.Time changing, lines on chart would be drawn correctly (see 2nd screenshot).

    What I'm doing wrong?
    Attached Files

    #2
    Hello,

    Thank you for the post.

    I took a look at the script provided and do see a difference between when you Call the drawing tool and set a date time:

    Code:
    line1 = Draw.VerticalLine(this, "Line1", new DateTime(2016,9,15,12,30,05), Brushes.Red, DashStyleHelper.Solid, 2, true);
    Versus:

    Code:
    line1.StartAnchor.Time 	= new DateTime(2016,9,15,12,30,05);
    I will need to do further research to see what specifically is different between adjusting the Anchor, and how the actual Draw. method works. Once I have further information on this I will reply back.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello, i look forward to hearing from you.

      Comment


        #4
        Hello,

        I just wanted to reply back on this item, this was resolved and is scheduled for a future release.
        The tracking number for the change log is: NTEIGHT-10515.

        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by jclose, Today, 09:37 PM
        0 responses
        5 views
        0 likes
        Last Post jclose
        by jclose
         
        Started by WeyldFalcon, 08-07-2020, 06:13 AM
        10 responses
        1,414 views
        0 likes
        Last Post Traderontheroad  
        Started by firefoxforum12, Today, 08:53 PM
        0 responses
        11 views
        0 likes
        Last Post firefoxforum12  
        Started by stafe, Today, 08:34 PM
        0 responses
        11 views
        0 likes
        Last Post stafe
        by stafe
         
        Started by sastrades, 01-31-2024, 10:19 PM
        11 responses
        169 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X