Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Data above or below bar using volumetric bars data order flow chart of NT8.

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

    #46
    My indicator has advanced a lot thanks to your help Brandon.

    Just three more questions. How do you round numbers up? e.g.

    myVolume = VOL()[1]/VOL()[0];

    What if I don't want decimals to display, just rounded up to 1s?

    How do you change the font size?

    And if == is the ninja way of saying equals, what is the way of writing ≠ in ninja?

    I've done a lot of work not written here in the forum, but it's almost done thanks to your help!
    Last edited by Bob-Habanai; 08-25-2022, 06:09 AM. Reason: Less wordy

    Comment


      #47
      Hello Bob-Habanai,

      Thanks for your notes.

      Rounding numbers would fall into C# education. Note that in the Support department at NinjaTrader we cannot provide C# education.

      You could do a quick Google search for something like 'how to round numbers C#' to find publicly available information about how to round numbers when using the C# programming language.


      To change the font size of text drawn using Draw.Text(), you would need to create a SimpleFont variable and use the Draw.Text() syntax that allows you to specify a SimpleFont parameter.

      The syntax could be seen in the Draw.Text() help guide page and also seen below.
      Draw.Text(NinjaScriptBase owner, string tag, bool isAutoScale, string text, int barsAgo, double y, int yPixelOffset, Brush textBrush, SimpleFont font, TextAlignment alignment, Brush outlineBrush, Brush areaBrush, int areaOpacity)

      See this help guide page for more information about SimpleFont and sample code: https://ninjatrader.com/support/help...font_class.htm

      See this help guide page for more information about Draw.Text(): https://ninjatrader.com/support/help.../draw_text.htm


      To compare if one value is not equal to another value, you would use !=. To compare if one value is equal to another value, you would use ==.

      For example:

      Close[0] != Open[0]
      Close[0] == Open[0]



      Let me know if I may assist you further.
      <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


        #48
        Hi Brandon, thanks again for all that.
        I appreciate you can't speak to writing C# itself,
        but in the Ninja script is there a specific place that's allowed to insert round() ​​​​​​?



        Comment


          #49
          Hello Bob-Habanai,

          Thanks for your note.

          If you are referring to using the C# Math.Round method, this could be used within the OnBarUpdate(), OnOrderUpdate(), or OnExecutionUpdate() methods.

          Let me know if I may assist further.
          <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


            #50
            Hi Brandon,

            Two questions.

            Is it possible to pixel size, instead of:
            Code:
            High[0] + 5 * TickSize
            How would that code look?

            I tried the below code, and many other attempts and so far I haven't been able to get the font working.

            Thanks again

            Code:
            protected override void OnStateChange()
            {
            if (State == State.SetDefaults)
            {
            Description = @"Enter the description for your new custom Indicator here.";
            Name = "DrawVolAboveUpBar";
            Calculate = Calculate.OnEachTick;
            IsOverlay = true;
            DisplayInDataBox = true;
            DrawOnPricePanel = true;
            DrawHorizontalGridLines = true;
            DrawVerticalGridLines = true;
            PaintPriceMarkers = true;
            ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
            //Disable this property if your indicator requires custom values that cumulate with each new market data event.
            //See Help Guide for additional information.
            IsSuspendedWhileInactive = true;
            NinjaTrader.Gui.Tools.SimpleFont myFont = new NinjaTrader.Gui.Tools.SimpleFont("Courier New", 12) { Size = 50, Bold = true };
            }
            else if (State == State.Configure)
            {
            }
            }
            
            protected override void OnBarUpdate()
            {
            //assign the VOL[0] indicator value to the double variable
            myVolume = VOL()[0];
            
            //check for up bar and use Draw.Text() to draw variable value on chart
            if (Close[0] > Open[0])
            Draw.Text(this, "vol up bar" + CurrentBar, myVolume.ToString(), 0, High[0] + 5 * TickSize, Brushes.Red, myFont);
            
            //check for download bar and use Draw.Text() to draw variable value on chart
            if (Open[0] > Close[0])
            Draw.Text(this, "vol up bar" + CurrentBar, myVolume.ToString(), 0, Low[0] - 5 * TickSize, Brushes.ForestGreen, myFont);

            Comment


              #51
              Hello Bob-Habanai,

              Thanks for your note.

              You would first need to create a SimpleFont variable. Then, you would define that SimpleFont variable and use the variable for the SimpleFont argument when calling the Draw.Text() method.

              See the attached sample script demonstrating the use of SimpleFont.

              If you would like to draw text to a specific pixel location, you would need to use SharpDX to custom render the text to that specifically calculated location on the chart.

              RenderTarget.DrawText() could be used to custom render text onto a chart. Note that this is considered an advanced programming concept.

              Please thoroughly review this help guide page for information about Using SharpDX to custom render objects on a chart: https://ninjatrader.com/support/help..._rendering.htm

              And, see this help guide page for information about RenderTarget.DrawText: https://ninjatrader.com/support/help...t_drawtext.htm

              We also have a SampleCustomRender indicator that comes default with NinjaTrader that you could reference also. To view the script, open a New > NinjaScript Editor window, open the Indicators folder, and double-click on the SampleCustomRender file.

              Let me know if I may assist further.
              Attached Files
              Last edited by NinjaTrader_BrandonH; 08-29-2022, 08:03 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


                #52
                Hi Brandon,

                I tried following the example script you kindly provided, but this is what resulted...


                Click image for larger version

Name:	Screenshot 2022-08-30 211532.png
Views:	181
Size:	27.5 KB
ID:	1213700

                Comment


                  #53
                  Hello Bob-Habanai,

                  Thanks for your note.

                  This error indicates that you are not using the correct number of arguments when calling your Draw method.

                  How are your calling the Draw.Text() method in your script?

                  You would need to ensure that you are passing in the correct number of arguments when calling the Draw method.

                  You could compare your syntax to the syntax listed in the help guide to see where there might be an issue.

                  The Draw.Text() method that allows you to specify a SimpleFont can be seen in this help guide page and attached below: https://ninjatrader.com/support/help.../draw_text.htm

                  Draw.Text(NinjaScriptBase owner, string tag, bool isAutoScale, string text, int barsAgo, double y, int yPixelOffset, Brush textBrush, SimpleFont font, TextAlignment alignment, Brush outlineBrush, Brush areaBrush, int areaOpacity)

                  or

                  Draw.Text(NinjaScriptBase owner, string tag, bool isAutoScale, string text, DateTime time, double y, int yPixelOffset, Brush textBrush, SimpleFont font, TextAlignment alignment, Brush outlineBrush, Brush areaBrush, int areaOpacity)

                  Note that each syntax option contains a total of 13 arguments. This means that you would need to ensure to pass in 13 arguments when calling your Draw.Text method.

                  Let me know if I may assist further.
                  <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


                    #54
                    Sorry I didn't reply earlier Brandon. I must have been reading late at night. I found a solution in the end that didn't involve SharpDX as like you said,
                    it's an advanced programming concept, but I always appreciate your help!

                    Comment


                      #55
                      Another question,

                      I appreciate all the help with rounding, but how do you round down? i.e. A string is going to divide 7 / 2,
                      and I want it to display 3?

                      Thanks again.

                      Comment


                        #56
                        Hello Bob-Habanai,

                        Thanks for your note.

                        Rounding would require the use of C# methods, not NinjaScript-specific methods, and would go beyond the level of support we provide.

                        To find information about how to round down using C# you could do a Google search for something like 'rounding down C#'. When doing a quick search for this, we can see an example from StackOverflow about how to round down in C#.

                        I have attached the publicly available link to this search result for you to view: https://stackoverflow.com/questions/...earest-integer

                        For further information you would need to do research about rounding down using C#.

                        Please let me know if you have further NinjaScript-specific questions.
                        <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


                          #57
                          Thanks Brandon!

                          Comment


                            #58
                            Originally posted by NinjaTrader_PaulH View Post
                            Hello avrege,

                            Thanks for your reply.

                            In that case then you would need to add Volumetric bars to your script using AddVolumetric() and segment your code for BarsInProgress. here is the same example as previous but adding volumetric bars to the script and segmenting the code as needed:

                            Click image for larger version

Name:	avrege-2.PNG
Views:	1387
Size:	135.5 KB
ID:	1088249

                            In both cases the help guide provide the references needed for using on a volumetric chart or using volumetric bars in a script for a non volumetric chart:

                            https://ninjatrader.com/support/help...tric_bars2.htm
                            Thanks NinjaTrader_PaulH for that. Seems you used a series for MaxSeen and MinSeen Delta on the candlestick chart? Otherwise would not be possible I assume. That is what code looks like to me.

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                            0 responses
                            636 views
                            0 likes
                            Last Post Geovanny Suaza  
                            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                            0 responses
                            366 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by Mindset, 02-09-2026, 11:44 AM
                            0 responses
                            107 views
                            0 likes
                            Last Post Mindset
                            by Mindset
                             
                            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                            0 responses
                            569 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by RFrosty, 01-28-2026, 06:49 PM
                            0 responses
                            571 views
                            1 like
                            Last Post RFrosty
                            by RFrosty
                             
                            Working...
                            X