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

NT7 Pivots indicator

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

    NT7 Pivots indicator

    The width of the NT7 pivot lines can be set in the indicator menu. Its measured in bars ago, i.e. to the left.

    Question: Where in the code can I change the width in the other direction i.e. to the right. It seems it's hard coded to "1" i.e. 1 bar ago. I'd like to set this to 3, 4 or 5 bars ago.

    sandman


    #2
    Hello sandman,

    Thank you for the post.

    For this indicator, it uses the Plot override to render the lines you see and this uses the LastBarIndexPainted as part of the rendering calculation. You would need to modify the plot logic to account for a different ending point. This is not necessarily something I could detail the full specifics on but bit I can provide a small sample to get you started.

    I did a quick test to make sure you can render into the future and it looks like it is possible. I have attached an image of the changes required to see this outcome. Mainly it is just adding + 10 to the LastBarIndexPainted where it is used and also removing the condition to check if the bar has a valid series index. The final part which I have not demonstrated in the image is toggling the price being picked.

    The original code is:
    Code:
    double    val = series.Get(idx);
    which is getting a price for the bar index. This does not work once your past the LastBarIndexPainted so you would need to make a condition to change between using the index and what is displayed in the image or:

    Code:
    double  val = series.Get(this.LastBarIndexPainted);
    For simplicity, I did not create this condition and just used LastBarIndexPainted for the price. To make the indicator correctly, you could add a condition which toggles the price based on the current idx and LastBarIndexPainted value.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Jesse, thanks for your fast reply. However, I think your response uses NT8's code which doesn't help me as I am using NT7. Could you advise the same as you did but for NT7 please. (I also had a slight mistake in my request as I want to make the lines shorter, i.e. not extend them into the future, but shorten them into the past so to speak. But that would probably easily resolve by using MINUS10 instead of PLUS10 in your example). I would just need your same advice but for NT7.

      sandman

      Comment


        #4
        Hello sandman,

        The reply I provided is for NT7 as we are in the NT7 forums. The image is also an image of the NT7 NS editor and chart, you can compare this with code with the code you see in the platform to confirm this is for NT7.

        Please let me know if I may be of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Shucks - my mistake. I guess I simply did not look far enough down in the code. What you provided is sufficient for me to work with.

          Thank you, Jesse.

          Comment


            #6
            Jesse. Thanks for your help. It provided exactly what I was looking for. Please allow me one more question on the same subject of the Pivots indicator. Where in the code can I change the font size of the pivot labels (PP, R1, R2, S1, S2 etc). I'd like to make them a bit smaller. I looked but could not figure it out.
            sandman

            Comment


              #7
              Hello sandman,

              This indicator currently uses the ChartControl to get the charts font, you can change this by making the following modification:

              from

              Code:
              graphics.DrawString(plot.Name, ChartControl.Font, brush, lastX, lastY - textHeight / 2, stringFormatFar);
              to

              Code:
              graphics.DrawString(plot.Name, [B]new Font("Arial", 5)[/B], brush, lastX, lastY - textHeight / 2, stringFormatFar);
              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment


                #8
                Thank you very much.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by rtwave, 04-12-2024, 09:30 AM
                2 responses
                19 views
                0 likes
                Last Post rtwave
                by rtwave
                 
                Started by tsantospinto, 04-12-2024, 07:04 PM
                5 responses
                67 views
                0 likes
                Last Post tsantospinto  
                Started by cre8able, Today, 03:20 PM
                0 responses
                6 views
                0 likes
                Last Post cre8able  
                Started by Fran888, 02-16-2024, 10:48 AM
                3 responses
                49 views
                0 likes
                Last Post Sam2515
                by Sam2515
                 
                Started by martin70, 03-24-2023, 04:58 AM
                15 responses
                115 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Working...
                X