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 slimcactus, Today, 10:26 AM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by Monares, Today, 10:49 AM
              3 responses
              16 views
              0 likes
              Last Post NinjaTrader_JustinD  
              Started by d122y, Today, 10:20 AM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_ChrisL  
              Started by trader3000a, Today, 06:41 AM
              1 response
              14 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Started by trader3000a, Today, 09:23 AM
              5 responses
              19 views
              0 likes
              Last Post trader3000a  
              Working...
              X