• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

PriorDayOHLC

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

    PriorDayOHLC

    Can the PriorDayOHLC be modified to show "PrevHigh" "PrevLow" "PrevOpen" "PrevClose" on the far right in lieu of the price of the lines? If so, can you walk me through this?

    #2
    Hello crabman777,

    Welcome to the NinjaTrader support forum.

    I wanted to clarify, do you mean to also display this as text in addition to the price shown on the right scale?

    Placing text in the scale its self would not be possible for this use case, however, you could likely use drawing objects or OnRender to place text at the CurrentBar. If this is what you are trying to do, I believe I could provide some instruction to get you started on doing that. Otherwise can you provide more specific detail on the outcome you want to see here?

    I look forward to being of further assistance.

    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      It was easier for me to make a quick image to show what I am hoping to accomplish. Please see attached.

      If this is something that can be done, can it also be done for "PrevOpen2" "PrevHigh2" "PrevLow2" "PrevClose2"

      Thank you

      Comment


        #4
        Hello crabman777,

        Thank you for your reply.

        Yes, this type of display is possible using just Drawing tools. You could either modify the existing indicator by duplicating it and adding the drawing objects to its code, or you could make a new indicator that replots the PriorDay values in addition to drawing objects. I will provide details on the first option or duplicating the code.

        You can find samples of the various drawing objects syntax in the help guide here: https://ninjatrader.com/support/help...us/drawing.htm

        For this use, Draw.Text could be used: https://ninjatrader.com/support/help.../draw_text.htm

        The most simple use would be the following, this shows how to plot text on the CurrentBar for the Close price:

        Code:
        Draw.Text(this, "MyClosePrice", "Close", 0, Close[0]);
        To add the text to a copy of the PriorDayOHLC, you can use the following steps:
        1. From the control center:
        2. Click New -> NinjaScript editor
        3. In the editor, locate the PriorDayOHLC indicator in the Indicators folder and double click it to open it.
        4. Right-click in the file and choose Save As
        5. Give it a name and click OK.
        6. In the new file, add a new line between lines 132 and 133 and then paste the following code:

        Code:
        Draw.Text(this, "MyClosePrice", "Prior Close", 0,PriorClose[0]);
        it will look like the following in the file:

        Code:
                        if (ShowClose)    PriorClose[0] = priorDayClose;
                    }
        Draw.Text(this, "MyClosePrice", "Prior Close", 0,PriorClose[0]);
                }

        This will put text on the line similar to your image, this can be further controlled using BarsAgo to push it more Left if required, you can also use one of the Draw.Text overloads which has "Y Pixel Offset" if you wanted to push the text off of the line. Alternatively, you can supply modified prices to move this up or down off of the line:
        Code:
        PriorClose[0] - 1 * TickSize
        You could add an additional line below this one for each of the other plots you wanted to add text to. Keep in mind the Tag name needs to be unique for each Text, this sample uses the tag name "MyClosePrice".

        After making changes, press F5 or right-click and Compile to save and make the changes. Next, apply the indicator to the chart.

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

        Comment


          #5
          Thank you Jesse!! I will try that tonight.

          Comment


            #6
            HI Jesse,

            That worked great. I don't quite understand moving the text plot though. Can you tell me how to move the new text about 10 bars to the right? Thanks

            Comment


              #7
              Hello crabman777,

              Thank you for the reply.

              The sample I had provided uses 0 BarsAgo, so this should place the text on the bar where this was called, are you trying to place the object into the future 10 bars when this is placed?


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

              Comment


                #8
                I think I misunderstood you. Where do I place the "0 BarsAgo"? I did not add that to the script. I only have:

                }
                Draw.Text(this , "MyOpenPrice", "Prior Open", 0, PriorOpen [0]);
                Draw.Text(this , "MyHighPrice", "Prior High", 0, PriorHigh [0]);
                Draw.Text(this , "MyLowPrice", "Prior Low", 0, PriorLow [0]);
                Draw.Text(this , "MyClosePrice", "Prior Close", 0, PriorClose [0]);
                }

                Thank you,

                Comment


                  #9
                  Hello crabman777,

                  Thank you for clairifing.

                  In this, you have used 0 BarsAgo:

                  Code:
                  Draw.Text(this , "MyOpenPrice", "Prior Open", 0 //<<< BarsAgo
                  So the question still remains, are you trying to place the object into the future 10 bars when this is called? As it is now, this will be placed on the bar when this syntax is called or when the condition is true. if you wanted 10 bars from when the condition was true, that would require additional logic.

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

                  Comment


                    #10
                    Yes, I believe I want in in the future (like the image I uploaded). Right now, the test covers price action. I would like it to the right of the end of the plotted line, so it is not in the same space as my candles..

                    Comment


                      #11
                      Hello crabman777,

                      Thank you for your reply.

                      Technically you could use a BarsAgo of -10 here because you are not trying to look in the future for data but just to push the text forward, however using negative bars ago is not documented so use at your own risk.

                      The alternative would be to use Onrender here and the right side margin property of the chart. There is a sample indicator in NinjaTrader which draws text using OnRender called SampleCustomRender, this shows the syntax needed to render.

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

                      Comment


                        #12
                        I'm going to need help with this one Jesse. I looked over the sample indicator, but am at a loss on how to apply it. Please help.

                        Comment


                          #13
                          Hello crabman777,

                          In the sample, it demonstrates how to use OnRender for drawing which allows for drawing anywhere on the chart in X and Y coordinates. For what you are asking, the alternative would be to draw fixed text on the Right side of the chart and to also use the charts Right side margin to push the bars away from the right giving it space. Using OnRender is quite a bit more involved so you would need to use some of the code from this sample.

                          The sample has comments and the part you would need to reference is noted as:

                          // 1.6 - Simple Text Rendering
                          The 5 lines following this comment are what is required to draw the text in a fixed position on the chart.

                          The X position of the text will be mainly what you would be interested in here to place the text at the fixed end position in the chart.

                          The Y value you can use the GetYByValue method to create a Y value from a Price: https://ninjatrader.com/support/help...ub=getybyvalue

                          The Price would come from the plot, and in this context getting the price is a little different:

                          Code:
                          PriorDayOHLC().PriorOpen.GetValueAt(Bars.Count - 1);
                          The last bar on the chart may be a good candidate for the last value seen in the indicator, this can be retrieved by using the Bars.Count - 1.



                          I look forward to being of further assistance.

                          JesseNinjaTrader Customer Service

                          Comment


                            #14
                            That is not helping Jesse. Can you be more specific? This is new for me.

                            Thanks

                            Comment


                              #15
                              Hello crabman777,

                              Thank you for your reply.

                              The sample is very specific and explains each step in its comments, are you having difficulty with some part of this script?

                              The comments in the file would be able to explain what each step of the text rendering is doing, and that would be essentially what is required to render text at a fixed position on the right of the chart. I would suggest making a new indicator and first trying to replicate the text rendering logic so that part makes more sense.

                              The other items I had noted would be things you can change to give the text the result you wanted. Are you having difficulty with one of these parts of this description? If you can provide more specific details about what you don't understand, we can try to cover that in more detail.

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

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by matthewbartlett, Today, 01:22 AM
                              2 responses
                              12 views
                              0 likes
                              Last Post NinjaTrader_Jim  
                              Started by thomaspartyof10, Today, 02:33 AM
                              1 response
                              19 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by manueldecastro, Yesterday, 12:57 AM
                              1 response
                              16 views
                              0 likes
                              Last Post NinjaTrader_ChrisL  
                              Started by ArmKnuckle, Today, 01:59 AM
                              1 response
                              17 views
                              0 likes
                              Last Post NinjaTrader_PaulH  
                              Started by seppyr, Today, 01:53 AM
                              1 response
                              18 views
                              0 likes
                              Last Post NinjaTrader_PaulH  
                              Working...
                              X