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

Plot Height (pixels to ticks)

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

    Plot Height (pixels to ticks)

    I am plotting in the price panel and that works fine. Is there any way so I can plot a number of ticks thick rather than pixels.

    Maybe better question is can I convert plot pixels to ticks?

    Cheers

    #2
    Remember that how many pixels per tick or ticks per pixel is a function of the scale - you can drag the price axis scale to expand or compress it, and these change dynamically as the chart is re-rendered.

    So, if you're doing this as a plot thickness, then no, the best you could do is estimate what thickness would be required at the current zoom level, but that's not a good idea.

    If, on the other hand, you're doing it manually in OnRender, you can determine how many pixels there are per tick by using the function chartScale.GetYByValue() and just comparing the Y value in pixels for some price with the Y value of that price plus or minus a tick - the difference in pixels is the height of a tick in pixels. But understand, you could easily zoom out to where there are multiple ticks per pixel so that the difference, or number of pixels per tick, might be zero. You could get the height of a tick in fractional pixels by comparing the GetYByValue for a price with the GetYByValue for that price + 1000 * TickSize, then convert the two answers to float or double, and subtract that instead and divide by 1000.

    I think, though, that this is probably too technical of an answer - the better answer might be, no, don't do it that way unless you're shading a region, and then that's not a plot but something like a rectangle.
    Last edited by QuantKey_Bruce; 03-11-2023, 03:16 PM.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      QuantKey_Bruce

      Many thanks. I was a developer for most of my life so understand the implications of what you have said.

      You are an absolute star!

      Cheers

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by rhyminkevin, Today, 04:58 PM
      4 responses
      52 views
      0 likes
      Last Post dp8282
      by dp8282
       
      Started by iceman2018, Today, 05:07 PM
      0 responses
      5 views
      0 likes
      Last Post iceman2018  
      Started by lightsun47, Today, 03:51 PM
      0 responses
      7 views
      0 likes
      Last Post lightsun47  
      Started by 00nevest, Today, 02:27 PM
      1 response
      14 views
      0 likes
      Last Post 00nevest  
      Started by futtrader, 04-21-2024, 01:50 AM
      4 responses
      50 views
      0 likes
      Last Post futtrader  
      Working...
      X