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

Price crossover my line

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

    Price crossover my line

    Hi , I will draw Lines and Channels from my Indicator. I want to take action when prices cross-over the line. I also want to calculate the price difference between current bar Low/High and my Line. What are the support available in Ninja Script? Kindly guide me.

    #2
    Hello nandhumca,

    Thank you for your post.

    You will need to calculate what value the line has at that particular bar and then compare the current price and bar low/high to that. The YAxisProjectionOfLine script my colleague Paul created at the link I also provided on your other post will demonstrate how you can calculate the price of a line at a specific bar:

    https://ninjatrader.com/support/forum/forum/ninjatrader-8/add-on-development/107312-price-crossing-a-line#post828663

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Thanks Kate. I will explore.

      Comment


        #4
        Hi Kate, I have used the sample code you shared to draw line from indicator. When I draw line from Y1 to Y2, the line is going into center of the Bar (marked in blue line in circle of attached image). But I want to draw the line on the Edge of the bar (marked in yellow line in circle attached. Kindly guide me how set the Y2 as edge of the bar.
        Attached Files

        Comment


          #5
          Hello nandhumca,

          Thank you for your reply.

          That's a bit tricky, you'd need to calculate exactly at what price the yellow line crosses the center of the bar and use that as your Y2 value instead of what you're using for the blue line, there wouldn't be a way to just snap the blue line to the corner of the bar.

          Please let us know if we may be of further assistance to you.
          Kate W.NinjaTrader Customer Service

          Comment


            #6
            Hi Kate, I am looking for the logic or the value needs to be adjusted to find the Y2 for the Yellow line touching the edge of the bar.

            Comment


              #7
              Hello nandhumca,

              Thank you for your reply.

              The problem is that you can't tell it to just snap to that corner of the bar since that corner's between time slots for the bar.

              You would have to modify the calculations to move the line to a different slope to do that, and I don't really have any exact guidance for that as I don't know what calculations you're using to place the line in the first place.

              Please let us know if we may be of further assistance to you.
              Kate W.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by timmbbo, Today, 08:59 AM
              0 responses
              1 view
              0 likes
              Last Post timmbbo
              by timmbbo
               
              Started by bmartz, 03-12-2024, 06:12 AM
              5 responses
              33 views
              0 likes
              Last Post NinjaTrader_Zachary  
              Started by Aviram Y, Today, 05:29 AM
              4 responses
              13 views
              0 likes
              Last Post Aviram Y  
              Started by algospoke, 04-17-2024, 06:40 PM
              3 responses
              28 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by gentlebenthebear, Today, 01:30 AM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X