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

GetYByValue returns distinct pixels between prices

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

    GetYByValue returns distinct pixels between prices

    Hello,

    I'm doing an indicator that use the function GetYByValue and I don't understand the values than it returns because sometimes increments 1 pixel. With an example better:
    I have TickSize of 0.25
    If I call this function for some prices, the results (for example) are:
    GetYByValue(1700.00) returns 100
    GetYByValue(1700.25) returns 120
    I say ok, the distance between ticksize's is 20 pixels, but ...
    GetYByValue(1700.50) returns 140
    GetYByValue(1700.75) returns 160
    GetYByValue(1701.00) returns 180
    GetYByValue(1701.25) returns 201 ---> Why the distance now is 21???
    GetYByValue(1701.50) returns 221 -> Now is 20 pixel of distance again

    The problem is the indicator, the properties of Chart, ...?

    Thanks
    Last edited by ninejavi; 01-12-2018, 04:52 AM.

    #2
    Hello ninejavi,

    Thank you for your note.

    It looks like this is due to rounding.

    I used the following code to test, which gave an output in the screen shot.

    Code:
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
    		 
    		int     yByValue = chartScale.GetYByValue(2700.00);
    		int     yByValue1 = chartScale.GetYByValue(2700.25);
    		int     yByValue2 = chartScale.GetYByValue(2700.50);
    		int     yByValue3 = chartScale.GetYByValue(2700.75);
    		int     yByValue4 = chartScale.GetYByValue(2701.00);
    		int     yByValue5 = chartScale.GetYByValue(2701.25);
    		int     yByValue6 = chartScale.GetYByValue(2701.50);
    		int     yByValue7 = chartScale.GetYByValue(2701.75);
    		 
    
    		Print(yByValue);
    		Print(yByValue1);
    		Print(yByValue2);
    		Print(yByValue3);
    		Print(yByValue4);
    		Print(yByValue5);
    		Print(yByValue6);
    		Print(yByValue7);
    }
    Please let us know if you need further assistance.
    Attached Files
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Hello NinjaTrader_AlanP, thanks for your answer.

      The problem is because this function retuns pixels than are numbers without decimals?

      I explain what is my problem. I use this function for calculate each price what is its y-position and then drawing a rectangle with the Volume Total on each level price. How each bar sometimes begins 1pixel more than previous, you can see a separation between some bars. I don't like how visually is it.

      How can i do this? Maybe with the function GetYByValueWpf?

      Thanks.

      Comment


        #4
        Hello ninejavi,

        Yes, using GetYByValueWpf would give you the pixel out to the decimal and should resolve the issue.



        Please let us know if you need further assistance.
        Alan P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DJ888, 04-16-2024, 06:09 PM
        4 responses
        12 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Started by terofs, Today, 04:18 PM
        0 responses
        7 views
        0 likes
        Last Post terofs
        by terofs
         
        Started by nandhumca, Today, 03:41 PM
        0 responses
        6 views
        0 likes
        Last Post nandhumca  
        Started by The_Sec, Today, 03:37 PM
        0 responses
        3 views
        0 likes
        Last Post The_Sec
        by The_Sec
         
        Started by GwFutures1988, Today, 02:48 PM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Working...
        X