Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Creating a custom draw object that updates itself

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

    Creating a custom draw object that updates itself

    Would it be technically possible to create a drawing object that updates itself? I have no experience with drawing objects, so I was just wondering if this can be done.

    I want to make a line that has some text on it and the text would get updated with the distance (ticks or points) from the current price.

    #2
    Hello NinjaCustomer,
    Thanks for your post.

    A drawing object would not be able to do this on its own. You would need to use the drawing tool inside an indicator and then update the drawing object on each tick.
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      can the indicator "adopt' a manually drawn drawing object? I want to be able to draw the lines manually

      Comment


        #4
        NinjaCustomer,

        That would not be possible. You could check to see if the line was manually drawn or not but thats about it.
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          You can do that by coding a custom drawing tool, then in its OnRender method you'd calculate the distance of the line from the current price, convert to ticks if you want, then draw your text using that value.

          To be more efficient you can calculate the price distance inside your drawing tool's AttachedTo.Instrument.MarketData.Update event, which fires less often than OnRender.
          But on today's systems the performance hit will be nothing for such a simple calculation, so there is really no need.

          I have done something similar with an alert line (see pic). Custom tools appear in the drawing tool menu and can be drawn manually.

          The HorizontalLine tool can be found in the DrawingTools folder inside Lines.cs. From there you can take out the code you need and make your own version.



          Comment


            #6
            great, thanks for the explanation.

            Comment


              #7
              I might just go this way, modify this indicator - it seems to have an interesting concept - it reads existing lines and writes text on the chart

              Labeled Horizontal Lines | NinjaTrader Ecosystem
              https://ninjatraderecosystem.com/use...izontal-lines/

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by yahrhnfhmk, Today, 02:05 AM
              0 responses
              1 view
              0 likes
              Last Post yahrhnfhmk  
              Started by Rebmr2, Today, 01:30 AM
              0 responses
              8 views
              0 likes
              Last Post Rebmr2
              by Rebmr2
               
              Started by Karl Armstrong, Today, 01:13 AM
              0 responses
              5 views
              0 likes
              Last Post Karl Armstrong  
              Started by JustinCross, Yesterday, 09:48 PM
              1 response
              19 views
              0 likes
              Last Post NinjaTrader_Marco  
              Started by levikNT, Today, 12:48 AM
              0 responses
              6 views
              0 likes
              Last Post levikNT
              by levikNT
               
              Working...
              X