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

Draw horizontal lines from open X ticks

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

    Draw horizontal lines from open X ticks

    Hey guys,

    I am after how to draw horizontal lines from the open(first bar) of the session X ticks(the users choice, so needs to be adjustable in indicator settings) above and below the open price, then above themselves as well. So say the user had 10 as the tick amount, it would draw lines 10 ticks above the open price of the day and 10 ticks below the open price of the day and lines every 10 ticks apart from those lines up and down the chart, so just multiple layers of these lines X ticks apart starting from the open price of the day/session.

    I haven't made an indicator in NT for a while, so I'm a bit rusty. But I understand there is a Bars.FirstBarOfSession that I can use, I just need to know how to draw the horizontal lines that don't end, like need to go till the end of the session in length.

    Can someone help with this please? Thanks in advance!!

    #2
    I have managed to get draw the horizontal lines, but I now need to know how to draw it just from current days open to current days close, in other words I want the lines to just be for the current session only, but I also want to see the previous day's lines, but just in their sessions, like pivot points do, scroll back through the chart and the lines are just there for that session. Damn this is way harder to explain than I thought

    Don't suppose theres any of the DrawHorizontalLine attributes that state where the line should end, then I could somehow do a "Draw till Bars.LastBarOfSession" kinda thing?

    Comment


      #3
      Hello Jumper,

      Thanks for your posts.

      Correct, Horizontal lines are just that extending in both directions. You could use Rays but that will still provide the same issue but in one direction. If you use DrawLine() then you can control the begin and end points but this may not be the best way to go because you are going to be generating many draw objects.

      I would recommend that you consider using plots that can be started and stopped as needed and actually use less resources that the draw methods. To see an example of this, please review the indicator Pivots in your NinjaTrader.
      Paul H.NinjaTrader Customer Service

      Comment


        #4
        Thanks Paul for the quick reply.

        I am looking at the Pivots indicator as you suggested, just wondering how does it actually plot the line? I have added 10 plots(5 lines up and 5 lines down), so do I just make them all variables as well, I can't piece together how a plot becomes lines on my chart, and how I specify where they start and end?

        Thanks!

        Comment


          #5
          Hello Jumper,

          Thanks for your reply.

          To help with the concept a bit, the Plot will place a bars width line at the level you tell it to on each OnBarUpdate going forward. The net effect will be of a continuous line at a level you provide.

          With reference to the pivots indicator (for a common example)

          This line: Add(new Plot(Color.Black, "PP")); adds a plot called PP.


          This line: PP.Set(pp); on each OnbarUpdate plots the value of the variable "pp". So this is where you "set" the plot value (level) of your line. You already have figured out the levels and that is what you would put inside of the PP.Set().


          In the properties section, you will also need to make sure you have the equivalent of the following for each added plot:

          [Browsable(false)]
          [XmlIgnore]
          public DataSeries PP
          {
          get { return Values[0]; }
          }


          Note: Each plot will have its own output as mentioned however observe that based on the order that the plots are added in the initialize section, in the properties section the index of Values[] will be in order starting from the first plot PP (starts at zero), so R1 will be Values[1], S1 will be Values[2], R2 will be Values[3], etc. etc. So your 10 lines means you will have 10 properties with Values from [0] through [9].
          Paul H.NinjaTrader Customer Service

          Comment


            #6
            Okay awesome I'll give it a go, thanks Paul!

            Comment


              #7
              Okay have done all you said, code looks good, it compiles, but no lines on my chart.

              I have an if(Bars.FirstBarOfSession) block where I have myDblForOpen = Open[0] then underneath I have my variables "up" "up1" etc. assigned to the value I want, so Open[0] + myValue, all in the if statement. Then I have done the UP.Set(up); for all of them. And done all the Values[0] bit in Properties section as well, so I'm not sure where I've gone wrong? If it compiles I can't be too far away, just can't see any lines for some reason. Any ideas?

              Comment


                #8
                Hello Jumper,

                Thanks for your reply.

                When an indicator compiles but does not show when applied to a chart, it may be a matter of a run time error. Please check the "log" tab of the control center for any error messages related to your indicator. The error messages, if any, will be pretty generic but should provide some direction.

                If you find that you have no errors in the control center then it may be that the plots are off screen vertically. In this case, in the indicator panel you can set the "autoScale" to true for the indicator and this will collapse the vertical display if the plots are at a far different value from price.
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Nevermind, got it, great success! I just took the variable assigning for the line values out of the if statement and its all good now.

                  Thanks again Paul, all working good now! Much better!

                  Much appreciated! Thread can be deleted now if need be!

                  Comment


                    #10
                    Hello Jumper,

                    Thanks for your reply.

                    Glad to hear of your success.

                    If after using for a while, you are inclined to share (certainly not required) and think the indicator would be of value to others, please feel free to post the indicator in the file sharing area of NT7: http://ninjatrader.com/support/forum...ks.php?catid=4

                    (edit: removed request for update, didn't see the full message below - Thanks)
                    Paul H.NinjaTrader Customer Service

                    Comment


                      #11
                      Jumper,

                      How much would you be willing to share? I am doing something that sounds very familiar. Currently I am entering daily data from the data box into an Excel spreadsheet and my formulas tell me where to draw my lines (manually on the charts) for the next day. Since the data comes straight from a Ninja data box, it seems reasonable to me that I could create an indicator that would automate this process. I have spent many hours working on strategies but I have yet to attempt to create an indicator. The indicator Wizard seems a little too basic to me to be able to pull all of the info that I would need for it to function. Additionally, I would need some math to be performed.

                      Can you give me a peek at some of your indicator? Did you use the wizard or or did you code it all yourself? Thanks in advance.

                      Best regards,

                      Dolfan

                      Comment


                        #12
                        Paul,

                        I have not gotten a response from Jumper so I assume he will not be responding. I am not certain about what he is doing but I seek to build an indicator that I just discovered is already here, Pivots. The exception is that I disagree with the locations of the lines drawn and would like them to be at levels that I dictate. At present I am producing these levels daily using formulas in an Excel spreadsheet and manually placing them on my charts. VERY time consuming daily! I was thinking that I would save the Pivot Indicator as a different name and begin my changes from there. I received error messages right away based on naming of certain lines of code. How do I identify and change those items? I understand that the same 'names' cannot exist elsewhere on any other indicator after compiling but I am uncertain what these exceptions are. Can I just put 'Dolfan' in front of each error that pops up to eliminate this? I don't want to screw up my entire indicator database with one bad compilation.

                        Also, the Pivot Indicator starts with the following formula to draw the PP line;

                        pp = (currentHigh + currentLow + currentClose) / 3;

                        When it denotes 'current', is that for the current bar or current day? For me to begin, I like to draw a line that represents the opening price of the day or more specifically, the open price of a 1440 minute bar. How would I modify this line to reflect that? Thanks in advance for your guidance.

                        Best regards,

                        Dolfan

                        Comment


                          #13
                          Hello Dolfan,

                          Thanks for your reply.

                          I recommend that you create a new thread for this topic as it is not related to the original thread. Also, if this is an NT8 question it really belongs in the NT8 section to avoid confusion for us and others that may be looking for something similar but in NT7.

                          Thanks for your understanding.
                          Paul H.NinjaTrader Customer Service

                          Comment


                            #14
                            Is there a list of development forums that I can zoom to?

                            Comment


                              #15
                              Never mind, got it

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by aa731, Today, 02:54 AM
                              0 responses
                              4 views
                              0 likes
                              Last Post aa731
                              by aa731
                               
                              Started by thanajo, 05-04-2021, 02:11 AM
                              3 responses
                              470 views
                              0 likes
                              Last Post tradingnasdaqprueba  
                              Started by Christopher_R, Today, 12:29 AM
                              0 responses
                              10 views
                              0 likes
                              Last Post Christopher_R  
                              Started by sidlercom80, 10-28-2023, 08:49 AM
                              166 responses
                              2,237 views
                              0 likes
                              Last Post sidlercom80  
                              Started by thread, Yesterday, 11:58 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post thread
                              by thread
                               
                              Working...
                              X