Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

CrossBelow Custome draw

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

    CrossBelow Custome draw

    Hi, can Ninja coding a way to exit a position when Close[0] cross below a custom line?

    if (CrossBelow(Close, "Blue Line", 1)

    ExitLong("Exit","Long");

    It doessn´t compile although I've added the indicator to the strategy that plotted the "Blue Line" on the chart.


    Thanks for help.
    Attached Files

    #2
    Hello,

    There are two ways to do this.

    One way means when you add the strategy it will draw the line on the chart and have "control" over it.

    The other way means it will scan the chart for a user drawn line with a specific name and grab the price from it.

    What way do you want and I can send information on how to do this.
    BrettNinjaTrader Product Management

    Comment


      #3
      I think it will helpfull the second way. Thanks in advance

      Comment


        #4
        Hello,



        You would need to use the following code:

        Code:
         foreach (IDrawObject draw in DrawObjects)
          {
        
        
                if (draw.DrawType == DrawType.HorizontalLine)
                {
                            ILine globalLine         = (ILine) draw;
                           if (Close[0] >= globalLine.EndY) 
                           EnterLong();
        
                }
        
                 
        
         }
        BrettNinjaTrader Product Management

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        648 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 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
        572 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        574 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X