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

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.

    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();
        
                }
        
                 
        
         }

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Bobin, 03-12-2024, 08:51 AM
        15 responses
        479 views
        0 likes
        Last Post fiddich
        by fiddich
         
        Started by Skifree, Today, 11:21 AM
        4 responses
        12 views
        0 likes
        Last Post Skifree
        by Skifree
         
        Started by Bogdan097, Today, 03:25 PM
        0 responses
        3 views
        0 likes
        Last Post Bogdan097  
        Started by cmtjoancolmenero, 04-25-2024, 03:58 PM
        25 responses
        127 views
        0 likes
        Last Post cmtjoancolmenero  
        Started by Mupulen, 04-16-2024, 11:26 AM
        1 response
        55 views
        0 likes
        Last Post techbech  
        Working...
        X