Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EntriesPerDirection Error

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

    EntriesPerDirection Error

    I'm testing out a strategy and had an unexpected entry. Last night the strategy was running and entered a position. After my broker reset I had to (argh!) restart NT and setup my strategies again. Later, the strategy entered an additional position even though EntriesPerDirection is 1.

    How do I prevent this from happening?

    Code:
    1/29/2009 23:53    Default    Verifying license at primary server...    
    1/29/2009 23:53    Default    Current license: Type=Regular State=Verified StartDate=10/17/2008 EndDate=12/30/2099 Collective2 Dtn ESignal External OpenTick Provider2 Replay Simulator Yahoo Gain MBTrading AutomatedTrading AdvancedStrategyManagement BasicEntry Charting LiveTrading SystemDevelopment    
    1/29/2009 23:53    Default    Session Break (Version 6.5.1000.8)    
    1/29/2009 23:53    Default    Automated trading disabled    
    1/29/2009 23:53    Connection    MBTrading: Primary connection=Connecting     Price feed=Connecting
    1/29/2009 23:53    Default    Connected to quote server (prc130)    
    1/29/2009 23:53    Default    Connected to order server    
    1/29/2009 23:53    Default    Forex: Maintenance completed     trading resumed.
    1/29/2009 23:53    Default    Connected to perm server    
    1/29/2009 23:53    Connection    MBTrading: Primary connection=Connected     Price feed=Connected
    1/29/2009 23:53    Position    Instrument='$USDCAD' Account='C2Test' Avg price=1.2266 Quantity=0.01M Market position=Long    
    1/29/2009 23:54    Connection    ESignal: Primary connection=Connecting     Price feed=Connecting
    1/29/2009 23:54    Connection    ESignal: Primary connection=Connected     Price feed=Connected
    1/29/2009 23:58    Strategy    Starting NinjaScript strategy 'NMAStrat/f6819c13f034450e9c9ecdc9424c0fc7' : On starting a real-time strategy - StrategySync=WaitUntilFlat EntryHandling=AllEntries EntriesPerDirection=1 StopTargetHandling=ByStrategyPosition ErrorHandling=StopStrategyCancelOrdersClosePositions ExitOnClose=False Set order quantity by=DefaultQuantity    
    1/30/2009 3:31    Strategy    Cancelling any remaining strategy orders    
    1/30/2009 4:00    Order    Order='09b335f5a63248cab02ccb97b1f80339/C2Test' Name='BTO' New State=PendingSubmit Instrument='$USDCAD' Action=Buy Limit price=0 Stop price=0 Quantity=0.01M Type=Market Filled=0 Fill price=0 Error=NoError Native error=''    
    1/30/2009 4:00    Order    Order='09b335f5a63248cab02ccb97b1f80339/C2Test' Name='BTO' New State=Working Instrument='$USDCAD' Action=Buy Limit price=0 Stop price=0 Quantity=0.01M Type=Market Filled=0 Fill price=0 Error=NoError Native error=''    
    1/30/2009 4:00    Order    Order='09b335f5a63248cab02ccb97b1f80339/C2Test' Name='BTO' New State=Accepted Instrument='$USDCAD' Action=Buy Limit price=0 Stop price=0 Quantity=0.01M Type=Market Filled=0 Fill price=0 Error=NoError Native error=''    
    1/30/2009 4:00    Execution    Execution='25b953ecc1e0460e8a3edbc8a3d731de' Instrument='$USDCAD' Account='C2Test' Exchange=Default Price=1.2323 Quantity=0.01M Market position=Long Operation=Insert Order='09b335f5a63248cab02ccb97b1f80339' Time='1/30/2009 4:00:00 AM' Multiplier=1E-05 Rate=0.811754200827989    
    1/30/2009 4:00    Order    Order='09b335f5a63248cab02ccb97b1f80339/C2Test' Name='BTO' New State=Filled Instrument='$USDCAD' Action=Buy Limit price=0 Stop price=0 Quantity=0.01M Type=Market Filled=10000 Fill price=1.2323 Error=NoError Native error=''    
    1/30/2009 4:00    Position    Instrument='$USDCAD' Account='C2Test' Avg price=1.22945 Quantity=0.02M Market position=Long Operation=Update Currency=Unknown
    Last edited by mdrichards; 01-30-2009, 12:59 PM.

    #2
    A NinjaScript strategy does not know what your account position is. If you restart your strategy it will recalculate out a strategy position. EntriesPerDirection governs your strategy position not your account position. You need to sync the two manually.

    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Josh View Post
      A NinjaScript strategy does not know what your account position is. If you restart your strategy it will recalculate out a strategy position. EntriesPerDirection governs your strategy position not your account position. You need to sync the two manually.

      http://www.ninjatrader-support2.com/...ead.php?t=4033
      I've read that article and many others multiple times but the entire "on starting a real-time strategy" handling is very confusing. In this case, I also have it set to "StrategySync=WaitUntilFlat" so shouldn't that have prevented an additional entry?

      The lack of state in strategies seems like a major problem. I can not figure out how I need to configure NT to properly manage my positions based on the strategies I've created. I'm forced to restart NT and setup my strategies every 24 hours because NT lacks the ability to gracefully handle the broker reset.

      Comment


        #4
        No. Your strategy never knows what is in your account. WaitUntilFlat means wait until your strategy position is flat before submitting live orders. You need to manually ensure your strategy position is the same as your account position.

        If you are using WaitUntilFlat all you need to do is flatten your account position before starting it.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Josh View Post
          No. Your strategy never knows what is in your account. WaitUntilFlat means wait until your strategy position is flat before submitting live orders. You need to manually ensure your strategy position is the same as your account position.

          If you are using WaitUntilFlat all you need to do is flatten your account position before starting it.
          I can't flatten my account every time I have to restart NT. Most of my trades last at least a week. I have to restart NT every day. Is there no way to configure NT so that a strategy will properly manage the positions it enters beyond the time I'm forced to restart it?

          Comment


            #6
            As discusssed, a NinjaScript strategy never knows what your account position is. You need to manually sync the two.

            If you restart your strategy it will proceed as it deems based off of the calculated strategy position. You need to reconcile any differences yourself between the account position versus the strategy position.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Josh View Post
              As discusssed, a NinjaScript strategy never knows what your account position is. You need to manually sync the two.

              If you restart your strategy it will proceed as it deems based off of the calculated strategy position. You need to reconcile any differences yourself between the account position versus the strategy position.
              I understand that. You seem to be suggesting that the way to do that is to flatten my account position. I can't close and open new positions every day, that's silly. How do I make the strategy position match the account position? Is NT7 going to introduce any sort of state management for strategies?

              Comment


                #8
                I am not suggesting one option is better than the other. If you want to use WaitUntilFlat the way you sync your account to strategy is by flattening your account. If you select a different option you need to follow the suggestions as described in the link I posted earlier.

                As discussed, you do not make the strategy position match anything. A NinjaScript strategy does not know anything about your account position. You sync the account position to the strategy position.

                Announcements will be made when appropriate about what NT7 can provide in syncing options.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Josh View Post
                  I am not suggesting one option is better than the other.
                  What is the "other". So far I've only seen one option suggested: Flatten my account everyday after NT forces me to restart it.

                  Originally posted by NinjaTrader_Josh View Post
                  If you want to use WaitUntilFlat the way you sync your account to strategy is by flattening your account. If you select a different option you need to follow the suggestions as described in the link I posted earlier.
                  I don't want to use WaitUntilFlat. What I want is for an automated strategy to manage a position it opened more than a day ago. ATM Strategies handle this perfectly. The link you posted earlier doesn't offer a different option. It says the same thing, flatten my account every day. I'm not going to pay 7-30x commissions to use NT.

                  Originally posted by NinjaTrader_Josh View Post
                  As discussed, you do not make the strategy position match anything. A NinjaScript strategy does not know anything about your account position. You sync the account position to the strategy position.
                  This is incredibly backwards logic. I should not have to make live trades, paying extra commissions, to get a strategy to continue managing a position that it opened simply because NT forced me to restart it.

                  Comment


                    #10
                    Hello,

                    Josh will respond to your post on Monday. Thank you for your patience.
                    DenNinjaTrader Customer Service

                    Comment


                      #11
                      The two options you have are flatten your account or manually sync your account to your strategy. If you use Wait until Flat, you will want to flatten your account before strategy start. If you use Execute live then you will want to follow what is outlined in the prior link provided.
                      Josh P.NinjaTrader Customer Service

                      Comment

                      Latest Posts

                      Collapse

                      Topics Statistics Last Post
                      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                      0 responses
                      646 views
                      0 likes
                      Last Post Geovanny Suaza  
                      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                      0 responses
                      367 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by Mindset, 02-09-2026, 11:44 AM
                      0 responses
                      108 views
                      0 likes
                      Last Post Mindset
                      by Mindset
                       
                      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                      0 responses
                      569 views
                      1 like
                      Last Post Geovanny Suaza  
                      Started by RFrosty, 01-28-2026, 06:49 PM
                      0 responses
                      573 views
                      1 like
                      Last Post RFrosty
                      by RFrosty
                       
                      Working...
                      X