Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Double plot above bar

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

    Double plot above bar

    Hello,

    I want to plot simply the difference of High and Low from bar[0] and bar[1] and plot it above and below the bar. I was searching in helpguide but I always get compiling errors whatever I try. What ist wrong here please

    pricediffHigh=(High[0]-High[1]).ToString();
    pricediffLow=(Low[0]-Low[1]).ToString();
    Draw.Text(this, "diffHigh" + CurrentBar, pricediffHigh, 0, High[0] + 3*TickSize);
    Draw.Text(this, "diffLow" + CurrentBar, pricediffLow, 0, Low[0] - 3*TickSize);

    Thank you!
    Tony

    #2
    Hello,

    it works with this...

    pricediffHigh=(High[0]-High[1]);//.ToString();
    pricediffLow=(Low[0]-Low[1]);//.ToString();
    str1 = pricediffHigh.ToString();
    str2 = pricediffLow.ToString();
    Draw.Text(this, "diffHigh" + CurrentBar, str1, 0, High[0] + 3*TickSize);
    Draw.Text(this, "diffLow" + CurrentBar, str2, 0, Low[0] - 3*TickSize);

    Tony

    Comment


      #3
      Hello TonyNT,

      Thanks for your post.

      If the variables pricediffHigh and pricediffLow are declared of the type double then that would be incompatible with the added.ToString(); which is used to convert the value into a string of characters. For example: This line pricediffHigh=(High[0]-High[1]).ToString(); would be trying to convert the math difference into a string and then store the string into the double variable pricediffHigh You can change that variable type to string and it will work as you have it.

      OR

      if you want to keep the variables as double type, then remove the .ToString() and in the Draw statements add the ToString there, like this: Draw.Text(this, "diffHigh" + CurrentBar, pricediffHigh.ToString(), 0, High[0] + 3*TickSize); So the double type variable is converted to a string withing the Draw statement and this will work.

      Comment


        #4
        Hello,

        thank you for your reply. In the meantime I grabbed me from the helpguide the syntax and from the forum a line to make plotting variabel (in helpguide there is only the most easy syntax example)

        I copied and pasted in my code and modified it

        Draw.Text(this, "diffHigh" + CurrentBar, false, str1, 0, High[0] + 21*TickSize, 21, Brushes. Black,new SimpleFont ("Arial",8), TextAlignment.Right, Brushes.Transparent,null,1);
        Draw.Text(this, "difflow" + CurrentBar, false, str2, 0, Low[0] - 21*TickSize, 21, Brushes. Black,new SimpleFont ("Arial",8), TextAlignment.Right, Brushes.Transparent,null,1);

        But the str2 is not plotting ok, whatever value I set its always the same position below the low (of the dataseries"box").

        And what means this "null" here please?

        I get for the ES with diff the value 0,5 plotted, how can I have the result of if(Math.Abs(High[0]-High[1])<=2*TickSize) plotted as 2 instead of 0,5 (which is of course 2 x 0,25) Getting almost crazy with this.

        Thank you!
        Tony
        Last edited by tonynt; 10-30-2020, 12:05 PM. Reason: add question

        Comment


          #5
          Hello tonynt,

          Thanks for your reply.

          "But the str2 is not plotting ok, whatever value I set its always the same position below the low (of the dataseries"box")." I'm not sure what you mean that it is always below the dataseries box.

          What your draw text statement shows is that it is drawing the contents of the string variable str2 21 ticks below the current bar with a y offset of 21 pixels

          "And what means this "null" here please?" Your draw.text() is using the overload parameters of this: Draw.Text(NinjaScriptBase owner, string tag, bool isAutoScale, string text, int barsAgo, double y, int yPixelOffset, Brush textBrush, SimpleFont font, TextAlignment alignment, Brush outlineBrush, Brush areaBrush, int areaOpacity) If you look at Text alignment\, the next parameter is an outline brush and you are specifying a transparent brush, the next parameter is an Area brush and this is what you have set to null meaning no brush specified. Reference: https://ninjatrader.com/support/help...?draw_text.htm

          "I get for the ES with diff the value 0,5 plotted, how can I have the result of if(Math.Abs(High[0]-High[1])<=2*TickSize) plotted as 2 instead of 0,5 (which is of course 2 x 0,25) Getting almost crazy with this." In other words, you want to know the number of ticks of the price difference and not the price difference itself. You can divide the result of your math by TickSize. In the case of the ES the TickSize will be 0.25 (smallest movement of the instrument. Thus a result of 0.5 / TickSize = 2.

          Comment


            #6
            Hello,

            thank you for your reply.
            str2:
            found out now that the y value in the syntax has to be + or -, of course (so I had -13+13, but should have a (-) below the low)

            null:
            Thank you for the link. I have been there of course, its not about the syntax, I didnt understand the "null". Never seen or used before. So "null"="nothing". OK

            /TickSize:
            works OK.

            Thank you!
            Tony
            Attached Files
            Last edited by tonynt; 10-30-2020, 01:19 PM. Reason: solution

            Comment


              #7
              Hello,

              when I set autoscale true in the Draw.Text syntax from my understanding the Drawtext above the High of the bar (and below the Low of the bar) should be visible inside the chart. No?

              When there is a bar going near the upper border of the chart window then I do not see the Drawtext above the high.

              ??

              Thank you!
              Tony

              Comment


                #8
                Hello tonynt,

                Thanks for your post.

                When you include the autoscale true in the Draw methods then that means the draw object would be included in the chart y-axis scaling IF the chart scale is set to autoscale (or Not Fixed) AND the indicator itself has AutoScale set to true.

                Can you advise if the Chart itself is set to autoscale (no F in the corner) and that the indicator is set to autoscale true in the User Interface and that you see (don't see ) the text above the bar when the bar is at the top of the chart?

                Comment


                  #9
                  Hello,

                  thank you for your reply. There is no "F" in upper right corner and in the indicator I have


                  But the draw.text is outside chart (if the close of bar is near to top of the window or low is near to the low of chartwindow). I have:

                  Draw.Text(this, "diffHigh" + CurrentBar, true, str1, 0, High[0] + 13*TickSize, 21, Brushes. Black,new SimpleFont ("Arial",9), TextAlignment.Center, Brushes.Transparent,null,1);

                  Thank you!
                  Tony

                  Comment


                    #10
                    Hello tonynt,

                    Thanks for your reply.

                    Can you confirm that the indicator itself is set to Autoscale in the indicators UI? (See example)


                    Click image for larger version

Name:	TonyNT-10.PNG
Views:	364
Size:	5.9 KB
ID:	1125855


                    Comment


                      #11
                      Hello,

                      yes. Please see the attached screenshot

                      Thank you!
                      Tony
                      Attached Files

                      Comment


                        #12
                        Hello tonynt,

                        Thanks for your reply.

                        I've created a short video on how I tested this here: https://Paul-ninjaTrader.tinytake.co...Ml8xNTEzMjU3MQ

                        I would suggest replicating what I am showing in a simple indicator, on your end.

                        If the chart does not auto adjust according to the draw text, please provide the simplified indicator example that demonstrates that it does not.



                        Comment


                          #13
                          Hello tonynt,

                          Just to update this forum thread.

                          We continued our discussion offline.

                          It appears that when using a large YPixelOffset that the text can be drawn off the chart even when Autoscale is set to true in the Draw.Text() method.

                          We are investigating this and will update this thread when information becomes available.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                          0 responses
                          648 views
                          0 likes
                          Last Post Geovanny Suaza  
                          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                          0 responses
                          369 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by Mindset, 02-09-2026, 11:44 AM
                          0 responses
                          108 views
                          0 likes
                          Last Post Mindset
                          by Mindset
                           
                          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                          0 responses
                          572 views
                          1 like
                          Last Post Geovanny Suaza  
                          Started by RFrosty, 01-28-2026, 06:49 PM
                          0 responses
                          574 views
                          1 like
                          Last Post RFrosty
                          by RFrosty
                           
                          Working...
                          X