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 GussJ, 03-04-2020, 03:11 PM
        16 responses
        3,281 views
        0 likes
        Last Post Leafcutter  
        Started by WHICKED, Today, 12:45 PM
        2 responses
        19 views
        0 likes
        Last Post WHICKED
        by WHICKED
         
        Started by Tim-c, Today, 02:10 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Taddypole, Today, 02:47 PM
        0 responses
        5 views
        0 likes
        Last Post Taddypole  
        Started by chbruno, 04-24-2024, 04:10 PM
        4 responses
        53 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Working...
        X