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 CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        31 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        21 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        184 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Started by CaptainJack, 04-24-2026, 11:07 PM
        0 responses
        342 views
        0 likes
        Last Post CaptainJack  
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        264 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X