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

drawing line

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

    drawing line

    Hello, I wanted to check on potential scaling issues in drawing an angled line in an indicator

    So the line is rendering all ok and the angle is 45 degree. The calculation uses sin cos from the radian value

    When i shift the x axis left or right OR hold left mouse down and adjust the bar widths - it adjusts the bars that were previously connected.
    Im experimenting with my own PNF style bars not the ninja ones.

    the Y is calculated chartScale.GetYByValue using this and then adjusting up or down with the pixel calculation.
    Pixel wise i assume the X and Y are different scales ? so moving the x axis in one of the above 2 ways is having this effect

    if i use just the standard line draw tool and do the same - it retains the Y points where the line connects. But this is not being drawn based on an angle

    Is there a way to preserve the Y points of the bars drawing an angled line ? I have also tried the Y scale properties to see if fixed would work but that doesnt seem to help
    and logarithmic is more for longer date range charts.

    Any pointers on working with the scaling - i have been through the help on this and scaling but nothing seems to answer this ? otherwise it is going to be a case of subjectively aligning the bars with the angled line and having to adjust the X axis (and bar widths) as more live bars come into view.

    update : looking at chart again as i scroll right and as history bars come into view i guess the max min on Y adjusts ie as lower & higher prices come into the chart render view - i presume this then adjusts the pixel range between price points ? Is there a way to calculate / retrieve the distance between the highest and lowest? From what i can see the price chart panel Y axis remains a fixed number of pixels?

    thanks
    Last edited by explorer101; 07-29-2019, 05:10 AM.

    #2
    hello explorer101

    Pixel wise i assume the X and Y are different scales ?
    Correct however as you noted they are linked by the actions you complete in the chart. The Y scale can change depending on what data the X scale is including.

    Is there a way to preserve the Y points of the bars drawing an angled line ?
    Not specifically, if you are calculating the value the Y on the chart will depend on the settings of the current chart. There would not be a static Y value you could save which would represent that point for all scale settings, this depends on the current compression of the Y scale as to what the Y will be when converted.


    update : looking at chart again as i scroll right and as history bars come into view i guess the max min on Y adjusts ie as lower & higher prices come into the chart render view - i presume this then adjusts the pixel range between price points ? Is there a way to calculate / retrieve the distance between the highest and lowest? From what i can see the price chart panel Y axis remains a fixed number of pixels?
    Correct, the chart will adjust for the new minimum/maximum values as you move it. If you are in an indicator, you can observe when this happens using the OnCalculateMinMax override.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Are you saying in effect there is no easy way to accomplish this. As i observed with the standard line tool it is connecting price points with a start xy and end xy
      What i can see would be a way to work with this and scaling ... once my adjustments to the X and with whatever bars are in view low high etc on chart. I could snapshot
      the current x Y of the calculated endpoint Y with the angle - and convert it to the Y price value (ie not pixel) and then use this to draw the line endpoint ?
      Just an idea but if i can manage this in the indicator i have a way of getting the Y price that currently represents the angle of my line ?

      Comment


        #4
        Hello explorer101,

        There is nothing pre made for what you described if that is what you are asking, you would need to form logic which creates the effect you are looking for. What you have described may be one way to approach the goal, storing the Y values specifically would be irrelevant if the scale changes so you may instead need to use other means to calculate the Y point such as calculating the Y from a price. Really all I could say here would be that the y can be variable depending on the scale, the Y will change if the price on the chart is in a different Y position due to scaling. Solutions may include options like you described such as storing the price instead of y, that could be used to generate a new Y value when needed which would reflect the current scale.

        I look forward to being of further assistance.





        JesseNinjaTrader Customer Service

        Comment


          #5
          thanks for confirming my logic idea - i think this will work for what i want to achieve here and store the Y Price and then convert to the chart Y pixel value.
          thanks for help and clarifying ; i just wanted to see i was on right track based on the scaling considerations i need to be aware of

          Comment


            #6
            If a line is drawn at 45 degrees mathematically (ex. 45 bars x 45 ticks), it will always be 45 degrees, no matter how it looks visually. The only way to see the line at the actual angle would be to square up the chart visually. Here is an example of a tool that squares the chart, to demonstrate what I am explaining here: IT_ChartSquare
            eDanny
            NinjaTrader Ecosystem Vendor - Integrity Traders

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by alifarahani, Today, 09:40 AM
            2 responses
            12 views
            0 likes
            Last Post alifarahani  
            Started by junkone, Today, 11:37 AM
            3 responses
            15 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by pickmyonlineclass, Today, 12:23 PM
            0 responses
            1 view
            0 likes
            Last Post pickmyonlineclass  
            Started by frankthearm, Yesterday, 09:08 AM
            12 responses
            44 views
            0 likes
            Last Post NinjaTrader_Clayton  
            Started by quantismo, 04-17-2024, 05:13 PM
            5 responses
            35 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X