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

Koganan RoundedValue

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

    Koganan RoundedValue

    There's something wrong with the forum, it's extremely slow besides almost impossible to post anything.

    Koganan I had to make this new post to answer:

    I've tried in my code " RoundedValue = Math.Round(value, 6); " but obviously there's something that I'm missing cause when I try to compile it it comes out this error:

    The name 'RoundedValue' does not exist in the current context

    I imagine there's something , library or configuration that I have to meke first before use RoundedValue

    Thanks in advance

    #2
    Hello pstrusi,
    RounedValue is a variable.

    Please modify the code as:
    Code:
    double RoundedValue = Math.Round(value, 6);
    Please let me know if I can assist you any further.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      How to use Math.Round

      Have in mind that I'm not an advance programmer therefore I need to know:

      1. where to declare your instruction (double RoundedValue = Math.Round(value, 6); in order to use it?

      This is a typical code, where does it go?

      #region Variables
      // Wizard generated variables

      #endregion

      protected override void Initialize()
      {
      // whatever
      }

      protected override void OnBarUpdate()
      {
      // code
      }

      #region Properties
      [Description("")]
      [GridCategory("Parameters")]
      public double Slf
      {
      get { return slf; }
      set { slf = Math.Max(0.05, value); }
      }

      [Description("")]
      [GridCategory("Parameters")]
      public double Prf
      {
      get { return prf; }
      set { prf = Math.Max(0.05, value); }
      }
      #endregion


      Thanks in advance

      Comment


        #4
        Hello pstrusi,
        Please send your code to support[AT]ninjatrader[DOT]com so that I can have a look at it.

        Please append Attn:Joydeep in the subject line of the email and give a reference of this thread in the body of the email.

        I look forward to assisting you further.
        JoydeepNinjaTrader Customer Service

        Comment


          #5
          Joydeep, this issue is pretty simple:

          I need to round number off to six meaningful digits after Zero, like: 0.0000xx

          I need to do this in order to avoid false results cause floating point; so you suggest that I use:
          (double RoundedValue = Math.Round(value, 6)

          My question is simple:
          In what parts of a typical code has to go that declaration, and how to use it?

          In "#region Variables" ?
          In protected override void Initialize() ?
          In protected override void OnBarUpdate() ?

          Thanks in advance

          Comment


            #6
            Hello pstrusi,
            Calculations are made in the OnBarUpdate section of the code.

            But everything depends on what exactly you are trying to doing (besides the rounding).

            I look forward to assisting you further.
            JoydeepNinjaTrader Customer Service

            Comment


              #7
              I thank you cause you're trying to help me, so I gonna repeat once again what I intend to do:

              - I work with EUR.USD on interactivebrokers, the ticksize is 0.00005

              - In my code I have to calculate several simple average and differences with Close and Median prices

              - After calculations several averages, I have to compare those results against Zero; I need use just numbers with 6 meaningful digits after zero, like: 0.0000XX, in order to have proper results

              - I need use Math.Round(value, 6) to work with JUST numbers in this format 0.0000XX

              My question is simple:
              WHERE and HOW I should set Math.Round(value, 6) to use it properly ?

              Thanks in advance

              Comment


                #8
                Hello Pier,
                Please find the below code which shows how to round the SMA values.

                The output window (Tools>Output Window) will print out the rounded values and the non-rounded values.

                Please let me know if I can assist you any further.
                Attached Files
                JoydeepNinjaTrader Customer Service

                Comment


                  #9
                  Thanks Joydeep, I going to review your examples

                  Comment


                    #10
                    My issue is solved Joydeep, thanks a lot

                    Best regards

                    Comment


                      #11
                      Hello pstrusi,
                      Glad to know everything is working fine at your end.

                      Please let me know if I can assist you any further.
                      JoydeepNinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Segwin, 05-07-2018, 02:15 PM
                      14 responses
                      1,789 views
                      0 likes
                      Last Post aligator  
                      Started by Jimmyk, 01-26-2018, 05:19 AM
                      6 responses
                      837 views
                      0 likes
                      Last Post emuns
                      by emuns
                       
                      Started by jxs_xrj, 01-12-2020, 09:49 AM
                      6 responses
                      3,293 views
                      1 like
                      Last Post jgualdronc  
                      Started by Touch-Ups, Today, 10:36 AM
                      0 responses
                      13 views
                      0 likes
                      Last Post Touch-Ups  
                      Started by geddyisodin, 04-25-2024, 05:20 AM
                      11 responses
                      63 views
                      0 likes
                      Last Post halgo_boulder  
                      Working...
                      X