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

Triangles and angles

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

    Triangles and angles

    Hi

    Is there any way when creating a triangle from 3 points, overlayed on a chart, that I would be able to calculate the internal angles?

    I can initially think to use the number of bars (x axis) and price (y axis) but obviously these values are not related in any way to each other and therefore any angle produced would not necessarily be accurate.

    Would I be able to get at he length of the lines in pixels or any form of measurement scale?

    Any thoughts appreciated.
    Thanks

    #2
    Hello fishbed,

    Thanks for opening the thread.

    You could use some trigonometry to calculate the angle based off of the slope of each line. You could calculate the slope using the drawing objects anchors. I can think of a couple implications while considering this.

    Using Price levels and bar indexes would keep the slope consistent in a price vs bar index perspective, but would not reveal a true angle in the charts scale.

    Using the pixel coordinates from the anchors to calculate slope will give you a truer angle in relativity to the chart, but the chart's auto scale setting should be noticed when calculating the slope from these anchors. If the charts scale changes, so will the angles. I would advise to override OnCalculateMinMax() and recalculate your slopes there to maintain accurate angles.

    ChartAnchor.GetPoint() - https://ninjatrader.com/support/help...s/getpoint.htm

    DrawObjects (to be referenced for looping through DrawObjects) - https://ninjatrader.com/support/help...rawobjects.htm

    OnCalculateMinMax() - https://ninjatrader.com/support/help...lateminmax.htm

    You can use an inverse tangent to calculate the angle from slope.

    Formulas for calculating the slope of lines or surfaces, plus tables of common slopes used in architecture.




    Please let me know if I may be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      triangle angles

      HI Jim

      Thanks for this, it is given me a lot to ponder and look through.

      Regards

      Comment


        #4
        Rather than Bars or Pixels why not use Price(y) and Time(x) given NT8 has
        better time resolution than NT7.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rdtdale, Today, 01:02 PM
        0 responses
        2 views
        0 likes
        Last Post rdtdale
        by rdtdale
         
        Started by alifarahani, Today, 09:40 AM
        3 responses
        15 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by RookieTrader, Today, 09:37 AM
        4 responses
        18 views
        0 likes
        Last Post RookieTrader  
        Started by PaulMohn, Today, 12:36 PM
        0 responses
        7 views
        0 likes
        Last Post PaulMohn  
        Started by love2code2trade, 04-17-2024, 01:45 PM
        4 responses
        41 views
        0 likes
        Last Post love2code2trade  
        Working...
        X