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 Hwop38, 05-04-2026, 07:02 PM
        0 responses
        164 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        318 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        246 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        350 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        179 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Working...
        X