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

DrawText Issues and DrawtextFixed

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

    DrawText Issues and DrawtextFixed

    Hi Guys, I've been getting a little frustrated trying to draw/position text on the chart and was hoping you could tell me an easier way. Please find attached the chart and look at the text on the right in Yellow - Low High Ratio etc. How I do this is with the following code from the manual which draws this one 5 across and 20 up from the close of the last bar:

    DrawText("5", true, "Delta:", -6, High[0] +20 * TickSize ,15, Color.Yellow, largeFont, StringAlignment.Near, Color.Transparent, Color.Green, 0);

    Now the problem with this code is it all moves as the candles move so can end up getting squashed at the top of the chart. What I am trying to do is anchor this at the top right as the chart moves it stays put. Ideally the drawtextfixed should come to the rescue but that only seems to allow one item at the corners not going down the page like I have. Ideally you could have a drawtextfixedright -1 and -2 etc so can be position down the page. So hopefully you can advise me a more effective way of doing this? Thanks. DJ
    Attached Files

    #2
    Hi DJ, you're correct in assuming the DrawTextFixed would only help you here if you could put all your custom info in one DrawTextFixed object, not several ones - perhaps the ideas working into the custom status box from the sharing section can help you out - http://www.ninjatrader.com/support/f...=status&desc=1
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Originally posted by djkiwi View Post
      Hi Guys, I've been getting a little frustrated trying to draw/position text on the chart and was hoping you could tell me an easier way. Please find attached the chart and look at the text on the right in Yellow - Low High Ratio etc. How I do this is with the following code from the manual which draws this one 5 across and 20 up from the close of the last bar:

      DrawText("5", true, "Delta:", -6, High[0] +20 * TickSize ,15, Color.Yellow, largeFont, StringAlignment.Near, Color.Transparent, Color.Green, 0);

      Now the problem with this code is it all moves as the candles move so can end up getting squashed at the top of the chart. What I am trying to do is anchor this at the top right as the chart moves it stays put. Ideally the drawtextfixed should come to the rescue but that only seems to allow one item at the corners not going down the page like I have. Ideally you could have a drawtextfixedright -1 and -2 etc so can be position down the page. So hopefully you can advise me a more effective way of doing this? Thanks. DJ
      Code:
      DrawTextFixed("InfoPanel",	FirstLineOfText + "\n" +
      					NextLineOfText + "\n" +
      					NextLineOfText + "\n" +
      					NextLineOfText etc,.+ "\n" +
      					LastLineOfText,
      					this.InfoPanelPosition, TextColor, TextFont, 
      					TextBoxOutlineColor, TextBackgroundColor, Transparency);

      Comment


        #4
        Draw text with panel box

        Thanks Guys for posting that and especially that last part Koganam. I am not really sure what that does until I see it on the chart. So far I have this:

        DrawTextFixed("InfoPanel", "Low" + "\n" +
        EMA(gcd.DeltaClose,5)[0].ToString("N0") + "\n" +
        "High" + "\n" +
        "Ratio" + "\n" +
        "Delta",
        this.InfoPanelPosition,Color.Red, largeFont,
        Color.White, Color.Blue, 10);


        I am getting an error that says does not contain a definition for infoPanelPosition and no extension method InfoPanelPostion" Accepting a first argument. So I tried to define it in variables with:

        private InfoPanelPosition = TextPosition.TopRight;

        then it said class member declaration expected.

        Not really sure what to do next. I assume I have to define InfoPanelPosition as top right somewhere so that is where the text starts? Thanks. DJ

        Comment


          #5
          From what you write, I presume that you have already defined largeFont.

          The InfoPanelPosition is of type TextPosition, so should be properly declared as:

          Code:
          private [B]TextPosition[/B] InfoPanelPosition = TextPosition.TopRight;
          or, as "InfoPanelPosition" was meant as a placeholder anyway, (just like "TextColor" et. al.,) just write it into place directly. You would only really need to declare it as a variable, if you want to make it a user selectable parameter for the indicator.

          You also need to write your lines correctly. "Low" will simply print that on the screen, I am going to presume that you mean to write the line to show the Low, and identify it. That would need to be written thus:

          Code:
          "Low: " + Low[0] + "\n" +
          etc

          Properly written, it should look something like the graphic attached.
          Attached Files
          Last edited by koganam; 03-20-2011, 12:18 PM.

          Comment


            #6
            Draw Text Fixed Scene 3

            Thanks. That is exactly what I was after! The only question I have remaining is how do I set the fonts and backgrounds for each individual line. For example I have this example right now:

            DrawTextFixed("InfoPanel", "Low: " + EMA(Close,5)[0].ToString("N0") + "\n" +
            "Ratio: " + EMA(gcd.DeltaClose,5)[0].ToString("N0") + "\n" +
            "High: " + High [0].ToString("N0") + "\n" +
            " " + "\n" +
            "Ratio: " + Close [0].ToString("N0") + "\n" +
            "Delta: ",
            this.InfoPanelPosition,Color.Red, largeFont,
            Color.White, Color.Blue, 10);

            Now the InfoPanelPostion sets all of this for all the parameters. Say I wanted to have The word ratio in Yellow and, the Close [0] in white and Background of close 0 in green like I have in this attached chart.

            For example when I used drawtext it allowed me set these things as follows:

            DrawText("6", true, "Swing:", -6, High[0] +0 * TickSize ,15, Color.Yellow, largeFont, StringAlignment.Near, Color.Transparent, Color.Green, 0);

            Thanks DJ
            Attached Files

            Comment


              #7
              To do that you would have to write each line individually with a separate DrawTextFixed, and use "\n"'s to space the text out vertically. Now that you have the idea, I am sure that you can run with this.

              Code:
              DrawTextFixed("InfoPanel1", [I]FirstLineOfText,
              					  this.InfoPanelPosition, TextColor1, TextFont1, 
              					 TextBoxOutlineColor1[/I], Color.Transparent, 0);
              DrawTextFixed("InfoPanel2", "\n" + [I]NextLineOfText,
              					  this.InfoPanelPosition, TextColor2, TextFont2, [/I]
              					[I] TextBoxOutlineColor2[/I], Color.Transparent, 0);
              DrawTextFixed("InfoPanel3", "\n\n" + [I]NextLineOfText,[/I]
              					 [I] this.InfoPanelPosition, [/I][I]TextColor3[/I], [I]TextFont3, [/I]
              					 [I]TextBoxOutlineColor3, InfoPanelBackgroundColor, Transparency[/I]);
              et.c.,
              Last edited by koganam; 03-20-2011, 01:09 PM.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by GussJ, 03-04-2020, 03:11 PM
              11 responses
              3,229 views
              0 likes
              Last Post xiinteractive  
              Started by andrewtrades, Today, 04:57 PM
              1 response
              14 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by chbruno, Today, 04:10 PM
              0 responses
              7 views
              0 likes
              Last Post chbruno
              by chbruno
               
              Started by josh18955, 03-25-2023, 11:16 AM
              6 responses
              441 views
              0 likes
              Last Post Delerium  
              Started by FAQtrader, Today, 03:35 PM
              0 responses
              12 views
              0 likes
              Last Post FAQtrader  
              Working...
              X