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

Expiring drawn objects as chart progresses

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

    Expiring drawn objects as chart progresses

    I have an issue with drawn items accumulating on my chart. My indicator is actually coded to only show the current support/resistance lines within the last five candles - see enclosed image. Unfortunately once the lines are drawn they remain and I can't manually reload the chart all the time, especially on my 5-min panels.

    Is there a way to actually remove drawn lines - or is there a way to programmatically reload the chart ever so often?

    Many thanks in advance.

    Molecool
    Attached Files

    #2
    Hello,


    Thank you for your note.



    Can you post the code you use for the DrawLine() method you are using.


    I look forward to assisting you further.

    Comment


      #3
      Here you go - this is how I draw the sell line for instance:

      DrawLine("Net-Line-Sell" + CurrentBar, true, 0, lowPrice, - (expireNL), lowPrice, sellColor, DashStyle.Dot, 2);
      Last edited by molecool; 08-29-2011, 01:12 PM.

      Comment


        #4
        Hello,

        Ok thanks for that.

        Try taking the +CurrentBar out of the name. This way it will replace the line isntead of draw a new one.

        Let me know if I can be of further assistance.

        Comment


          #5
          Oh I get - that makes total sense. Thanks! Will make the change and let you know if it updates properly now.

          Comment


            #6
            Okay, now I have a similar problem with candle outlines. This is how I set it:

            CandleOutlineColor = Color.Blue;

            Pretty simple - but no matter what I do I can't set them back once the next candle is set to blue. I'm using this to mark support line breaches (see image in my initial post).

            Comment


              #7
              Hello,

              You will want to use the candle outline series in this case to pinpoint which one you want to change the color for.



              Let me know if I can be of further assistance.

              Comment


                #8
                Thanks for your suggestions - I think I get where this is going. But if I set a candle to blue via:

                CandleOutlineColorSeries[0] = Color.Blue

                ... then I am pretty sure it'll stick around until the chart gets reloaded since the color is only set once. At some point every candle is the first candle (zero index) as you know.

                What I am trying to do is to keep the candle blue for a five candle period (see my chart), assuming it breached that little trend line. I was able to retire the trend lines and labels by naming then identically but I don't think the same concept applies to candle colors.

                Hope all this makes sense - please let me know if you can think of a solution.

                Originally posted by NinjaTrader_Brett View Post
                Hello,

                You will want to use the candle outline series in this case to pinpoint which one you want to change the color for.



                Let me know if I can be of further assistance.

                Comment


                  #9
                  Hi molecool,

                  If you conditionally set CandleOutlineColor, it only changes color for the bar you're evaluating. It should not color all bars going forward from the first time it's true. To check this, use the following snippet on a daily chart. It should only color Wednesdays. Use it with no other color changing scripts applied to same chart.

                  if (Time[0].DayOfWeek == DayOfWeek.Wednesday)
                  {
                  CandleOutlineColor = Color.Blue;
                  }
                  Ryan M.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by ScottWalsh, 04-16-2024, 04:29 PM
                  7 responses
                  34 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Started by cls71, Today, 04:45 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post cls71
                  by cls71
                   
                  Started by mjairg, 07-20-2023, 11:57 PM
                  3 responses
                  214 views
                  1 like
                  Last Post PaulMohn  
                  Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                  4 responses
                  546 views
                  0 likes
                  Last Post PaulMohn  
                  Started by GLFX005, Today, 03:23 AM
                  0 responses
                  3 views
                  0 likes
                  Last Post GLFX005
                  by GLFX005
                   
                  Working...
                  X