Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.



    JesseNinjaTrader Customer Service

    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 judysamnt7, 03-13-2023, 09:11 AM
      4 responses
      59 views
      0 likes
      Last Post DynamicTest  
      Started by ScottWalsh, Today, 06:52 PM
      4 responses
      36 views
      0 likes
      Last Post ScottWalsh  
      Started by olisav57, Today, 07:39 PM
      0 responses
      7 views
      0 likes
      Last Post olisav57  
      Started by trilliantrader, Today, 03:01 PM
      2 responses
      21 views
      0 likes
      Last Post helpwanted  
      Started by cre8able, Today, 07:24 PM
      0 responses
      10 views
      0 likes
      Last Post cre8able  
      Working...
      X