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 dynamic text

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

    draw dynamic text


    I am facing another issue, ollowing up the problem with the values in OnRender().

    I am trying to draw dynamic texts in OnDender(), but after failling to achieve the goal, I have deceided to draw the fixed text to check if there could be an issue with my values from the region Helpers. The fixed text can be seen on the chart, but not the dynamic texts.
    Here is my code:

    HTML Code:
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
    {
        SharpDX.Vector2 startPoint;
        startPoint = new SharpDX.Vector2(ChartPanel.X, ChartPanel.Y);​
        float canvasEndCoordinate = chartControl.CanvasRight;
        int xCoordinate1 = chartControl.GetXByTime(endX1);
    
    
       // Fixed text
       SharpDX.Vector2 vecMyTag = new SharpDX.Vector2(canvasEndCoordinate-75, startPoint.Y+35);
       SharpDX.DirectWrite.TextLayout textLayout1 = new SharpDX.DirectWrite.TextLayout(NinjaTrader.Core.Gl obals.DirectWriteFactory,
         "Here is my text", textFormat1, ChartPanel.X + ChartPanel.W, textFormat1.FontSize);
      RenderTarget.DrawTextLayout(vecMyTag, textLayout1, firstColorDx, SharpDX.Direct2D1.DrawTextOptions.NoSnap);
    
       // ​Dynymic text
       SharpDX.Vector2 vecMyTag = new SharpDX.Vector2(xCoordinate1, endY);
       SharpDX.DirectWrite.TextLayout textLayout1 = new SharpDX.DirectWrite.TextLayout(NinjaTrader.Core.Gl obals.DirectWriteFactory,
          "Here is my text", textFormat1, ChartPanel.X + ChartPanel.W, textFormat1.FontSize);
       RenderTarget.DrawTextLayout(vecMyTag, textLayout1, firstColorDx, SharpDX.Direct2D1.DrawTextOptions.NoSnap);​​​
    }
    I would be gratefull to you if you coud point out where I am mistaking.

    Thanks in advace!
    Last edited by NinjaTrader_Gaby; 04-26-2024, 07:28 AM.

    #2
    Hello,

    I have moved this to a separate post since it is unrelated to your previous inquiry. Please note, any time you reply to a thread, this will go to the person you are working with. Reply instead of created a new thread when you would like to continue investigating an existing inquiry.

    Any time you create a new thread, this will create a new inquiry and a new case ticket, which will be answered by the first person available and may not be the person you are previously working with. Create a new thread instead of a reply when you have a new question that is unrelated to a previous inquiry. This will allow us to properly track each issue.

    We appreciate your cooperation in this regard.


    Are you seeing any errors in the Log tab of the Control Center?

    It also looks like you are using the same variable names for the fixed text and the dynamic text (vecMyTag and textLayout1).

    I also recommend taking a look at SampleCustomRender included in NinjaTrader 8 which demonstrates using SharpDX.DirectWrite.TextLayout.
    Gaby V.NinjaTrader Customer Service

    Comment


      #3
      Thanks NinjaTrader_Gaby for your help.

      Are you seeing any errors in the Log tab of the Control Center?
      No!

      It also looks like you are using the same variable names for the fixed text and the dynamic text (vecMyTag and textLayout1).
      I do not have "fixed text and "dynnaic text" at the same time in OnRender(). I write the code for the fixe text first and delete it to write the code for dynamic text.
      I also have the X ad Y values in the print function in OnRender().

      What could be the problem here?

      Comment


        #4
        Hello Stanfillirenfro,

        What do you consider dynamic text?

        Do you mean you want text that will scroll with the chart bars?
        Below is a link to an example of this.


        If you have print output, please provide the print output so we may assist with analyzing the output.

        Are you printing the chart panel X and Y and H and W and comparing this to the X and Y coordinates of the rendered text?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Thanks NinjaTrader_Gaby for your reply!

          What do you consider dynamic text?
          I have some rectangles on the chart. I want to label each rectangle drawn and therefore I want text right after the rectangles.Since the rectangles increase their widths with the new bar, I want the text to remain right after the rectangles.

          I have the coordinates as shown in the attached file. I am using these values to create the rectangles.

          What could be the mistake I am making here?

          Thanks in advance!​

          Comment


            #6
            Hello Stanfillirenfro,

            No output text file is attached to post # 5.

            To confirm you are printing the coordinates for the TextLayout and these are within the coordinates and height / width of the panel?
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              xCoordinate1 Size : 953
              EndY1: 17441,9397357452
              xCoordinate1 Size : 953
              EndY1: 17441,9397357452
              xCoordinate1 Size : 953
              EndY1: 17441,9397357452
              xCoordinate1 Size : 953
              EndY1: 17441,9397357452​

              Comment


                #8
                Many thanks NinjaTrader_ChelseaB for your reply!

                To confirm you are printing the coordinates for the TextLayout and these are within the coordinates and height / width of the panel?
                Yes!

                Comment


                  #9
                  xCoordinate1 Size : 953
                  EndY1: 17441,9397357452
                  xCoordinate1 Size : 953
                  EndY1: 17441,9397357452
                  xCoordinate1 Size : 953
                  EndY1: 17441,9397357452
                  xCoordinate1 Size : 953
                  EndY1: 17441,9397357452​

                  Comment


                    #10
                    Hello Stanfillirenfro,

                    What is this output?

                    Your prints should include labels that identify what each value is.

                    Print(string.Format( "ChartPanel.X: {0}, ChartPanel.W: {1}, ChartPanel.Y: {2}, ChartPanel.H: {3}, vecMyTag.X: {4} < ({0} + {1}): {5}, vecMyTag.Y: {6} > {2}, vecMyTag.Y: {6} < ({2} + {3}): {7} ", ChartPanel.X, ChartPanel.W, ChartPanel.Y, ChartPanel.H, vecMyTag.X, (ChartPanel.X + ChartPanel.W), vecMyTag.Y, (ChartPanel.Y + ChartPanel.H) ));
                    Chelsea B.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Austiner87, Yesterday, 11:24 AM
                    2 responses
                    12 views
                    0 likes
                    Last Post brucerobinson  
                    Started by Rogers101, 05-05-2024, 11:30 AM
                    3 responses
                    21 views
                    0 likes
                    Last Post Rogers101  
                    Started by nightstalker, 05-04-2024, 02:05 PM
                    5 responses
                    53 views
                    1 like
                    Last Post nightstalker  
                    Started by MSerag, Yesterday, 11:52 PM
                    0 responses
                    11 views
                    0 likes
                    Last Post MSerag
                    by MSerag
                     
                    Started by DynamicTest, Yesterday, 11:18 PM
                    0 responses
                    3 views
                    0 likes
                    Last Post DynamicTest  
                    Working...
                    X