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 with textAlignment.Right or textAlignment.Left shown on the opposit size

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

    Draw.Text with textAlignment.Right or textAlignment.Left shown on the opposit size

    I am using Draw.Text, with and character is displayed on the wrong side of the bar (left instead of right, and right instead of left)

    Code:
    private const string     openDistrbutionSymbol = "4"; // Ascii code for > in "Webdings"
    private const string     closeDistrbutionSymbol = "3"; // Ascii code for < in "Webdings"
    ...
    fontSymbols = new Gui.Tools.SimpleFont("Webdings", 18);
    ...
    
    private void DrawOpen()
    {
        Draw.Text(this.parent, TagText("Open"), false, openDistrbutionSymbol, this.StartDateTime, this.OpenPrice, 0,
            Brushes.Black, this.parent.fontSymbols, TextAlignment.Left, Brushes.Transparent, Brushes.Transparent, 0); 
    }
    
    private void DrawClose()
    {
        Draw.Text(this.parent, TagText("Close"), false, closeDistrbutionSymbol, BarsToDateTime(this.StartBar+this.BarsCount-1), this.ClosePrice, 0,
            Brushes.Black, this.parent.fontSymbols, TextAlignment.Right, Brushes.Transparent, Brushes.Transparent, 0); 
    }
    Click image for larger version

Name:	Screen Shot 2018-10-15 at 2.44.51 AM.png
Views:	554
Size:	72.8 KB
ID:	1035640

    #2
    Hello Shai Samuel,

    Thanks for your post.

    The alignment is relative to the center of the bar.
    Right justified text will end at the bar center line.
    Left justified text will begin at the bar center line.
    Please see the embedded example where the text is drawn relative to the doji bar center line.

    You would need to reverse your alignment to have the arrow text point to the center of the bar line.

    Click image for larger version

Name:	ShaiS-2.PNG
Views:	527
Size:	45.3 KB
ID:	1035649
    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Good afternoon, I have the problem that the text comes out too far to the left and I want to see it more together with the price. The text comes out centered but it appears to me very separated from the bar. My purpose is that it is more linked to the price bar. How could I solve it?

      Thanks a lot.




      if(ShowTime)
      {
      Draw.Text(this,"TFx"+CurrentBar, true, Convert.ToString(Time[0]),5, Median[0], 0,colorText1,
      new SimpleFont("Small Fonts", 10)/*new Font("Small Fonts", 7, FontStyle.Regular)*/, TextAlignment.Right, Brushes.Transparent,Brushes.Transparent, 0);
      }
      Attached Files

      Comment


        #4
        Hello punkiy2111,

        Thanks for your post.

        To adjust the relationship between the text and the price bars you would want to change the "Y" parameter in your Draw.text(0 statement. The Y parameters shows as "5".

        I would suggest something like Low[0] - 5 * TickSize as the Y value to use, this will place the text 5 price ticks below the low of the bar. You can adjust the number of ticks to what works best for you.
        Paul H.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by sidlercom80, 10-28-2023, 08:49 AM
        171 responses
        2,275 views
        0 likes
        Last Post QuantKey_Bruce  
        Started by Irukandji, Yesterday, 02:53 AM
        2 responses
        17 views
        0 likes
        Last Post Irukandji  
        Started by adeelshahzad, Today, 03:54 AM
        0 responses
        3 views
        0 likes
        Last Post adeelshahzad  
        Started by CortexZenUSA, Today, 12:53 AM
        0 responses
        3 views
        0 likes
        Last Post CortexZenUSA  
        Started by CortexZenUSA, Today, 12:46 AM
        0 responses
        1 view
        0 likes
        Last Post CortexZenUSA  
        Working...
        X