Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simulator is out of sync

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

    Simulator is out of sync

    Hi there. I'm starting to test strategies using the simulator for the first time. While running my own strategies, I noticed unexpected behavior; notably, there were too many orders being placed and the positions got larger than I expected (e.g. if I had a position size of 500 I was ending up with 1000 and 1500 shares short).

    To try and understand what the problem might be, I ran the SampleMACrossover strategy with 1 min/5 min just to generate a lot of orders. When the strategy starts, it thinks it is long (assuming of course 1MA > 5MA), but does not actually place an order to get there. Then, when the next crossover occurs, it does place an order to close the position, and then the additional short order. The strategy thinks it is 100S, while the account thinks it is 200S because the initial long order was never placed.

    Is this a bug or am I misunderstanding something?

    Thanks.

    Pete

    #2
    You are misunderstanding.

    A strategy position independant from an account position, in this case Sim101. As you start your strategy, it may be flat, long or short. NinjaTrader will NOT submit orders to synchronize your account position with your strategy position. You have to do this manually. For example, if you strategy starts and is 1 long and your simulation account is flat. If you want the two to be synchronized, you must place a buy order for 1 contract via the Order panel in the Control Center window.

    We will be publishing additional information on this shortly.
    RayNinjaTrader Customer Service

    Comment


      #3
      But then why does it place the order to close that initial position? It is in fact assuming that the two are synchronized.

      I can't see a good reason for this behavior, but I admit I am new to this. Rather than risk synchronization problems, why not provide an option to just place the initial order automatically when you run the strategy?

      Finally, is this an aspect of the simulator or would this same behavior occur against my live account?

      Thanks.

      Comment


        #4
        A strategy runs indpendant of an account position. There is no assuming its synchronized, its just executing its own logic.

        There are many reasons for this however, you do have the option to run your strategy in a mode where NO orders are sent until the strategy reaches a flat state. This is set under Tools > Options > Strategies.

        The same behaviour will occure in a live account.
        RayNinjaTrader Customer Service

        Comment


          #5
          First of all, thanks for your patience in discussing this with me.

          I thought about this for a while yesterday. I suspect if you are going to be running strategies that last longer than a session, you would want the current behavior, so you can stop strategies without having to place extra trades.

          If you're going to be running intraday strategies and always flattening when you exit, and let's say running on 5 symbols at once, it would be less than ideal to have to place manual orders.

          I think I've come up with a workaround for my purposes, which will be more along the 2nd scenario. I'll just check if ExitOnClose is true in my code. If it is, I'll place the first order myself in the code in the first OnBarUpdate.

          Does that sound correct? I'll of course test this myself, just want to make sure conceptually it would be the right approach.

          Thanks.

          Comment


            #6
            Not sure I completely follow. The only approach is to ensure that your strategy is flat when it is started. You could do this by doing something like:

            if (Historical)
            return;
            RayNinjaTrader Customer Service

            Comment


              #7
              Just to close the loop on this...I figured out what the second problem was after some debugging.

              I have about 8 conditions that get checked in my strategy. Let's say 2 of those would potentially trigger the closing of a long position, and 1 would trigger the opening of a short position. I was just firing all of those method calls, and assuming the order management layer would straighten it out given my settings on EntriesPerDirection. This is in fact not the case. If I want to close a long position and open a short position on the same bar, I need to call EnterShort and let the system figure out closing the long position.

              That wasn't completely obvious to me from the documentation. If you don't do this, like I said, you end up with multiples of your intended position amount.

              Comment


                #8
                I'd like to understand this better.

                Were you using "EntriesPerDirection=1" along with "EntryHandling=AllEntries"?

                If so, according to the documentation, there should be no way that you'd get more than one trade at a time.

                If, on the other hand, you had "EntriesPerDirection=1" along with "EntryHandling=UniqueEntries", you could have as many simultaneous trades as you have different signalName values specified when invoking the EnterLong method.

                So, taking that into account, does your scenario show that this is not working as documented?
                Last edited by KBJ; 11-04-2007, 11:53 PM. Reason: Corrected typo as mentioned by Pete S. in subsequent post.

                Comment


                  #9
                  KBJ -- Assuming you meant AllEntries the first time (you said Unique both times), then yes, that's what I'm saying. I would get multiple trades in the same direction. When I intended to get 2 trades, 1 to close a position and 1 to go to the other side, I would instead get 3: my trade to close the position, NT's trade to close the position, and the trade to open the position. This may be intended behavior, just clarifying what I saw in case it comes up for anyone else.

                  Pete

                  Comment


                    #10
                    Pete: Thanks for pointing that out. Yes, that is what I meant. I've edited the post so it doesn't cause confusion for others.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by RookieTrader, Today, 09:37 AM
                    3 responses
                    15 views
                    0 likes
                    Last Post NinjaTrader_ChelseaB  
                    Started by kulwinder73, Today, 10:31 AM
                    0 responses
                    5 views
                    0 likes
                    Last Post kulwinder73  
                    Started by terofs, Yesterday, 04:18 PM
                    1 response
                    23 views
                    0 likes
                    Last Post terofs
                    by terofs
                     
                    Started by CommonWhale, Today, 09:55 AM
                    1 response
                    3 views
                    0 likes
                    Last Post NinjaTrader_Erick  
                    Started by Gerik, Today, 09:40 AM
                    2 responses
                    7 views
                    0 likes
                    Last Post Gerik
                    by Gerik
                     
                    Working...
                    X