• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw Custom OHLC Plots using OnRender

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

    Draw Custom OHLC Plots using OnRender

    Hello,
    I am trying to draw Custom OHLC Plots using OnRender:
    https://gist.github.com/Zz9uk3/4c3f6...7a3ba0a178e395

    For some unknown reason the low and the high point are a bit off from the default drawn OHLC plots by the configured data series. Moreover the left and right tick of open and close are sometimes to small:
    https://i.imgur.com/kFgG7Hp.jpg

    Does anyone know what I am doing wrong here or how I can account for the difference between the default OHLC plots and my plots?


    #2
    Here is a video of the default plot getting bigger as soon as I stretch the horizontal axis:
    https://i.imgur.com/wmH6aZB.gifv

    Comment


      #3
      Hello mrzz93,
      Thanks for your post.

      I do not see anything right off the bat, and I am unable to test the GitHub snippet.

      Can you add some prints and see what values are getting passed in versus what is appearing on the chart?

      JoshNinjaTrader Customer Service

      Comment


        #4
        Hey Josh! Thanks for your reply
        The solution was to first of all acknowledge that if the width is under 1 OnRender wont draw line. So I came up with the following to always keep my plots visible:

        Code:
        float barPixelWidth = (float)chartControl.BarWidth;
        if (barPixelWidth < 1) barPixelWidth = 1;
        Lates on I added the barPixelWidth to the top and low of the points I choose for my lines:

        Code:
        var yHigh = chartScale.GetYByValue(high) - barPixelWidth / 2;
        var yLow = chartScale.GetYByValue(low) + barPixelWidth / 2;
        Now the low and top end of my OHLC candle always aligns perfectly.

        I also monitored the values closely and they were always equal which makes me believe NT also adds a few numbers to the top and bottom of the OHLC bar drawn for the DataSeries.

        Comment


          #5
          mrzz93,

          Happy to help. Thanks for sharing!
          JoshNinjaTrader Customer Service

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by ntbone, Today, 12:05 AM
          0 responses
          7 views
          0 likes
          Last Post ntbone
          by ntbone
           
          Started by cutzpr, Yesterday, 09:33 PM
          1 response
          11 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by hotsalami, Yesterday, 09:02 PM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by Luigio, Yesterday, 04:50 AM
          1 response
          9 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by sidviciousX, 08-17-2019, 06:47 AM
          2 responses
          36 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Working...
          X