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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      79 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      40 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      63 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      63 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      54 views
      0 likes
      Last Post CarlTrading  
      Working...
      X