Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Bug: NT not drawing lines

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

    Bug: NT not drawing lines

    I have an indicator which draws horizontal lines. I'm using DrawLine(...) to draw these horizontal lines because they are only valid within a month.

    This works fine on higher time frames, but on lower time frames (like 5 minutes) Ninja Trader sometimes forgets to draw these lines when scrolling on the time axis.


    Take a look at the screenshots:

    The first pic shows the chart including the line.

    The second pic shows the same chart, but I scrolled a little bit to the right. The line is not there any more!
    Attached Files

    #2
    Hi Currywurst,

    I'd like to try this on my end as well, can you please provide the code snippet you used to create the lines?
    TimNinjaTrader Customer Service

    Comment


      #3
      I attached a sample code.

      Use this code on $GBPUSD (Gain).

      It draws a line from 2010/6/1 to 2010/7/1 at 1.5101 .

      Works fine in zoomed out 60 min chart

      But using the 5 min chart the line disappears if you scroll to the left.
      Attached Files

      Comment


        #4
        Hi Currywurst,

        I will try this on my end.

        In the meantime, what version are you using? (Help>About)
        TimNinjaTrader Customer Service

        Comment


          #5
          it's the latest.....18

          Comment


            #6
            Hi Currywurst,

            I see, I get the same results. I will submit this to our development team to find if this is expected behavior or if is it something that needs to be addressed.

            Have you tried perhaps using a plot instead? Giving it a time filter for the plot set?
            TimNinjaTrader Customer Service

            Comment


              #7
              Thanks for the advice. But I think using DrawLine is the right way to do it.

              It seems to be some kind of clipping problem - NT thinks the line is off screen and does not draw it but in fact it is on screen.

              Comment


                #8
                Why doesn't NinjaTrader 7 draws a line with the following code?

                Code:
                [FONT=Consolas][SIZE=2][COLOR=#f3f3f3][FONT=Consolas][SIZE=2][COLOR=#f3f3f3][FONT=Consolas][SIZE=2][COLOR=#f3f3f3]
                [COLOR=black][SIZE=3]DrawLine[B]([/B][/SIZE][/COLOR][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][COLOR=black][SIZE=3][FONT=Consolas][FONT=Consolas][FONT=Consolas]"Ema signal line"[/FONT][/FONT][/FONT][B][FONT=Consolas][FONT=Consolas][FONT=Consolas] [/FONT][/FONT][/FONT][/B][FONT=Consolas][FONT=Consolas][FONT=Consolas]+CurrentBar[B], [/B][/FONT][/FONT][/FONT][/SIZE][/COLOR][COLOR=black][SIZE=3][FONT=Consolas][FONT=Consolas][FONT=Consolas]true[/FONT][/FONT][/FONT][B][FONT=Consolas][FONT=Consolas][FONT=Consolas], [/FONT][/FONT][/FONT][/B][FONT=Consolas][FONT=Consolas][FONT=Consolas]30[B], [/B]3000[B], [/B]0[B], [/B]3000[B], [/B][/FONT][/FONT][/FONT][/SIZE][/COLOR][COLOR=black][SIZE=3][FONT=Consolas][FONT=Consolas][FONT=Consolas]Color[/FONT][/FONT][/FONT][FONT=Consolas][FONT=Consolas][FONT=Consolas].Red[B], [/B][/FONT][/FONT][/FONT][FONT=Consolas][FONT=Consolas][FONT=Consolas]DashStyle[/FONT][/FONT][/FONT][/SIZE][/COLOR][FONT=Consolas][FONT=Consolas][FONT=Consolas][SIZE=3][COLOR=black].DashDot[B], [/B]2[/COLOR][/SIZE][B][SIZE=3][COLOR=black]);[/COLOR][/SIZE]
                [/B][/FONT][/FONT][/FONT][SIZE=3][COLOR=black][/COLOR][/SIZE]

                If I substitute the 30 for -30 (minus 30), then the line get drawn, but only in the future prices. However, I try to draw a line starting 30 bars back and stopping at the currentbar.

                Anyone can help me out?

                Regards,

                Comment


                  #9
                  Hi J_o_s,

                  Is this in an indicator or strategy?
                  Are you getting any errors in the Log tab of the Control Center?
                  TimNinjaTrader Customer Service

                  Comment


                    #10
                    >> SOLVED
                    Originally posted by NinjaTrader_Tim View Post
                    Hi J_o_s,

                    Is this in an indicator or strategy?
                    Are you getting any errors in the Log tab of the Control Center?
                    Hi NinjaTrader Tim,

                    Thanks for your quick response. This is for an custom indicator, which gives an signal if the EMA crosses a (manually entered) level. With the DrawLine() function I would like to visually show where this entered level is (for example at 3.000 index points).

                    The error log shows the following rather cryptical error:
                    Code:
                    Error on calling 'OnBarUpdate' method for indicator 'EmailAlert' on bar 0: EmailAlert.DrawLine: startBarsAgo out of valid range 0 through 0, was 30.
                    That wierd line got me thinking, and with some trail-and-error got it to work.

                    Here's how I changed the code to work correctly:
                    Code:
                    [COLOR=black][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]if[/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][B][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2] ([/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][/B][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]CurrentBar<15[/SIZE][/FONT][B][COLOR=black])[/COLOR][/B]
                    [B][COLOR=black]{[/COLOR][/B]
                    [/SIZE][/FONT][/SIZE][/FONT][/COLOR][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][COLOR=black]return[/COLOR][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][B][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][COLOR=black];[/COLOR][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][/B][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]
                    [B][SIZE=2][FONT=Consolas][COLOR=black]}[/COLOR][/FONT][/SIZE][/B]
                    [/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][COLOR=black]else[/COLOR][/SIZE][/FONT]
                    [/SIZE][/FONT][/SIZE][/FONT][B][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][COLOR=black]{[/COLOR][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][/B][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]
                    [SIZE=2][FONT=Consolas][COLOR=black]DrawLine[B]([/B][/COLOR][/FONT][/SIZE][/SIZE][/FONT][/SIZE][/FONT][COLOR=black][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]"Ema signal line"[/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][B][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][/B][/COLOR][COLOR=black][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]true[/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][B][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2], [/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][/B][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]15[B], [/B]3000[B], [/B]0[B], [/B]3000[B], [/B][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][/COLOR][COLOR=black][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]Color[/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2].Red[B], [/B][/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2][FONT=Consolas][SIZE=2]DashStyle[/SIZE][/FONT][/SIZE][/FONT][/SIZE][/FONT][/COLOR][FONT=Consolas][SIZE=2][COLOR=#f3f3f3][FONT=Consolas][SIZE=2][COLOR=#f3f3f3][FONT=Consolas][SIZE=2][COLOR=#f3f3f3][COLOR=black].DashDot[B], [/B]2[/COLOR][B][COLOR=black]);[/COLOR][/B][/COLOR][/SIZE][/FONT][COLOR=#f3f3f3]
                    [B][SIZE=2][FONT=Consolas][COLOR=black]}[/COLOR][/FONT][/SIZE][/B]
                    [/COLOR][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
                    In hindsight I made two "duh"-errors on my part:
                    - I didn't check for the CurrentBar function,
                    - I included the CurrentBar() function in the DrawLine(), which resulted in numerous unique lines, which gave the ilussion there was one long line plotted.

                    Thanks for pointing me in the right direction Tim,

                    Regards,

                    Comment


                      #11
                      Hi J_o_s,

                      Nice debugging, glad to hear you're up and running now!
                      TimNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      581 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      338 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      103 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      554 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      552 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X