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

printing "0"

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

    printing "0"

    NT 8090

    I'm adding together four int variables and printing the result on my charts. But when the result is "0", the 0 doesn't print--it leaves a blank space.

    How do I print a "0" when the result is 0?

    Thank you.

    #2
    Originally posted by imalil View Post
    NT 8090

    I'm adding together four int variables and printing the result on my charts. But when the result is "0", the 0 doesn't print--it leaves a blank space.

    How do I print a "0" when the result is 0?

    Thank you.
    Try printing it as a string.
    RJay
    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

    Comment


      #3
      Hello imalil,

      Thanks for your post.

      As RJay has advised you can print as a string, for example:

      if ( x1+X2+x3+x4 == 0)
      Print ("Result is zero");
      else
      Print("Result is "+( x1+X2+x3+x4).ToString());
      Paul H.NinjaTrader Customer Service

      Comment


        #4
        Thanks. But I'm not talking about printing "Result is zero" in the output window. As I wrote, I want to print "0" on my charts, above or below a bar.

        Isn't there a simple way to do this using my existing if statement?

        Thank you.

        Comment


          #5
          Originally posted by imalil View Post
          Thanks. But I'm not talking about printing "Result is zero" in the output window. As I wrote, I want to print "0" on my charts, above or below a bar.

          Isn't there a simple way to do this using my existing if statement?

          Thank you.
          Post the line of code that is not working for you.
          RJay
          NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

          Comment


            #6
            Originally posted by imalil View Post
            Thanks. But I'm not talking about printing "Result is zero" in the output window. As I wrote, I want to print "0" on my charts, above or below a bar.

            Isn't there a simple way to do this using my existing if statement?

            Thank you.
            It makes no sense. If you can print a "1" above or below a bar, you should be able to print a "0".

            Comment


              #7
              Hello imalil,

              Thanks for your reply.

              My example was provided as you did not show what code you are using. The concept I was providing was to evaluate the condition and if 0 do one thing and if not 0 do something else.

              If the concept does not help then please post the specific code you are using.
              Paul H.NinjaTrader Customer Service

              Comment


                #8
                I feel like this is getting more complex than it should be. I have this:

                int totalOutOfBal = var1 + var2 + var3 + var4;

                The value of each variable, var1 to 4, can either be 1 or 0. For each bar, var1 to 4 are added together and printed above or below the bar using a draw.text statement:

                (+ totalOutOfBal).ToString("#")

                When the result is 1, 2, 3, or 4, it prints fine. But when the result is 0, the 0 does not print; there is nothing printed above or below the bar.

                All I want is for the 0 to print when the result is 0. How do I do that?

                Thank you.

                Comment


                  #9
                  I agree with you 100%, Sledge. That's why I'm asking the question.

                  Comment


                    #10
                    Originally posted by imalil View Post
                    I feel like this is getting more complex than it should be. I have this:

                    int totalOutOfBal = var1 + var2 + var3 + var4;

                    The value of each variable, var1 to 4, can either be 1 or 0. For each bar, var1 to 4 are added together and printed above or below the bar using a draw.text statement:

                    (+ totalOutOfBal).ToString("#")

                    When the result is 1, 2, 3, or 4, it prints fine. But when the result is 0, the 0 does not print; there is nothing printed above or below the bar.

                    All I want is for the 0 to print when the result is 0. How do I do that?

                    Thank you.
                    Replace the "#" with a "0"
                    RJay
                    NinjaTrader Ecosystem Vendor - Innovative Trading Solutions

                    Comment


                      #11
                      Learn how to create a custom numeric format string to format numeric data in .NET. A custom numeric format string has one or more custom numeric specifiers.


                      Details on #

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by The_Sec, Today, 02:29 PM
                      1 response
                      5 views
                      0 likes
                      Last Post NinjaTrader_Jesse  
                      Started by jeronymite, 04-12-2024, 04:26 PM
                      2 responses
                      30 views
                      0 likes
                      Last Post NinjaTrader_BrandonH  
                      Started by Mindset, 05-06-2023, 09:03 PM
                      10 responses
                      265 views
                      0 likes
                      Last Post NinjaTrader_BrandonH  
                      Started by michi08, 10-05-2018, 09:31 AM
                      5 responses
                      743 views
                      0 likes
                      Last Post NinjaTrader_ChelseaB  
                      Started by tsantospinto, 04-12-2024, 07:04 PM
                      4 responses
                      63 views
                      0 likes
                      Last Post aligator  
                      Working...
                      X