Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    BertrandNinjaTrader Customer Service

    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
        BertrandNinjaTrader Customer Service

        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...
              BertrandNinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by kaywai, 09-01-2023, 08:44 PM
              5 responses
              601 views
              0 likes
              Last Post NinjaTrader_Jason  
              Started by xiinteractive, 04-09-2024, 08:08 AM
              6 responses
              22 views
              0 likes
              Last Post xiinteractive  
              Started by Pattontje, Yesterday, 02:10 PM
              2 responses
              18 views
              0 likes
              Last Post Pattontje  
              Started by flybuzz, 04-21-2024, 04:07 PM
              17 responses
              230 views
              0 likes
              Last Post TradingLoss  
              Started by agclub, 04-21-2024, 08:57 PM
              3 responses
              17 views
              0 likes
              Last Post TradingLoss  
              Working...
              X