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 TraderBCL, Today, 04:38 AM
              2 responses
              16 views
              0 likes
              Last Post TraderBCL  
              Started by martin70, 03-24-2023, 04:58 AM
              14 responses
              106 views
              0 likes
              Last Post martin70  
              Started by Radano, 06-10-2021, 01:40 AM
              19 responses
              609 views
              0 likes
              Last Post Radano
              by Radano
               
              Started by KenneGaray, Today, 03:48 AM
              0 responses
              5 views
              0 likes
              Last Post KenneGaray  
              Started by thanajo, 05-04-2021, 02:11 AM
              4 responses
              471 views
              0 likes
              Last Post tradingnasdaqprueba  
              Working...
              X