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

DrawRay, DrawLine as dash or dot.

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

    DrawRay, DrawLine as dash or dot.

    I'm probably missing something obvious here but I can't figure it out. NT 64-bit 7.0.1000.1

    I have an indicator with the following line of code that works fine:

    DrawRay("hTrade" + ctr.ToString(), false, 1, Low[1] - 1 * TickSize, 1, 0.0, Color.DarkGreen, DashStyle.Solid, 3);

    It draws a vertical solid ray from one ticksize below the low of the previous bar down through 0.0. It works fine and fast.

    If all I do is change the DashStyle to dot or dash it will eventually draw the dotted or dashed line but very slowly. It slows down my whole computer and all 4 cores keep running at a high % even after the lines are drawn. An example of the offending code (exactly the same except for different DashStyle) is:

    DrawRay("hTrade" + ctr.ToString(), false, 1, Low[1] - 1 * TickSize, 1, 0.0, Color.DarkGreen, DashStyle.Dot, 3);

    I'm also seeing the same thing with DrawLine(). DashStyle.Solid works great. DashStyle Dot or Dash slows down my machine and continues to load all 4 cores.

    Am I missing something obvious?
    Last edited by higler; 12-18-2010, 01:20 PM.

    #2
    higler, there should not be a performance issue by changing the draw style. Could you perhaps share the code with us so we can test it out?
    AustinNinjaTrader Customer Service

    Comment


      #3
      I'll get back to you after the market opens on Monday. I'm trying to pin down the exact conditions when it happens so that either you can reproduce it or I see where my error is. Thanks.

      Comment


        #4
        higler, thank you for the update.
        AustinNinjaTrader Customer Service

        Comment


          #5
          Based upon my testing, DrawRay() with a DashStyle.Dot consumes about 3 to 4 times CPU resources than with DashStyle.Solid. Here's what I did:

          1. Create a new 1 minute chart of YM 03-11 with a Session Template of default 24/7

          2. Create an indicator that overlays on price and includes the following code (there's nothing special about this code except it needs to draw plenty of rays so that you can see the difference in CPU load between the DashStyles) For my example code you will also need to create a private int rayCtr = 0 variable to keep track of the rays:

          if (Stochastics(Input, 7, 14, 3).K[0] < Stochastics(Input, 7, 14, 3).D[0])
          {
          DrawRay("ray" + rayCtr.ToString(), false, 0, Low[0] - TickSize, 0, 0.0, Color.Firebrick, DashStyle.Solid, 5);
          rayCtr++;
          }
          else if (Stochastics(Input, 7, 14, 3).K[0] > Stochastics(Input, 7, 14, 3).D[0])
          {
          DrawRay("ray" + rayCtr.ToString(), false, 0, Low[0] - TickSize, 0, 0.0, Color.Blue, DashStyle.Solid, 5);
          rayCtr++;
          }

          3. Apply only this indicator to the chart. My CPU load with the DashStyle.Solid reads ~ 5% - 7%

          4. Now modify the indicator code so that in the two DrawRay methods the DashStyle is now DashStyle.Dot. Compile the indicator and apply the modified indicator to the chart.

          5. My CPU load with the DashStyle.Dot reads ~ 26% - 35%.

          On my computer, using the DashStyle.Dot vs DashStyle.Solid in the DrawRay() and some other draw methods seems to consume anywhere from 3 to 4 times the computer CPU resources.

          Thanks.

          These results are with NT 64 bit. I don't have any results with other versions.
          Last edited by higler; 12-20-2010, 10:41 AM. Reason: Additional Info

          Comment


            #6
            Thanks. We will take a look.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Thanks. Actually, it's not that big a deal for me but I thought I would mention it. I was using DrawRay to mark certain inflection points on my charts because it was more visually obvious to me than DrawArrowUp/Down. I just happened to notice that sometimes things could get pretty slow if I use DashStyle.Dot. I can use the DrawArrowUp/Down method instead without any performance hit and I'm sure that DrawRay must have a lot more overhead. It's probably a case of me using a sledgehammer to push in a thumbtack. I should probably reserve DrawRay, etc. more for what they were designed for.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by GussJ, 03-04-2020, 03:11 PM
              11 responses
              3,229 views
              0 likes
              Last Post xiinteractive  
              Started by andrewtrades, Today, 04:57 PM
              1 response
              14 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by chbruno, Today, 04:10 PM
              0 responses
              7 views
              0 likes
              Last Post chbruno
              by chbruno
               
              Started by josh18955, 03-25-2023, 11:16 AM
              6 responses
              441 views
              0 likes
              Last Post Delerium  
              Started by FAQtrader, Today, 03:35 PM
              0 responses
              12 views
              0 likes
              Last Post FAQtrader  
              Working...
              X