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

Memory Leaks?

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

    Memory Leaks?

    Is anyone experiencing inconsistent results when doing many back to back strategy analysis?

    For example, run backtest, change strategy, compile, re-run backtest. But over and over again and then results start to get bizzare.

    I just ran a simple 50ma crossover test (if close above 50, get long, and do opposite if cross below). A total of 66 trades in about 45 days on 30 min chart and it showed I lost 980k. Is that even possible in 66 trades? lol.

    Anyway, I looked at the chart and sure enough it was more accurate, but my results didn't match the trades that were showing on the chart itself under the strategy analyzer.

    I have often found that I need to reboot Ninja after testing for a period of time. Should I be doing some type of deconstruction in my code or does NT tear things down and clean up on my behalf?

    Thanks

    #2
    r2kTrader,

    If you have created your own objects and things like that you will for sure need to dispose of them yourself. http://www.ninjatrader-support.com/H...6/Dispose.html

    Otherwise memory is managed by the .NET garbage collector and is released when .NET deems it necessary.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      This looks more like a bug

      Please see if you can replicate.

      Here is the code, this was done through wizard and is still locked. I am getting wrong results. Showing I lost millions on 50-100 trades with 1 contract:

      protectedoverridevoid Initialize()
      {
      SetProfitTarget(
      "", CalculationMode.Price, Profit);
      CalculateOnBarClose =
      true;
      }
      ///<summary>
      /// Called on each bar update event (incoming tick)
      ///</summary>
      protectedoverridevoid OnBarUpdate()
      {
      // Condition set 1
      if (Close[0] > EMA(MyInput0)[0])
      {
      EnterLong(DefaultQuantity,
      "");
      }
      // Condition set 2
      if (Close[0] < EMA(MyInput0)[0])
      {
      EnterShort(DefaultQuantity,
      "");
      }
      }

      Comment


        #4
        Error appears to be with the Profit Target. When I took that out, it corrects.

        Am I doing something wrong or is this a bug?

        Comment


          #5
          Not following you. What exactly is the issue? Instead of posting snippets, please just post the complete file. Thank you.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            Josh,

            Something is screwed up. I'm not following either because I can't narrow it down.

            I'm on .10

            I setup a simple MA test system using the code above. It's off the strat wiz, so please duplicate.

            It seems any time I put in any type of stop loss, or profit target, the results go bonkers. Example.

            I just tried a simple MA close above/below buy/sell system, straight out of the wiz using EMA. Works ok (I believe), but when I put in StopLoss feature using wiz, it is not correct.

            I set StopLoss in wiz to 40000 (meaning I should get same results as system running without StopLoss method added because I will not draw down the entire price of the russell). But my results are different.

            Frustrated.

            Comment


              #7
              r2kTrader,

              Please attach your strategy here. Unfortunately we do not have the bandwidth to be going off and creating every strategy every customer wants just for testing. If you want us to look at something we will be glad to look at it if you provide the test sample and steps to reproduce. Thank you.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                I tried:

                repairing db
                resetting db
                resetting instr
                clearing account
                deleting strategy and re-creating new one from scratch
                -with ProfitTarget (caused errors)
                -with StopLoss (caused errors)
                -without P or S, seems to be working as it should (seems to be, but can I trust ANYTHING?)

                UPDATE:
                I am feeling pretty sure this is a bug. I just went to my other computer. Built the same strategy, and it's throwing crap results. I don't think I lost 6 million in 30 days on 1 car. But who knows...

                I also noticed that when I went to start the strategy, the default parameter for my Profit variable didn't show up as per what I set it for in the wiz, rather it was just a 1, and not the 100 I set it for as the default when I built the variable.

                Comment


                  #9
                  r2kTrader,

                  Please attach the test strategy.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_Josh View Post
                    r2kTrader,

                    Please attach your strategy here. Unfortunately we do not have the bandwidth to be going off and creating every strategy every customer wants just for testing. If you want us to look at something we will be glad to look at it if you provide the test sample and steps to reproduce. Thank you.
                    Josh,

                    It looks like a bug. Please run through the wiz as per my post. It will take less time than to reply.
                    Attached Files
                    Last edited by r2kTrader; 05-29-2009, 10:44 AM.

                    Comment


                      #11
                      r2kTrader,

                      As stated earlier we cannot create every single strategy every customer wants. Please understand that you are not the only one asking for checks and there is no way we can go off and try and create everything every one wants, no matter how simple or complex the strategy may be.

                      If you want something looked at we are glad to do so, but please provide the test strategy as an attachment along with instructions. We would appreciate it greatly if you fulfilled this request. Thank you for understanding.

                      I will examine your test reference and let you know.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_Josh View Post
                        r2kTrader,

                        Please attach your strategy here. Unfortunately we do not have the bandwidth to be going off and creating every strategy every customer wants just for testing. If you want us to look at something we will be glad to look at it if you provide the test sample and steps to reproduce. Thank you.
                        Josh,

                        With all due respect, I don't have the bandwidth to test NT bugs. I gave explicit instructions on how to duplicate the issue using the wizard and enclosed the based code from which to build the script with the wizard. Ideally, I would want you to build the script from the wizard to see if you can duplicate same.

                        Sending you my code will not truly "duplicate" the issue.

                        Bandwidth is a two-way street. I won't get my hours back.

                        Comment


                          #13
                          Originally posted by NinjaTrader_Josh View Post
                          r2kTrader,

                          As stated earlier we cannot create every single strategy every customer wants. Please understand that you are not the only one asking for checks and there is no way we can go off and try and create everything every one wants, no matter how simple or complex the strategy may be.

                          If you want something looked at we are glad to do so, but please provide the test strategy as an attachment along with instructions. We would appreciate it greatly if you fulfilled this request. Thank you for understanding.

                          I will examine your test reference and let you know.
                          I never ask you for help with my stategies. I may ask you for syntax, but not once have I ever dumped a strategy on you and asked you to debug. I ask for direction. Here I was explicity saying "hey, I think I found a bug". Not "how come my script doesn't work".

                          There is a difference.

                          Please just look into it. I don't use the word "bug" unless there is something that is truly "buggy". I was the one who reported the Replay Datafeed / DOM error that froze the NT. You fixed it a rev or two ago.

                          I don't want to start a flame. I am extremely upset and doing all I can to try to be calm and open minded. There is something wrong and it needs to be loooked at and I narrowed the issue down on my own time before consulting the message board/support. I try to do homework before I bother anyone as I understand the VALUE OF BANDWIDTH.

                          Please let me know where the issue may lie if you find anything.

                          Comment


                            #14
                            r2kTrader,

                            We fully appreciate and thank you for your efforts in trying to isolate issues you encounter. I do understand all you want is for someone to look at your script, but please understand that we cannot spend time going back and forth trying to reproduce scripts. All I am requesting is to simply attach your scripts if it is something you want us to look at.

                            A. You already have the scripts.
                            B. More importantly, there will be no ambiguity as to how you have made your scripts and how to reproduce.

                            It is our experience when trying to reproduce customer scripts that more often than not a critical component is not revealed to the support team until after several back and forths of failing to be able to reproduce customer concerns. Because of this reason we request all customers to simply attach their simple-as-possible, complete scripts and then we will be able to evaluate them.

                            This will be the last I say about this. Thank you for understanding the reasoning behind this policy.

                            Now, back to the important matter. Please consider your strategy which goes long and short. You have in place a single profit target that says "target at price $200" for this instrument. This works fine for longs because let's say you enter the market at $100. That would be a +$100 profit target for it, but now consider the shorts. You enter a short position at $100 then you place a profit target at price = $200. For a short, profit targets actually need to be <$100, but since we placed one at $200 you get filled immediately at that price. Essentially all of your short trades are getting you filled at $200 for a loss of $100 per trade and that quickly aggregates you to the outrageous losses seen on your strategy results. Hopefully that makes sense.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              Josh,

                              See post #10.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by elirion, Today, 09:32 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post elirion
                              by elirion
                               
                              Started by cre8able, Today, 09:15 PM
                              1 response
                              5 views
                              0 likes
                              Last Post bltdavid  
                              Started by cummish, Today, 08:43 PM
                              0 responses
                              9 views
                              0 likes
                              Last Post cummish
                              by cummish
                               
                              Started by Option Whisperer, Today, 07:58 PM
                              4 responses
                              20 views
                              0 likes
                              Last Post Option Whisperer  
                              Started by ETFVoyageur, 05-07-2024, 07:05 PM
                              13 responses
                              87 views
                              0 likes
                              Last Post ETFVoyageur  
                              Working...
                              X