Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Same strategy, different ninjascript, different results

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

    #16
    Originally posted by NGorodzhiy View Post
    I do. CrossAbove and CrossBelow is his version of ">" and "<".
    They are not, and they do not become so by our saying so. A "CrossAbove" does NOT mean "Greater than". Your results, in and of themselves, are proof of the difference.

    Comment


      #17
      I changed it, no difference.

      Comment


        #18
        NinjaTrader customer service, please look into this issue.

        Comment


          #19
          Originally posted by NGorodzhiy View Post
          I changed it, no difference.
          So post your new formulation.

          Did you compile the changes after you made them?

          Comment


            #20
            Probably has the rsi changes still.

            Comment


              #21
              Hello NGorodzhiy,

              Koganam is correct here, so thanks to them for catching that.

              Sledge could also be onto something here.

              As koganam asked, did you compile? And can you provide your new edited code?

              Comment


                #22
                I compiled the code. I have made the changes, there are changes in results but not close to my friend's results.

                Code:
                protected override void OnBarUpdate()
                        {
                			//Enter long
                			if(Close[0] > SMA(200)[0] && RSI(2, 0)[0] <= 10);
                			{
                			EnterLong(DefaultQuantity, "Long");
                			}
                			//Enter short 
                			if(Close[0] < SMA(200)[0] && RSI(2, 0)[0] >= 90);
                			{
                			EnterShort(DefaultQuantity, "Short");
                			}
                			//Exit long
                			if(RSI(2, 0)[0] > 50);
                			{
                			ExitLong("Exit Long", "");
                			}
                			//Exit short
                			if(RSI(2, 0)[0] < 50);
                			{
                			ExitShort("Exit Short", "");
                			}
                        }

                Comment


                  #23
                  Originally posted by NGorodzhiy View Post
                  I compiled the code. I have made the changes, there are changes in results but not close to my friend's results.

                  Code:
                  protected override void OnBarUpdate()
                          {
                  			//Enter long
                  			if(Close[0] > SMA(200)[0] && RSI(2, 0)[0] <= 10);
                  			{
                  			EnterLong(DefaultQuantity, "Long");
                  			}
                  			//Enter short 
                  			if(Close[0] < SMA(200)[0] && RSI(2, 0)[0] >= 90);
                  			{
                  			EnterShort(DefaultQuantity, "Short");
                  			}
                  			//Exit long
                  			if(RSI(2, 0)[0] > 50);
                  			{
                  			ExitLong("Exit Long", "");
                  			}
                  			//Exit short
                  			if(RSI(2, 0)[0] < 50);
                  			{
                  			ExitShort("Exit Short", "");
                  			}
                          }
                  That code is now completely equivalent to your friend's code. The only possible reason that you do not get the same results is because your data is different.
                  • Do you two use the exact same data provider?
                  • Are your test "date ranges" exactly the same?

                  If your comparison tests are actually all on your own computer, rather that a comparison of your friend's to yours, you might try downloading all data afresh before you run the tests.

                  The only other suggestion is to compare the trades that are being taken. They will not be the same, and likely they will not even be the same number of trades. Once you have that data, you should be able to see what is really going on. Sometimes it does get hairy trying to track this stuff down. Just keep at it.

                  Comment


                    #24
                    Results are still different. I am testing everything from the same computer, connected to Kinetick. I uploaded charts from the different strategies. "Radin - chart" is my friend's, "Nikita - chart" is mine. Maybe by looking at the charts you will figure out how to solve this. Thanks for the help.
                    Attached Files

                    Comment


                      #25
                      Please help me fix it, the results are still different. I am getting frustrated because I and everyone thinks the ninjascript is the same, but the results are coming out different.

                      Comment


                        #26
                        I am trying to enter a position long when a the close price is larger than the 200 period SMA and when the RSI is below 10. I would exit when the RSI is above 50. When going short, everything is reversed. The problem is that it is avoiding the SMA and still entering the trades. How to fix it? I have attached an image so it is easier to understand.
                        Attached Files

                        Comment


                          #27
                          Originally posted by NGorodzhiy View Post
                          I compiled the code. I have made the changes, there are changes in results but not close to my friend's results.

                          Code:
                          protected override void OnBarUpdate()
                                  {
                                      //Enter long
                                      if(Close[0] > SMA(200)[0] && RSI(2, 0)[0] <= 10);  [COLOR=Red]// <-- remove ; here[/COLOR]
                                      {
                                      EnterLong(DefaultQuantity, "Long");
                                      }
                                      //Enter short 
                                      if(Close[0] < SMA(200)[0] && RSI(2, 0)[0] >= 90);  [COLOR=Red]// <-- remove ; here[/COLOR]
                                      {
                                      EnterShort(DefaultQuantity, "Short");
                                      }
                                      //Exit long
                                      if(RSI(2, 0)[0] > 50);   [COLOR=Red]// <-- remove ; here[/COLOR]
                                      {
                                      ExitLong("Exit Long", "");
                                      }
                                      //Exit short
                                      if(RSI(2, 0)[0] < 50);  [COLOR=Red]// <-- remove ; here[/COLOR]
                                      {
                                      ExitShort("Exit Short", "");
                                      }
                                  }
                          That's because the two pieces of code are not the same.

                          Remove the semi-colons from the end of the conditionals of all your if statements.

                          Seriously (not trying to be sarcastic) learn about C# programming. It is obvious that you have little experience programming, this is a very VERY rookie mistake. To correct that brain deficiency, you should spend a few hours using google, and do some reading. There are tons of useful and helpful websites just waiting to teach you basic rules of C# programming.

                          http://lmgtfy.com/?q=c%23+programming+tutorial

                          For ex, start with "The Basics" on the right hand side of this page:

                          http://csharp.net-tutorials.com/basics/if-statement/

                          or download their entire tutorial as a PDF (see upper right link).

                          If you didn't know before that C# is VERY specific about where you place semi-colons, well, now you know.

                          Comment


                            #28
                            Thank you so much! I know I am bad at C#, I just started learning. I am learning via Microsoft virtual school, they have great tutorials. Thanks for the tips anyways.

                            Comment


                              #29
                              Look here,



                              scroll down to "The Phantom Semi-Colon" ...

                              Comment


                                #30
                                No problem.

                                As a beginner, I cannot stress enough the importance of indenting your code to recognize control flow. As you learn and grow, you should adopt a personal mandate to always write correctly indented code, as well as fix indention of code sent to you for consultation *before you start reading it*.

                                For that last part, there are actual programs that will auto-indent your code, they're known as code "beautifiers" or code "pretty-printers".

                                So, if you had to beautify 1000s of lines of code, say, to fix the indention, you'd want an automated way to do that.

                                My point is: such an automated program immediately points out this kind of rookie mistake of the phantom semi-colon.

                                My second point is: use this feature of a C# beautifier program to help you find problems with your code. When it's 2am and your eyes (and your friend's eyes) can't find it, such a program could be very useful.

                                Look at the search results for:
                                For all those people who find it more convenient to bother you with their question rather than to Google it for themselves.

                                Comment

                                Latest Posts

                                Collapse

                                Topics Statistics Last Post
                                Started by argusthome, 03-08-2026, 10:06 AM
                                0 responses
                                91 views
                                0 likes
                                Last Post argusthome  
                                Started by NabilKhattabi, 03-06-2026, 11:18 AM
                                0 responses
                                48 views
                                0 likes
                                Last Post NabilKhattabi  
                                Started by Deep42, 03-06-2026, 12:28 AM
                                0 responses
                                31 views
                                0 likes
                                Last Post Deep42
                                by Deep42
                                 
                                Started by TheRealMorford, 03-05-2026, 06:15 PM
                                0 responses
                                34 views
                                0 likes
                                Last Post TheRealMorford  
                                Started by Mindset, 02-28-2026, 06:16 AM
                                0 responses
                                69 views
                                0 likes
                                Last Post Mindset
                                by Mindset
                                 
                                Working...
                                X