Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Trouble with Draw.Line()

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

    Trouble with Draw.Line()

    Hi there, I am trying to draw a line on my chart from one point to another with known bars ago and prices. Inside of OnBarUpdate() I have the following:
    Print("aBar, aPrice: " + a.idx + ", " + a.High);
    Print("aBar, bPrice: " + b.idx + ", " + b.Low);
    Draw.Text(this, "APoint", "A", a.idx, a.High);
    Draw.Line(this, "AB", a.idx, a.High, b.idx, b.Low, Brushes.White);

    The first two Print() statements confirm that my variables are holding the expected values. Neither the Draw.Text() nor the Draw.Line() statements I'm using above draw anything on my chart. My chart is black, so the white should show up.

    What am I missing? I have a suspicion that I need to AddLine or something like that in OnStateChange(), but when I go down that path, it seems that you're just adding a line of some mostly constant value. I need to draw a line between two points as those points are calculated. If I could get some complete examples of Draw.Line() (including any syntax that may be required in OnStateChange()) then that would be fantastic.

    Thank you so much for your help in advance.

    Nate.

    #2
    Hello NateG0310,

    Welcome to the NinjaTrader forums!

    Have you checked the DrawingObjects window or looped through DrawObjects to confirm the objects are not being drawn?



    Is the script experiencing an error on the Log tab of the Control Center?

    What prints from your prints?

    Note, that as you are not using unique tag names, only one object will be drawn and then updated.
    https://ninjatrader.com/support/foru...630#post838630
    Last edited by NinjaTrader_ChelseaB; 04-25-2021, 08:04 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      ChelseaB,
      Thank you so much for your reply. We're making progress here, and I have you to thank! I have since added " + CurrentBar" to my tags and I am now able to find the lines listed in my Drawing Tools > Drawing Objects pane. So, we're close, but no yet exactly where I need to be...

      I want the lines to plot on the chart, over the candles, they are plotting in a separate pane below my chart (see attached Screenshot). Can you point me in the right direction so I can better understand how to instruct my indicator to draw the lines on my chart? Thank you!
      Attached Files

      Comment


        #4
        Chelsea,
        I seem to have figured it out. In my if (State == State.SetDefaults) {} section, I made sure to set IsOverlay = true and DrawOnPricePanel = true and that did the trick. Thank you for pointing me down the right path, I should be good for now

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        63 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        90 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        47 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        105 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        63 views
        0 likes
        Last Post PaulMohn  
        Working...
        X