Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NinjaTrade Draw object ill-behavior?

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

    NinjaTrade Draw object ill-behavior?

    I don't know how much support you can give regarding custom indicators, but I'm seeing something here that does not look right.....

    Steps to reproduce:
    1) Create 1 Min ES Chart with multiple days of data.
    2) Set Session Start Time = 9AM and Session Stop Time = 3:15PM
    3) Apply below custome indicator.
    4) PreviousDaysOHLC Lines will draw on chart.
    5) Uncomment DrawText() functions.
    6) Lines no longer draw but text does.

    Expected Results:
    With DrawText() uncommented, should get Lines and Text.

    Other Indicator Problem:

    This indicator should simply Draw the previous days OHLC lines on the chart for the current day, re-drawing each BarUpdate to include the current bar. (This functionality is required for further development even though one can do this much simpler). What you appear to get is todays OHLC plotted today and yesterday. If someone can spot whats wrong it would be appreciated because I'm converting from TS and the high level logic matches. Is this a NT bug?

    Here is the indicator:
    Attached Files

    #2
    Hi bienduga,

    From a quick look at the code, please use unique tag id's for your Text and Trendlines, if you uncomment the DrawText lines you will modify the Trendlines tags resulting in you only see the text being drawn.

    Comment


      #3
      Thanks, forgot about that... How about the...

      This indicator should simply Draw the previous days OHLC lines on the chart for the current day, re-drawing each BarUpdate to include the current bar. (This functionality is required for further development even though one can do this much simpler). What you appear to get is todays OHLC plotted today and yesterday. If someone can spot whats wrong it would be appreciated because I'm converting from TS and the high level logic matches. Is this a NT bug?
      Did you spot anything with that? As you can see I used the same bars and y valeus for the text and they show where expected. The lines still don't.

      Comment


        #4
        Hi, it may have to do with your use of FirstBarOfSession() - http://www.ninjatrader-support.com/H...OfSession.html

        You only draw the trendlines when it is true...

        Please check also into the CurrentDayOHL indicator - http://www.ninjatrader-support.com/H...entDayOHL.html

        Comment


          #5
          Hi,

          Your not understanding the code. CurrentOHLC() can't be a problem because it is used to draw the text and the text shows up at the right levels and on the right bar. The lines do not.

          Also FirstBarofSession is used to display the text also so that must be working.

          The FirstBarofSession DrawLine() is probably not needed because it would only draw the lines for one bar. This section is used to store the start levels and set a pointer to the start bar of the session. Also the unique tag name is stored for the line. Then at each bar of the session:

          for(i = 0 ; i < Tag.Count - 1; i++)
          {
          BarsAgo[i] = (
          int)BarsAgo[i] + 1;
          }

          The bars array is incremented so I can redraw the line again on this bar via the name tag stored in the name tag array. I'm incrementing the pointer on each bar so I know on what bar the line always starts on. Then finally I re-draw the line extending it by one bar by using Bars.CurrentBar as the endpoint of the line.

          for(i = 0 ; i < Tag.Count - 1; i++)
          {
          switch(i)
          {
          case 0:
          DrawLine((
          string)Tag[i].ToString(),(int)BarsAgo[i],(double)Price[i],Bars.CurrentBar,(double)Price[i],Color.Orange,DashStyle.Solid,2);
          break;
          case 1:
          DrawLine((
          string)Tag[i].ToString(),(int)BarsAgo[i],(double)Price[i],Bars.CurrentBar,(double)Price[i],Color.Blue,DashStyle.Solid,2);
          break;
          case 2:
          DrawLine((
          string)Tag[i].ToString(),(int)BarsAgo[i],(double)Price[i],Bars.CurrentBar,(double)Price[i],Color.Green,DashStyle.Solid,2);
          break;
          case 3:
          DrawLine((
          string)Tag[i].ToString(),(int)BarsAgo[i],(double)Price[i],Bars.CurrentBar,(double)Price[i],Color.Red,DashStyle.Solid,2);
          break;
          }
          }


          Just FYI the three arrays used to store all the lines drawn for the session are cleared at the start of the new session. So the previous session's line tags are lost forever and never touched again. Since the line tags have the date encoded in them you should never ever be drawing lines in multiple sessions. But its happening.

          I'm not seeing anything wrong with the code. What do you see? Is this a NT bug?

          Comment


            #6
            bienduga,

            We just do not have enough bandwidth to go through everyone's code in depth. Unfortunately at the current state you will just have to slowly debug it. If you truly never call prior drawn lines again it is impossible for it to move. There is no bug in that regards. You will need to step through it slowly. Thank you for understanding.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Hi bienduga,

              I think it may be the issue that you reuse the TagID's for the new session - please use Print() to debug those with the help of the output window...

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              580 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              335 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              102 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