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

Custom drawing tool development

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

    Custom drawing tool development

    Hello, I want to create custom drawing tool. I want to click into chart and in the point where I click I want to draw line "0" which is middle line. Then I want to draw 5 lines on top of the middle line in distance +2, +5, +10, +15, +20 ticks from the middle line. Then I want to draw 5 lines underneath the middle line in distance -2, -5, -10, -15, -20 ticks from the middle line. I have managed to do it by copying Line drawing tool but the scaling seems off. Please see attached picture. Lines are on are which seems to be 6 ticks measured by another tool. I calculate y coordinate of the lines by taking y coordinate of the middle line and then adding in loop 2, 5, 10. I divide the values 2, 5, 10 by current tick size. I have also attached my code. Could you please help me? Thanks in advance

    Attached Files

    #2
    Hello 09try,

    While our support is not able to assist with custom calculations or custom logic, I can help guide you in the right direction.

    Are you adding / subtracting these values from a price value or a pixel value?
    Meaning are you getting the price of the anchor and adding 2?
    Or you getting an x or y pixel value and adding 2 pixels?

    Are you printing the price values before and after the custom calculation to ensure these are the expected values?


    May I have you provide that print output saved to a text file?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hello Chelsea, thanks for quick reply. I take the middle point as Point startPoint = StartAnchor.GetPoint(chartControl, panel, chartScale); and then add 2 / tickSize, 5 / tickSize and so on... Here is Print output

      2 Y 148.5
      5 Y 136.5
      10 Y 116.5
      15 Y 96.5
      20 Y 76.5
      0 Y 156.5
      -2 Y 164.5
      -5 Y 176.5
      -10 Y 196.5
      -15 Y 216.5
      -20 Y 236.5​

      tickSize is 0.25. 0 is middle line Y value. 2 Y is Y value of "2" = 156.5 - 2 / 0.25 = 148.5
      Last edited by 09try; 02-22-2024, 01:41 PM.

      Comment


        #4
        Hello 09try,

        GetPoint() would return an x/y coordinate and not a price.

        Adding ticks to an x/y coordinate value doesn't make sense as TickSize is related to price and x/y coordinates do not relate to a price.

        I think you need the StartAnchor.Price to add ticks to the price, and then convert the price to an x or y coordinate value.

        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello Chelsea, thanks for precise advice. It looks okay now. Here is Print output

          clicked price 2360.14044306497
          Positive lines
          d = 2
          price - d = 2358.14044306497
          GetYByValue(price - d) = 329
          d = 5
          price - d = 2355.14044306497
          GetYByValue(price - d) = 355
          d = 10
          price - d = 2350.14044306497
          GetYByValue(price - d) = 397
          d = 15
          price - d = 2345.14044306497
          GetYByValue(price - d) = 440
          d = 20
          price - d = 2340.14044306497
          GetYByValue(price - d) = 483
          Middle line
          0 Y 312
          Negative lines
          d = -2
          price - d = 2362.14044306497
          GetYByValue(price - d) = 295
          d = -5
          price - d = 2365.14044306497
          GetYByValue(price - d) = 269
          d = -10
          price - d = 2370.14044306497
          GetYByValue(price - d) = 227
          d = -15
          price - d = 2375.14044306497
          GetYByValue(price - d) = 184
          d = -20
          price - d = 2380.14044306497
          GetYByValue(price - d) = 141​

          and measured
          Attached Files

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by ageeholdings, Today, 07:43 AM
          0 responses
          7 views
          0 likes
          Last Post ageeholdings  
          Started by pibrew, Today, 06:37 AM
          0 responses
          4 views
          0 likes
          Last Post pibrew
          by pibrew
           
          Started by rbeckmann05, Yesterday, 06:48 PM
          1 response
          14 views
          0 likes
          Last Post bltdavid  
          Started by llanqui, Today, 03:53 AM
          0 responses
          6 views
          0 likes
          Last Post llanqui
          by llanqui
           
          Started by burtoninlondon, Today, 12:38 AM
          0 responses
          12 views
          0 likes
          Last Post burtoninlondon  
          Working...
          X