Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Rays. Lines and bars

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

    Rays. Lines and bars

    Is there a way in ninjascript to see if a bar crossed an angled ray object or line object?

    #2
    Hello ballboy11,

    Thanks for your post.

    The CrossAbove and CrossBelow NinjaScript functions do not allow for comparing a Series or bar against a drawing object.

    I would recommend using the anchor points for the line/ray and then using math to determine when the a cross happens between those data points and the high/low data points of a bar.

    ChartAnchors - https://ninjatrader.com/support/help...hartanchor.htm

    I went used some similar math in my Labeled Lines Drawing Tool extension, so the math there may be helpful for your needs.

    This is an expansion of the the NinjaTrader Lines Drawing Tool(s) that adds text boxes to each line that will show prices associated with the endpoint or where the line crosses the price scale. Vertical lines will show time stamps. Your own messages can be added to each text box. New settings can be set […]


    The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.

    Please let us know if we can be of further assistance.

    Comment


      #3
      Hello gplantis,

      Thanks for your question.

      CrossAbove/CrossBelow have an overload where you can specify an IDataSeries (like Close or Value) to see if it crosses a double.

      Code:
      // Go short if CCI crossed above 250 within the last bar
      if (CrossAbove(CCI(14), 250, 1))
          EnterShort();
      CrossAbove - https://ninjatrader.com/support/help...crossabove.htm

      Let me know if you have any additional questions.

      Comment


        #4
        Hello gplantis,

        I'm not exactly following here. When I test another indicator like an SMA crossing over a numeric value or test Close crossing over a numeric value, I do not have any issue.

        Demo - https://drive.google.com/file/d/1txV...w?usp=drivesdk

        Could you provide an example for what isn't working so I can give my input?

        I look forward to being of further assistance.

        Comment


          #5
          Hello gplatis,

          I'm glad you were able to resolve the issue on your end.

          I've included a screenshot showing the prints.

          If we modify the example to use EnterLong() instead of Print(), we would not be making an Apples to Apples test as there are internal rules that control how the order methods function. The condition could become true, but if we are already in a position and our strategy settings do not allow a new entry, we will see no action. Using Prints would be the sure fire way to check the logic alone.

          Please let us know if there is anything else we can do to assist here.
          Attached Files

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          561 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          325 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          547 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X