Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Processing line breaks for Hand Drawn Horizontal and Ray lines

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

    Processing line breaks for Hand Drawn Horizontal and Ray lines

    Hello,

    I had an indicator in NT7 that is partially ported to NT8.

    What it did was give me an alert when a hand-drawn Horizontal or Ray lines were crossed. It is working in NT8 for horizontal lines but not Rays.

    This is the code that searches for the lines

    foreach (IDrawObject draw in DrawObjects)
    {
    // select User Drawn Horizontal or Ray Lines, and BLACK
    if (draw.UserDrawn
    && (draw.DrawType == DrawType.Ray
    || draw.DrawType == DrawType.HorizontalLine))
    {
    //Sets some line properties programatically
    ILine ThisLine = (ILine) draw;
    if (ThisLine.Pen.Color == Color.Black
    || ThisLine.Pen.Color == Color.Cyan)
    {
    ProcessDrawObject(draw, ThisLine);
    }
    }
    }

    The ProcessDrawObject method receives the ILine object and then gets the anchors

    //Sets right and left points depending on how line is drawn.
    if (ThisLine.StartBarsAgo > ThisLine.EndBarsAgo)
    {
    LeftY = ThisLine.StartY;
    RightY = ThisLine.EndY;
    LeftBarsAgo = ThisLine.StartBarsAgo;
    RightBarsAgo = ThisLine.EndBarsAgo;
    }

    else if (ThisLine.StartBarsAgo < ThisLine.EndBarsAgo)
    {
    LeftY = ThisLine.EndY;
    RightY = ThisLine.StartY;
    LeftBarsAgo = ThisLine.EndBarsAgo;
    RightBarsAgo = ThisLine.StartBarsAgo;
    }

    then I can test for a line cross...

    ================================================== =================

    in NT7 this worked for both Ray and Horizontalline....

    a search in the NT8 online help does not produce resulte for "ILine".... ???

    could it be that in NT8 a HorizontalLine and Ray have different interface objects?

    1) if so, what is the interface object for Ray

    and

    2) where can I find them in the online doc?

    thanks
    ​​

    #2
    Ok, stupid me....the above code is for NT7...I had that open in the NT8 Editor (no compile option)................

    I guess the question would be, are there code snippets that can show me how to access the anchor data for a Ray?

    Comment


      #3
      seems it is this

      DrawingTools.Ray thisRay = draw as DrawingTools.Ray;

      double LeftY = thisRay.StartAnchor.Price;
      double RightY = thisRay.EndAnchor.Price;

      int LeftBarsAgo = thisRay.StartAnchor.BarsAgo;
      int RightBarsAgo = thisRay.EndAnchor.BarsAgo;

      Comment


        #4
        Hello l​lanqui,

        Thanks for your post.

        That would be the correct way to get the Price and BarsAgo of the drawing object's StartAnchor and EndAnchor in NinjaTrader 8.

        See the help guide documentation below for more information.

        IDrawingTool: https://ninjatrader.com/support/help...rawingtool.htm
        DrawObjects: https://ninjatrader.com/support/help...rawobjects.htm
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        647 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        368 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        108 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        571 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        573 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X