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

Continue Drawing Line Until Indicator Crosses Above

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

    #16
    Hello 2fr33d0m,

    The issue may be with the line being drawn. Current for the end point of the line you are using conditionBar-CurrentBar. This would likely end up being a negative number and would plot the line forward however many bars forward that it should actually be backward.

    Try changing this:
    DrawLine("Gap" + CurrentBar, false, 2, Low[conditionBar], conditionBar - CurrentBar, Low[conditionBar], Color.DarkRed, DashStyle.Dot, 1);

    To:

    DrawLine("Gap" + CurrentBar, false, 2, Low[conditionBar], CurrentBar-conditionBar, Low[conditionBar], Color.DarkRed, DashStyle.Dot, 1);
    Chelsea B.NinjaTrader Customer Service

    Comment


      #17
      Hello ChelseaB,

      I've tried that, and the lines start where I want, which is the Low of the conditionBar, however, the lines extend to the left, not to the right.

      With "conditionBar - CurrentBar" and High[0] >Low[conditionBar], the lines start at the Low of the conditionBar, and extend to the right, which is closest to what I want to see, except the lines don't stop drawing past the first bar, the high of which is higher than the low of the conditionBar.

      With "conditionBar - CurrentBar" or "CurrentBar - conditionBar" and High[0]>Low[CurrentBar - conditionBar] like you suggested yesterday, most of the lines do not appear at all.

      How can I make the lines stop extending and just see a horizontal line from the low of the conditionBar to the first bar after the conditionBar that makes a high above it?

      Thanks.

      Comment


        #18
        Originally posted by 2fr33d0m View Post
        Hello ChelseaB,

        I've tried that, and the lines start where I want, which is the Low of the conditionBar, however, the lines extend to the left, not to the right.

        With "conditionBar - CurrentBar" and High[0] >Low[conditionBar], the lines start at the Low of the conditionBar, and extend to the right, which is closest to what I want to see, except the lines don't stop drawing past the first bar, the high of which is higher than the low of the conditionBar.

        With "conditionBar - CurrentBar" or "CurrentBar - conditionBar" and High[0]>Low[CurrentBar - conditionBar] like you suggested yesterday, most of the lines do not appear at all.

        How can I make the lines stop extending and just see a horizontal line from the low of the conditionBar to the first bar after the conditionBar that makes a high above it?

        Thanks.
        Code:
        DrawLine("Gap" + CurrentBar, false, CurrentBar-conditionBar, Low[conditionBar], 0, Low[conditionBar], Color.DarkRed, DashStyle.Dot, 1);

        Comment


          #19
          Thanks, koganam.

          I've tried your version, but the lines now start two bars to the right of the conditionBar at the low of the conditionBar and extends to the left.

          I appreciate your help, though.

          Comment


            #20
            Originally posted by 2fr33d0m View Post
            Thanks, koganam.

            I've tried your version, but the lines now start two bars to the right of the conditionBar at the low of the conditionBar and extends to the left.

            I appreciate your help, though.
            That makes no sense. Please show a picture?

            Comment


              #21
              ok. Here's closest to I've ever gotten to the final result, and I get this when I use the code below.

              if (High[0] > Low[conditionBar])
              {
              drawLines = false;
              }

              if (drawLines)
              {
              DrawLine("Gap" + CurrentBar, false, 2, Low[conditionBar], conditionBar-CurrentBar, Low[conditionBar], Color.DarkRed, DashStyle.Dot, 1);
              }
              Attached Files

              Comment


                #22
                Originally posted by 2fr33d0m View Post
                ok. Here's closest to I've ever gotten to the final result, and I get this when I use the code below.

                if (High[0] > Low[conditionBar])
                {
                drawLines = false;
                }

                if (drawLines)
                {
                DrawLine("Gap" + CurrentBar, false, 2, Low[conditionBar], conditionBar-CurrentBar, Low[conditionBar], Color.DarkRed, DashStyle.Dot, 1);
                }
                That is because what you have here is NOT what I wrote. Please read again, or copy and paste.

                Comment


                  #23
                  and here's the picture with koganam's drawLine version.

                  DrawLine("Gap" + CurrentBar, false, CurrentBar-conditionBar, Low[conditionBar], 0, Low[conditionBar], Color.DarkRed, DashStyle.Dot, 1);

                  Now the lines start two bars to the right of the conditionBar at the low of the conditionBar and extend to the left.
                  Attached Files

                  Comment


                    #24
                    The first picture was before I changed the code with koganam's drawLine version

                    Comment


                      #25
                      Originally posted by 2fr33d0m View Post
                      and here's the picture with koganam's drawLine version.

                      DrawLine("Gap" + CurrentBar, false, CurrentBar-conditionBar, Low[conditionBar], 0, Low[conditionBar], Color.DarkRed, DashStyle.Dot, 1);

                      Now the lines start two bars to the right of the conditionBar at the low of the conditionBar and extend to the left.
                      That is definitely not correct. But the issue goes a little deeper than that: I may have misunderstood what you were trying to do, which is why I asked for a picture in the first place. I was under the impression that you wanted to do this for only the last setup that is valid. From what I see, you want to do it for every setup that is valid. In that case, this syntax will simply not be valid as it is, in fact, drawing multiple overlapping lines, not single variable length lines, one to each setup.

                      As I have already inserted myself into this case, please describe a bit more clearly what you want to do, and I will see if I can write it for you. I suspect that we shall almost certainly need a counter to keep track of the lines. I apologize for not fully understanding the situation before getting involved.
                      Last edited by koganam; 12-14-2013, 01:34 PM.

                      Comment


                        #26
                        Originally posted by koganam View Post
                        That is definitely not correct. But the issue goes a little deeper than that: I may have misunderstood what you were trying to do, which is why I asked for a picture in the first place. I was under the impression that you wanted to do this for only the last setup that is valid. From what I see, you want to do it for every setup that is valid. In that case, this syntax will simply not be valid asit is, in fact, drawing multiple overlapping lines, not single variable length lines, one to each setup.

                        As I have already inserted myself into this case, please describe a bit more clearly what you want to do, and I will see if I can write it for you. I suspect that we shall almost certainly need a counter to keep track of the lines. I apologize for not fully understanding the situation before getting involved.
                        That's ok.
                        Let me explain what I'm trying to do.

                        The basic logic is this.
                        1. For every bar (x), see if the next bar (y) makes a low below that of x.
                        2. If yes, then see if the bar after y (z) makes a high that is lower than or equal to
                        the low of x.
                        3. If yes, then draw a horizontal line that starts at the low of x and extends all the way
                        to the right(more like a ray at this point)
                        4. Once any bar after z (a) makes a high higher than the low of x, stop extending the
                        line to the right so that the end result is a horizontal line that starts at the low of x
                        and stops one bar before a.

                        I've attached a picture where I've drawn manually what I'd like this indicator to do automatically. I've numbered and placed a red arrow over each bar (x) that satisfies the conditions above. The numbers and arrows should not be part of this indicator.
                        They are drawn only to highlight the bars that meet the logic.
                        You'll see that, for every numbered bar, there's a dark red horizontal line starting at its low and extending to the right until a bar pokes above it.
                        For bars 1 - 5, the lines stopped extending and paused one bar before the bar that poked above it whereas for bars 6 - 14, the lines are more like rays that extend all the way to the right because no bar has yet to poke above any of them.

                        This is actually about half of what I'd like this indicator to do. The picture I've attached shows only this first half.

                        The other half involves bars e, f, and g where

                        1. For every bar (e), see if the next bar (f) makes a high above that of e.
                        2. If yes, then see if the bar after f (g) makes a low that is higher than or equal to
                        the high of e.
                        3. If yes, then draw a horizontal line that starts at the high of e and extends all the way
                        to the right(more like a horizontal ray at this point)
                        4. Once any bar after g (b) makes a low lower than the high of e, stop extending the
                        line to the right so that the end result is a horizontal line that starts at the high of e
                        and stops one bar before b.

                        It'd be nice to be able to make the lines configurable as well.
                        Do you need any other information?
                        I appreciate your help.

                        Thanks.
                        Attached Files

                        Comment


                          #27
                          Originally posted by 2fr33d0m View Post
                          That's ok.
                          Let me explain what I'm trying to do.

                          The basic logic is this.
                          1. For every bar (x), see if the next bar (y) makes a low below that of x.
                          2. If yes, then see if the bar after y (z) makes a high that is lower than or equal to
                          the low of x.
                          3. If yes, then draw a horizontal line that starts at the low of x and extends all the way
                          to the right(more like a ray at this point)
                          4. Once any bar after z (a) makes a high higher than the low of x, stop extending the
                          line to the right so that the end result is a horizontal line that starts at the low of x
                          and stops one bar before a.

                          I've attached a picture where I've drawn manually what I'd like this indicator to do automatically. I've numbered and placed a red arrow over each bar (x) that satisfies the conditions above. The numbers and arrows should not be part of this indicator.
                          They are drawn only to highlight the bars that meet the logic.
                          You'll see that, for every numbered bar, there's a dark red horizontal line starting at its low and extending to the right until a bar pokes above it.
                          For bars 1 - 5, the lines stopped extending and paused one bar before the bar that poked above it whereas for bars 6 - 14, the lines are more like rays that extend all the way to the right because no bar has yet to poke above any of them.

                          This is actually about half of what I'd like this indicator to do. The picture I've attached shows only this first half.

                          The other half involves bars e, f, and g where

                          1. For every bar (e), see if the next bar (f) makes a high above that of e.
                          2. If yes, then see if the bar after f (g) makes a low that is higher than or equal to
                          the high of e.
                          3. If yes, then draw a horizontal line that starts at the high of e and extends all the way
                          to the right(more like a horizontal ray at this point)
                          4. Once any bar after g (b) makes a low lower than the high of e, stop extending the
                          line to the right so that the end result is a horizontal line that starts at the high of e
                          and stops one bar before b.

                          It'd be nice to be able to make the lines configurable as well.
                          Do you need any other information?
                          I appreciate your help.

                          Thanks.
                          Just as I suspected, that is a whole new kettle of fish, involving tracking or querying an unknown number of existing lines (rays) and modifying them. It will take a while: it is not going to be a quick one, as I have to tackle it only when I have some free cycles.
                          Last edited by koganam; 01-07-2014, 07:06 PM. Reason: Corrected spelling.

                          Comment


                            #28
                            Hi 2fr33d0m,

                            Due to the complicated nature of what you are trying to accomplish, I wanted to mention that you can receive professional help from our NinjaScript Consultant partners.

                            http://www.ninjatrader.com/Ecosystem/NonBroker.php#81
                            Chelsea B.NinjaTrader Customer Service

                            Comment


                              #29
                              Originally posted by koganam View Post
                              Just as I suspected, that is a whole new kettle of dish, involving tracking or querying an unknown number of existing lines (rays) and modifying them. It will take a while: it is not going to be a quick one, as I have to tackle it only when I have some free cycles.
                              I understand. Now I see a ray of hope.
                              I'll check back from time to time.
                              Thanks.

                              Comment


                                #30
                                Originally posted by NinjaTrader_ChelseaB View Post
                                Hi 2fr33d0m,

                                Due to the complicated nature of what you are trying to accomplish, I wanted to mention that you can receive professional help from our NinjaScript Consultant partners.

                                http://www.ninjatrader.com/Ecosystem/NonBroker.php#81
                                Hi ChelseaB,

                                It looks like the code's more complicated than I thought.
                                I'm waiting for koganam's version now, but it's nice to have another option.
                                Thank you for the information.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by gentlebenthebear, Today, 01:30 AM
                                0 responses
                                2 views
                                0 likes
                                Last Post gentlebenthebear  
                                Started by samish18, Yesterday, 08:31 AM
                                2 responses
                                9 views
                                0 likes
                                Last Post elirion
                                by elirion
                                 
                                Started by Mestor, 03-10-2023, 01:50 AM
                                16 responses
                                389 views
                                0 likes
                                Last Post z.franck  
                                Started by rtwave, 04-12-2024, 09:30 AM
                                4 responses
                                31 views
                                0 likes
                                Last Post rtwave
                                by rtwave
                                 
                                Started by yertle, Yesterday, 08:38 AM
                                7 responses
                                29 views
                                0 likes
                                Last Post yertle
                                by yertle
                                 
                                Working...
                                X