Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

converting code from Draw.Text to Draw.TextFixed

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

    converting code from Draw.Text to Draw.TextFixed

    Hi all,
    I would appreciate converting the following code to print the high value of prior/current bars at the top right corner of chart, and the lows a the lower right corner of chart next to each other PH: CH: PL: CL:
    I am not a programmer, and trying to chnage that code from Draw.text to Draw.Textfixed

    would appreciate your help


    Draw.Text(this,"ch", true, currentHigh.ToString(), -5, High[0], 25, Brushes.Blue, iTextFont, TextAlignment.Left, Brushes.Transparent, Brushes.Transparent, 0);
    Draw.Text(this,"cl", true, currentLow.ToString(), -5, Low[0], -25, Brushes.DarkRed, iTextFont, TextAlignment.Left, Brushes.Transparent, Brushes.Transparent, 0);
    Draw.Text(this,"ph", true, previousHigh.ToString(), -5, High[0], 25, Brushes.Blue, iTextFont, TextAlignment.Right, Brushes.Transparent, Brushes.Transparent, 0);
    Draw.Text(this,"pl", true, previousLow.ToString(), -5, Low[0], -25, Brushes.DarkRed, iTextFont, TextAlignment.Right, Brushes.Transparent, Brushes.Transparent, 0);​
    Last edited by GussJ; 10-18-2023, 09:09 AM.

    #2
    Hello GussJ,

    Thanks for your post.

    The Draw.TextFixed() syntax you would need to use could be found below.

    Draw.TextFixed(NinjaScriptBase owner, string tag, string text, TextPosition textPosition, Brush textBrush, SimpleFont font, Brush outlineBrush, Brush areaBrush, int areaOpacity)

    To draw the text on the top right corner of the chart, you could set the TextPosition argument to TextPosition.TopRight when calling Draw.TextFixed().

    To draw the test on the bottom right corner of the chart, you could set the TextPosition argument to TextPosition.BottomRight when calling Draw.TextFixed().

    You could consider consolidating the low values to one Draw.TextFixed() method on the high values to a second Draw.TextFixed() method.

    For example, the code to draw the high values might look something like this:

    Draw.TextFixed(this, "chph", "Current High: " + currentHigh.ToString() + " : Prev High: " + previousHigh.ToString(), TextPosition.TopRight, Brushes.Blue, iTextFont, Brushes.Transparent, Brushes.Transparent, 0);

    See this help guide documentation for more information about Draw.TextFixed(): https://ninjatrader.com/support/help..._textfixed.htm
    Last edited by NinjaTrader_BrandonH; 10-18-2023, 09:32 AM.
    <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

    Comment


      #3
      Originally posted by NinjaTrader_BrandonH View Post
      Hello GussJ,

      Thanks for your post.

      The Draw.TextFixed() syntax you would need to use could be found below.

      Draw.TextFixed(NinjaScriptBase owner, string tag, string text, TextPosition textPosition, Brush textBrush, SimpleFont font, Brush outlineBrush, Brush areaBrush, int areaOpacity)

      To draw the text on the top right corner of the chart, you could set the TextPosition argument to TextPosition.TopRight when calling Draw.TextFixed().

      To draw the test on the bottom right corner of the chart, you could set the TextPosition argument to TextPosition.BottomRight when calling Draw.TextFixed().

      You could consider consolidating the low values to one Draw.TextFixed() method on the high values to a second Draw.TextFixed() method.

      For example, the code to draw the high values might look something like this:

      Draw.TextFixed(this, "chph", currentHigh.ToString() + " : " + previousHigh.ToString(), TextPosition.TopRight, Brushes.Blue, iTextFont, Brushes.Transparent, Brushes.Transparent, 0);

      See this help guide documentation for more information about Draw.TextFixed(): https://ninjatrader.com/support/help..._textfixed.htm
      I am not a programmer,, Can you pls change one of the lines as an example, as I am not familiar with the language

      Thanks

      Comment


        #4
        Hello GussJ,

        Thanks for your notes.

        In post # 2 I gave an example of consolidating the highs to a single Draw.TextFixed() method.

        This:

        Draw.Text(this,"ch", true, currentHigh.ToString(), -5, High[0], 25, Brushes.Blue, iTextFont, TextAlignment.Left, Brushes.Transparent, Brushes.Transparent, 0);
        Draw.Text(this,"ph", true, previousHigh.ToString(), -5, High[0], 25, Brushes.Blue, iTextFont, TextAlignment.Right, Brushes.Transparent, Brushes.Transparent, 0);


        Was converted to the code below:

        Draw.TextFixed(this, "chph", "Current High: " + currentHigh.ToString() + " : Prev High: " + previousHigh.ToString(), TextPosition.TopRight, Brushes.Blue, iTextFont, Brushes.Transparent, Brushes.Transparent, 0);​​


        If you need someone to write this script for you and add this method call on your behalf, you can also contact a professional NinjaScript Consultant who would be eager to create or modify this script at your request or assist you with your script.

        You can search our extensive library of NinjaScript consultants through the link below. Simply enter a consultant name or search by using our filter categories. Once you have identified your consultants of choice, please visit each consultant's site for more information or contact them directly to learn more!

        https://ninjatraderecosystem.com/sea...mming-services

        Educators - https://ninjatraderecosystem.com/sea...ures=education

        You can locate the contact information for the consultants on their direct websites for any additional questions you may have. Since these consultants are third-party services for NinjaTrader, all pricing and support information will need to be obtained through the consultant.

        This NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The companies and services listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.​​
        Last edited by NinjaTrader_BrandonH; 10-18-2023, 09:32 AM.
        <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

        Comment


          #5
          THanks Brandon,
          I used your line with combined values, I am getting an error, No overload for method text takes 9 argument CODE CS1501 line 92 Column 5
          although line 92 is blank whee I deleted original line
          Help appreciated

          Comment


            #6
            Hello GussJ,

            Thanks for your notes.

            When testing the code on my end I am not seeing any compile errors appear.

            I attached a simple example script demonstrating what this line of code might look like in an indicator.

            You could compare the code in the attached script to your script to see where differences might be for this method.

            Otherwise, it is possible that the error is being caused by some other line of code in the script. If this is the case. you would need to debug the script to locate the exact line of code causing the error.

            You could comment out the Draw.Text() and Draw.TextFixed() methods in your script one at a time and run a compile to see if the error persists. Once you comment out a line of code and the error stops, it is likely that last commented out section of code that was causing the error.
            Attached Files
            <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

            Comment


              #7
              Thanks Brandon
              it seems there was an error in another copy of the indicator that was causing this issue, so deleted it. and got it to work,
              But it is only drawing the Bar lows values only not the bar highs for some reason.would appreciate taking a look at the script.
              attached is the updated script if you can take a look at it.
              As for your test script it worked fine on the upper chart and showed the values as needed.

              Looking forward to hearing from you





              Attached Files

              Comment


                #8
                Hello GussJ,

                Thanks for your notes.

                You are using the same exact tag name for the Draw.TextFixed() method to draw the high values and for the Draw.TextFixed() method to draw the low values. This is why the Draw.TextFixed() method to draw the low values is appearing but not the Draw.TextFixed() to draw the high values.

                Each Draw.TextFixed() method should have a unique tag name.

                In the Draw.TextFixed() method to draw the low values on the chart, change the Tag name from "chph" to something like "clpl".
                <span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>

                Comment


                  #9
                  Originally posted by NinjaTrader_BrandonH View Post
                  Hello GussJ,

                  Thanks for your notes.

                  You are using the same exact tag name for the Draw.TextFixed() method to draw the high values and for the Draw.TextFixed() method to draw the low values. This is why the Draw.TextFixed() method to draw the low values is appearing but not the Draw.TextFixed() to draw the high values.

                  Each Draw.TextFixed() method should have a unique tag name.

                  In the Draw.TextFixed() method to draw the low values on the chart, change the Tag name from "chph" to something like "clpl".
                  got it thanks a lot, much appreciated

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  599 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  344 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  103 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  558 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  557 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X