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.Text weird behaviour

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

    Draw.Text weird behaviour

    Hi NT,

    I have some counting logic applies to bars. I will add numbers above or below the bars.
    I am seeing some strange behavior which is leaving me slightly perplexed...
    I either add my numbers (counter value) above the bar... or below the bar.

    If am adding above the bar, i am using:

    Code:
    Draw.Text(this, "S" + (CurrentBar), true, "" + (counterSs) , 0, High[0], 20, Brushes.Lime, new SimpleFont("Arial", 12),TextAlignment.Center,Brushes.Transparent, Brushes.Transparent, 0);
    The result here is the screenshot attached called 'High'.
    It looks great... but its not actually on the high ... I expect that it should be on the high.
    Do you agree ? (i haven't said High[0] + X in my code line above). The numbers seem to be higher than they should be.

    The real problem comes when I am trying to place numbers on the other side, under the bars. I am using the same line as above, but replacing the High[0] with Low[0]:

    Code:
    Draw.Text(this, "B" + (CurrentBar), true, "" + (counterBs * -1) , 0, Low[0] , 20, Brushes.Lime, new SimpleFont("Arial", 12),TextAlignment.Center,Brushes.Transparent, Brushes.Transparent, 0);
    The result here is the screenshot attached called 'Low'.
    You can see this is completely off, the numbers are actually above the low and inside the bar.. despite my line calling on Low[0]. Once again, the numbers seem to be higher than they should be.

    Is this a bug ? Or am i missing something ?

    As a quick acid test, i did replace both lines above with the 2 lines below:

    Code:
    Draw.Dot(this, "test1" + CurrentBar, true, 0, Low[0], Brushes.Purple);
    Draw.Dot(this, "test2" + CurrentBar, true, 0, High[0], Brushes.Blue);
    In both case,the 'dots' where positioned exactly on the high/low (as you would expect), which 'implies' the issue lies with Draw.Text .. and not the high/low.

    Any ideas on what could be causing the Draw.Text outputs to NOT display at the exact high/lows as you would expect if choosing High[0] and Low[0] ?

    Thanks
    A
    Attached Files

    #2
    Hello akvevo,

    Thank you for your note.

    It looks like you are passing a yPixelOffset value of 20 to the draw text method.

    Code:
    Draw.Text(this, "S" + (CurrentBar), true, "" + (counterSs) , 0, High[0], [B]20[/B], Brushes.Lime, new SimpleFont("Arial", 12),TextAlignment.Center,Brushes.Transparent, Brushes.Transparent, 0);
    The second to the last syntax listed at the following page in our helpguide, you'll see after the y value comes yPixelOffset.



    If you remove the figure 20 after High[0], do you see the results you expect?

    I look forward to your reply.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Ah, thats better, thank you !

      Comment


        #4
        Hi NT,

        One follow up question please, that "20" is my previous example is extremely useful.
        I would like to use it in this line too:

        Code:
        Draw.ArrowUp(this, "perfectb" + CurrentBar, true, 0,Low[0], Brushes.Lime);
        Is this possible ?
        The help page doesnt seem to show a a relevant argument:



        Thanks
        A

        Comment


          #5
          Hello akvevo,

          Draw.ArrowUp does not have a parameter for a pixel offset.



          What you could do is pass the Y Value an amount to offset, for example
          Code:
          Draw.ArrowUp(this, "perfectb" + CurrentBar, true, 0,[B]Low[0] - 3*TickSize[/B], Brushes.Lime);
          Please let us know if you need further assistance.
          Alan P.NinjaTrader Customer Service

          Comment


            #6
            Ah, that a shame.
            Yes, I am currently doing what you suggested, the only downside is that 3 ticks in Corn, doesnt really equate to 3 ticks in CL and it creates different distances across difference products.. the pixel offet is a great way to normalise that, but thanks anyway

            Regards
            A

            Comment


              #7
              Hello akvevo,

              I will put in a feature request for pixel offset parameter to be added.

              Instead of ticks you could use a percent of the price.

              For example

              double offsetX = Close[0]*.001;

              Code:
              Draw.ArrowUp(this, "perfectb" + CurrentBar, true, 0,Low[0] - offsetX *TickSize, Brushes.Lime);
              Please let us know if you need further assistance.
              Alan P.NinjaTrader Customer Service

              Comment


                #8
                Great idea, thank you

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by selu72, Today, 02:01 PM
                1 response
                8 views
                0 likes
                Last Post NinjaTrader_Zachary  
                Started by WHICKED, Today, 02:02 PM
                2 responses
                12 views
                0 likes
                Last Post WHICKED
                by WHICKED
                 
                Started by f.saeidi, Today, 12:14 PM
                8 responses
                21 views
                0 likes
                Last Post f.saeidi  
                Started by Mikey_, 03-23-2024, 05:59 PM
                3 responses
                51 views
                0 likes
                Last Post Sam2515
                by Sam2515
                 
                Started by Russ Moreland, Today, 12:54 PM
                1 response
                8 views
                0 likes
                Last Post NinjaTrader_Erick  
                Working...
                X