Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw Horizontal Lines

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

    Draw Horizontal Lines

    I am trying to write an indicator which allows one to set a High and Low, calculate mid and quarter points, then to draw horizontal lines across the price chart. Ideally, these would be yellow dotted lines of width 3.

    The code compiles and is very similar to another indicator I have written to draw horizontal lines which does work, but this one does not draw the lines. Maybe my math is messing it up?

    FYI, I have very much appreciated your help and have coded some very nice indicators. The ability to do this has made me very excited about NinjaTrader charts.

    Thanks again.
    Attached Files

    #2
    I can't see at a quick glance what could be wrong. Please check your Log tab for any errors. Apart from that, you will have to debug it.
    RayNinjaTrader Customer Service

    Comment


      #3
      What you want to do is use DrawHorizontalLine() instead of the Add(new Line) stuff. The Add(new Line) will not update to changes in your parameters because it is only run once in the Initialize() section.

      Check out the attachment. Hopefully that's what you wanted.
      Attached Files
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        Thank you for your help. The revised indicator is not working for me.

        1. It does not seem to draw the lines.
        2. When I change the High and Low settings, the settings for the mid and quarters do not change.
        3. When I apply this to a chart, it makes the horizontal grid lines and some other indicators disappear.

        Not sure what it's doing. I thought maybe I just had too many indicators on one chart and tried it on a simpler one, but acted the same.

        By the way, there were no errors in my Log file.

        Comment


          #5
          I'm not sure what you mean the settings aren't changing. The mid and qtr are recalculated on every bar. The lines should draw fine. Try this indicator by itself. I suspect it is one of your other indicators causing plotting issues.

          Also realize that if your stock price is nowhere near 800 or 750 (your default high and low settings) you simply won't see the lines because your y-axis is out of range.
          Last edited by NinjaTrader_JoshP; 08-01-2007, 02:03 PM.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Sorry to be dense, but I can't make it work.

            I tried putting it on a new chart with only the price bars on it, no lines. I compressed the y axis to check the default regions, but still nothing there.

            I added

            if (CurrentBar < 2)
            return;

            to the logic. The choices when you edit the indicator changed to eliminate the qtrs, mid, but still no lines.

            I can't figure it out.

            Do they show up on your charts?

            Comment


              #7
              I believe we are on different wavelengths Richard. Let me just touch base with you. Are you currently using the exact indicator I posted or did you take the code and modify it to your likings? If you are using the exact indicator they should draw the lines for you. It does draw on my charts. If you are using your own please post it so I can get an idea of what is going on.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                One possible reason:

                If you're using draw objects and you've set 'Overlay' to false you should also be setting 'DrawOnPricePanel' to false in Initialize().


                Also make sure you're calling DrawLine in OnBarUpdate()

                Comment


                  #9
                  I am using the code you sent without modifications on a new chart that only has price candles and still no lines. I condensed the y scale to check the levels, but no lines.

                  ????

                  Comment


                    #10
                    Not sure what its trying to do but the high and low values are set to 800 and 750, so you need to change those to match the price scale on your chart. Or make it dynamic like adding this to the start of OnBarUpdate :

                    Code:
                    high=High[0];
                    low=Low[0];

                    Comment


                      #11
                      Thanks to everyone for helping. I found out I could save a standard indicator ConstantLines under a new name and add my logic to that which I now have working.

                      I appreciate you all working on my problem.

                      Comment


                        #12
                        That's great!
                        RayNinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by 7robert, Today, 10:08 AM
                        0 responses
                        5 views
                        0 likes
                        Last Post 7robert
                        by 7robert
                         
                        Started by bosajin, Today, 09:15 AM
                        1 response
                        11 views
                        0 likes
                        Last Post NinjaTrader_ChrisL  
                        Started by Noobie2B, Today, 09:14 AM
                        1 response
                        8 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Started by Zombie, Yesterday, 06:23 PM
                        1 response
                        17 views
                        0 likes
                        Last Post NinjaTrader_Kate  
                        Started by EquityTrader, Today, 09:05 AM
                        1 response
                        9 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Working...
                        X