• 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

Using DrawText for arrows and numbers

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

    Using DrawText for arrows and numbers

    Hello

    I would like to draw up and down arrows, and have a number above or below that arrow. Here is what I have done followed by my question.

    To do that I am using the following:

    Rising
    DrawText("arr6", false, "á", 0, Lows[6][0], 0, Color.Blue, new Font ("Wingdings", 7, FontStyle.Bold),StringAlignment.Center, Color.Empty, Color.Empty, 0);
    DrawText("lab6", false, "30", 0, Lows[6][0]-3*TickSize, 0, Color.Blue, new Font ("Arial", 7, FontStyle.Bold),StringAlignment.Center, Color.Empty, Color.Empty, 0);
    Falling

    DrawText("arr6", false, "â", 0, Highs[6][0], 0, Color.Red, new Font ("Wingdings", 7, FontStyle.Bold),StringAlignment.Center, Color.Empty, Color.Empty, 0);
    DrawText("lab6", false, "30", 0, Highs[6][0]+3*TickSize, 0, Color.Red, new Font ("Arial", 7, FontStyle.Bold),StringAlignment.Center, Color.Empty, Color.Empty, 0);

    The problem is with the +-3*TickSize. Sometimes it fits but when the scaling changes, the distance needs to be increased or decreased, or arrow and number are laid over each other.

    Next I tried using the font size e.g.

    Rising
    DrawText("arr6", false, "á", 0, Lows[6][0], 0, Color.Blue, new Font ("Wingdings", fsize, FontStyle.Bold),StringAlignment.Center, Color.Empty, Color.Empty, 0);
    DrawText("lab6", false, "30", 0, Lows[6][0]-fsize*TickSize, 0, Color.Blue, new Font ("Arial", fsize, FontStyle.Bold),StringAlignment.Center, Color.Empty, Color.Empty, 0);

    Falling
    DrawText("arr6", false, "â", 0, Highs[6][0], 0, Color.Red, new Font ("Wingdings", fsize, FontStyle.Bold),StringAlignment.Center, Color.Empty, Color.Empty, 0);
    DrawText("lab6", false, "30", 0, Highs[6][0]+fsize*TickSize, 0, Color.Red, new Font ("Arial", fsize, FontStyle.Bold),StringAlignment.Center, Color.Empty, Color.Empty, 0);

    That gives me better results but it's not optimum yet.

    The 'DrawTextFixed' method with its TopRight and TopBottom uses the "n's" to move up and down. I am wondering whether there's something similar to use in 'DrawText' that I am not aware of yet.

    Any advice to keep arrow and number always close together and not overlapping is appreciated.

    sandman




    #2
    Hello sandman,

    Thanks for your post.

    The only thing I could suggest (in addition to what you have tried) would be to use the Ypixeloffset that is available in the Draw.Text() method. Currently, you have it set to 0. You can try variations to find if something works for you.



    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Thank you PaulH. I think I got the idea and will try it out using a positive Ypixeloffset for the arrows and a negative one for the numbers defined by half the value of the font size.
      Will let you know the result.

      sandman

      Comment


        #4
        Perfect. Does exactly what I tried to achieve.

        To complete it, here is the code that did it, i.e. draw an arrow with the text snuggly above or below the arrow no matter the scaling:

        Rising
        DrawText("arr0", false, "á", 0, Lows[0][0], +fsize/2, Color.Blue, new Font ("Wingdings", fsize, FontStyle.Bold),StringAlignment.Center, Color.Empty, Color.Empty, 0);
        DrawText("lab0", false, "15", 0, Lows[0][0], -fsize/2, Color.Blue, new Font ("Arial", fsize, FontStyle.Bold),StringAlignment.Center, Color.Empty, Color.Empty, 0);

        Falling
        DrawText("arr0", false, "â", 0, Highs[0][0], -fsize/2, Color.Red, new Font ("Wingdings", fsize, FontStyle.Bold),StringAlignment.Center, Color.Empty, Color.Empty, 0);
        DrawText("lab0", false, "15", 0, Highs[0][0], +fsize/2, Color.Red, new Font ("Arial", fsize, FontStyle.Bold),StringAlignment.Center, Color.Empty, Color.Empty, 0);

        Thanks PaulH!

        sandman

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by jeronymite, Today, 09:26 PM
        0 responses
        6 views
        0 likes
        Last Post jeronymite  
        Started by ttodua, Yesterday, 06:45 AM
        2 responses
        17 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by franco12364, Today, 08:08 PM
        2 responses
        11 views
        0 likes
        Last Post franco12364  
        Started by smcllr, Today, 06:10 PM
        1 response
        16 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by lupearadu, Today, 01:58 PM
        7 responses
        38 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Working...
        X