Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help with Ray Anchor Points

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

    Help with Ray Anchor Points

    Hi NT Support,

    I have the following code in a strategy I'm developing:


    Code:
    if(myLine == null && State != State.Historical) //Initial set of Ray
    {
             myLine = Draw.Ray(this, "MyLine", true, 10, High[10], 5, High[10], Brushes.Blue, DashStyleHelper.Solid, 2);
             myLine.IsLocked = false;
    }
    
    if(myLine != null && State != State.Historical) 
    {
            Print(DateTime.Now+" Last BarsAgo= "+myLine.EndAnchor.BarsAgo+" First BarsAgo= "+myLine.StartAnchor.BarsAgo);
    }


    Before I manually move the Ray on the chart, the following info is printed, which is correct:

    10/22/2019 4:32:51 PM Last BarsAgo= 5 First BarsAgo= 10


    But, after I manually move the Ray on the chart, I get the following output:

    10/22/2019 4:32:52 PM Last BarsAgo= -2147483648 First BarsAgo= 10



    I'm trying to ascertain why the BarsAgo value for the EndAnchor appears to get corrupted or be incorrect.

    #2
    Hello maltese,

    Thank you for the post.

    This is expected as the object is now a manually drawn after moving it. The BarsAgo property and also the DrawnOnBar only relate to script drawn objects, you instead would need to use SlotIndex after manually moving it.This is noted in the BarsAgo and DrawnOnBar documentation.

    Please note that SlotIndex is not exactly the same as your scripts BarsAgo. The SlotIndex is the nearest bar slot value where anchor is drawn on a chart.


    https://ninjatrader.com/support/helpGuides/nt8/?drawnonbar.htm.


    I look forward to being of further assistance.



    Comment


      #3
      Originally posted by NinjaTrader_Jesse View Post
      Hello maltese,

      Thank you for the post.

      This is expected as the object is now a manually drawn after moving it. The BarsAgo property and also the DrawnOnBar only relate to script drawn objects, you instead would need to use SlotIndex after manually moving it.This is noted in the BarsAgo and DrawnOnBar documentation.

      Please note that SlotIndex is not exactly the same as your scripts BarsAgo. The SlotIndex is the nearest bar slot value where anchor is drawn on a chart.


      https://ninjatrader.com/support/helpGuides/nt8/?drawnonbar.htm.


      I look forward to being of further assistance.




      OK. Thanks. That helped.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by NullPointStrategies, 03-13-2026, 05:17 AM
      0 responses
      95 views
      0 likes
      Last Post NullPointStrategies  
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      153 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      80 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      54 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      70 views
      0 likes
      Last Post TheRealMorford  
      Working...
      X