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

What is Input ?

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

    #16
    Hello,

    Can you please elaborate on your post?

    If you feel there are logical errors in the code you had provided, please provide a specific explanation of the logical issue you have found as well as your solution to correct it. Also please provide the way this conclusion was reached so I can review the total details of what you are saying.

    Our support and Members are here to assist but we would need to know the full details of what you are asking before we could assist in any way. Please provide more details on your post and what the questions is related to the code that was posted.

    Please let me know if I may be of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #17
      Originally posted by BankRobber View Post
      Let's get the answer from the Ninja team first, then we'll see do i understand or not.
      What does NT support Team have to do with the logic of code? Any programmer can evaluate the logic of code. NT support is not the ultimate determinant of logic validity.

      Comment


        #18
        Originally posted by BankRobber View Post
        Let's get the answer from the Ninja team first, then we'll see do i understand or not.
        They cannot answer, because you did not ask any question. You just cried "Foul".

        Comment


          #19
          Originally posted by Harry View Post
          They cannot answer, because you did not ask any question. You just cried "Foul".
          OK, I'll ask...

          Could anyone PLEASE explain to me the purpose of Math.Min 3 TIMES in the code??

          P.S. if you put more weight on the back of the SNAIL, do you think the snail will run any faster?
          Last edited by BankRobber; 08-25-2015, 10:10 AM.

          Comment


            #20
            It allows the indicator to process during the first bars of the chart, before there are 'Period' bars available.
            eDanny
            NinjaTrader Ecosystem Vendor - Integrity Traders

            Comment


              #21
              Originally posted by BankRobber View Post
              OK, I'll ask...

              Could anyone PLEASE explain to me the purpose of Math.Min 3 TIMES in the code??

              The second time Math.Min(Currentbar, Period) is used it is not necessary. You can simply replace it with Period.

              This would simplify the code:

              Code:
              if (CurrentBar == 0)
                  Value.Set(Input[0]);
              else
              {
                  double last = Value[1] * Math.Min(CurrentBar, Period);
                  if (CurrentBar >= Period)
                      Value.Set((last + Input[0] - Input[Period]) / Period);
                 else
                      Value.Set((last + Input[0]) / (Math.Min(CurrentBar, Period) + 1));
              }
              That said, the original code also works without any flaws, in despite of the redundancy.

              Comment


                #22
                Hello,

                The Math.Min method in C# returns the value of the smaller of the two numbers supplied.

                The purpose of their use in this case would be if the CurrentBar is less than the Period selected, the Currentbar value is used otherwise the Period value is used.

                Please let me know if you have further questions.
                JesseNinjaTrader Customer Service

                Comment


                  #23
                  Originally posted by Harry View Post
                  The second time Math.Min(Currentbar, Period) is used it is not necessary. You can simply replace it with Period.

                  This would simplify the code:

                  Code:
                  if (CurrentBar == 0)
                      Value.Set(Input[0]);
                  else
                  {
                      double last = Value[1] * Math.Min(CurrentBar, Period);
                      if (CurrentBar >= Period)
                          Value.Set((last + Input[0] - Input[Period]) / Period);
                     else
                          Value.Set((last + Input[0]) / (Math.Min(CurrentBar, Period) + 1));
                  }
                  That said, the original code also works without any flaws, in despite of the redundancy.
                  NOT bad, how about you stop checking is it BAR 0 on every single bar.

                  And how about you kick out ALL of the math. min?

                  Comment


                    #24
                    Originally posted by NinjaTrader_Jesse View Post
                    Hello,

                    The Math.Min method in C# returns the value of the smaller of the two numbers supplied.

                    The purpose of their use in this case would be if the CurrentBar is less than the Period selected, the Currentbar value is used otherwise the Period value is used.

                    Please let me know if you have further questions.
                    You COULD already know which one is higher

                    Comment


                      #25
                      Hello,

                      It looks like there is no actual problem here so I will just watch the thread from here out.

                      The indicator in question is just a stock SMA that comes with the platform. You can certainly recreate this as you need to. NinjaScript is designed specifically for this task so that you can modify existing scripts or you can create your own entirely.

                      If there is no actual error you can provide on this topic, I will leave the discussion so you can collaborate with the other members on your SMA ideas.

                      Please let me know if I may be of further assistance.
                      JesseNinjaTrader Customer Service

                      Comment


                        #26
                        Originally posted by NinjaTrader_Jesse View Post
                        Hello,

                        It looks like there is no actual problem here so I will just watch the thread from here out.

                        The indicator in question is just a stock SMA that comes with the platform. You can certainly recreate this as you need to. NinjaScript is designed specifically for this task so that you can modify existing scripts or you can create your own entirely.

                        If there is no actual error you can provide on this topic, I will leave the discussion so you can collaborate with the other members on your SMA ideas.

                        Please let me know if I may be of further assistance.

                        This is a perfect example of bad coding practice.
                        The problem here is speed. Sure, this is just one small indicator. But What happens when you start compounding these bad coding practices inside the Ninja Core?
                        You guys didn't care to change this in 10 years?
                        The snail can't take anymore weight on his tiny shoulder.

                        I'm little tired of tweeks and hacks just to achieve what i want.

                        Comment


                          #27
                          Originally posted by BankRobber View Post
                          You COULD already know which one is higher
                          Yes, one could. with an if ... else block. Look in the MSIL, and it is coded no different. Math.Min() is simply shorthand for the equivalent if...else block.
                          Last edited by koganam; 08-25-2015, 12:12 PM.

                          Comment


                            #28
                            Originally posted by BankRobber View Post
                            This is a perfect example of bad coding practice.
                            The problem here is speed. Sure, this is just one small indicator. But What happens when you start compounding these bad coding practices inside the Ninja Core?
                            You guys didn't care to change this in 10 years?
                            The snail can't take anymore weight on his tiny shoulder.

                            I'm little tired of tweeks and hacks just to achieve what i want.
                            In this case, not quite. But certainly if one is using loops instead of simple branches.

                            I have had to recode some of the stock indicators in order to avoid loops, so I very much agree on your general perspective about coding practice. It is just not the case in this instance.

                            Comment


                              #29
                              Originally posted by koganam View Post
                              Yes, on ecould. with an if ... else block. Look in the MSIL, and it is coded no different. Math.Min() is simply shorthand for the equivalent if...else block.
                              int NinjaTurtle = CurrentBar; //
                              int Snail = Period; //

                              if (NinjaTurtle >= Snail)
                              Value.Set((Value[1] * Snail + Input[0] - Input[Snail]) / Snail); //NO need for Math.Min

                              EDIT: this is not the complete code, as one of the guys said "Any programmer can guess the rest of the code"


                              Oh man, I love Colorado, there is so much fun down there;-)
                              Last edited by BankRobber; 08-25-2015, 12:51 PM.

                              Comment


                                #30
                                Originally posted by BankRobber View Post
                                int NinjaTurtle = CurrentBar; //
                                int Snail = Period; //

                                if (NinjaTurtle >= Snail)
                                Value.Set((Value[1] * Snail + Input[0] - Input[Snail]) / Snail); //NO need for Math.Min

                                Oh man, I love Colorado, there is so much fun down there;-)
                                That is an if...else block, with a null else branch. Same thing.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by RookieTrader, Today, 07:41 AM
                                1 response
                                5 views
                                0 likes
                                Last Post NinjaTrader_ChelseaB  
                                Started by kujista, Today, 05:44 AM
                                1 response
                                9 views
                                0 likes
                                Last Post NinjaTrader_ChelseaB  
                                Started by elderan, Yesterday, 08:03 PM
                                1 response
                                12 views
                                0 likes
                                Last Post NinjaTrader_BrandonH  
                                Started by samish18, Yesterday, 08:57 AM
                                8 responses
                                25 views
                                0 likes
                                Last Post samish18  
                                Started by DJ888, 04-16-2024, 06:09 PM
                                3 responses
                                10 views
                                0 likes
                                Last Post NinjaTrader_Erick  
                                Working...
                                X