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

Strategy position with unmanaged orders?

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

    Strategy position with unmanaged orders?

    Hello,

    I recently switched to unmanaged approach so that I don't have to worry about syncing the strategy position. However, NT seems to be keeping track of strategy position anyways. The Position column in the Strategies tab lists positions as if it were managed. This is usually wrong, and has been causing problems for me when submitting orders.

    For example, my account is flat, but the position is incorrectly listed as short. Then, when the strategy submits a buy order (using SubmitOrder method with OrderAction.Buy), NT submits it as a 'buy to cover' order, which gets rejected by my broker since my account is flat.

    Is there any way to prevent NT from keeping track of strategy positions completely? I thought unmanaged approach was supposed to do this...guess I was wrong?

    #2
    Hi sjwelch, thanks for the post. Your strategy will always have a strategy position that NT keeps track of, regardless if you were working in managed or unmanaged mode. However the signal tracking level done will be at a very basic level only which is needed for bare strategy operation, thus leaving a few of the convenience and protection features of the managed mode out (EntryHandling, Internal Order Handling Rules) while providing more flexibility.

    If you strategy is run through the historical OnBarUpdate() part it would arrive at a strategy position it's carrying from historical data, to not have that come into effect I would suggest only submitting order in your logic if you're seeing realtime data with the script.

    BertrandNinjaTrader Customer Service

    Comment


      #3
      Bertrand,

      Thanks for your reply. I'm already using logic that only submits orders on real-time data only. It would take a while to explain exactly why I'm using unmanaged orders to ignore strategy position entirely, but you can see this thread for reference:

      http://www.ninjatrader.com/support/f...d.php?p=330596

      If unmanaged is truly the "ultimate" in flexibility as the NT help guide says, then there must be a way to ignore strategy position when submitting orders. I simply want to buy when I want to buy, and I want to sell when I want to sell. I don't want NT to interfere with that. How do I do this?

      Comment


        #4
        As long as you're not checking for the strategy position, you should be able to straight buy and sell using the SubmitOrder() function.

        The strategy column is going to still track the position itself, but should not prevent you from placing orders.

        Ensuring you're only processing real-time data, are you saying that you still see where the account is flat but the strategy reports it is long?

        As your account always flat when you start the strategy?
        MatthewNinjaTrader Product Management

        Comment


          #5
          So, here's what happened: I held on to a long position overnight, then restarted the strategy. When I restarted, the strategy position said flat. During the day, it exited my long position so the strategy position indicated short. Later, when it tried to enter a long position again, I got an error message from the broker saying that I can't buy to cover because I don't have any short positions. I'm just using the SubmitOrder() method with OrderAction.Buy and OrderAction.Sell, but when I looked at the log it was submitted as Action = 'Buy to Cover'. Is there a way to override this so it simply sends a 'Buy' or 'Sell' signal?

          Comment


            #6
            Originally posted by sjwelch View Post
            So, here's what happened: I held on to a long position overnight, then restarted the strategy. When I restarted, the strategy position said flat. During the day, it exited my long position so the strategy position indicated short. Later, when it tried to enter a long position again, I got an error message from the broker saying that I can't buy to cover because I don't have any short positions. I'm just using the SubmitOrder() method with OrderAction.Buy and OrderAction.Sell, but when I looked at the log it was submitted as Action = 'Buy to Cover'. Is there a way to override this so it simply sends a 'Buy' or 'Sell' signal?
            If you have a realtime only filter on a Strategy, the Strategy will always start Flat, because it will never process a historical position to determine if it was in a position when it closed. Are you really sure that that is what you want to do?

            Comment


              #7
              The strategy does exactly what I want it to do. It filters historical when it should and it doesn't filter when it shouldn't. I internalized position tracking because I didn't like how NT did it. Except even with unmanaged NT is still keeping track of positions! There must be a way to ignore it...

              Comment


                #8
                Originally posted by sjwelch View Post
                The strategy does exactly what I want it to do. It filters historical when it should and it doesn't filter when it shouldn't. I internalized position tracking because I didn't like how NT did it. Except even with unmanaged NT is still keeping track of positions! There must be a way to ignore it...
                Yoiu mean that you actually want your strategy to say it is flat when you were actually in a position when the strategy was shut down? In effect having the strategy reflect a different state than when it was shut down, if that state was not flat? Interesting notion.

                However, that also points the way to working around your problem, albeit not exactly programatically. You know that the strategy will always start flat, so in the particular instance that you cite, your strategy tried to enter a long order when the real account position was actually flat. Therefore, you would need to restart the strategy after the first order that resulted in exiting the account position, at which time is will start up flat, just like the account actually is.

                Comment


                  #9
                  Originally posted by koganam View Post
                  Yoiu mean that you actually want your strategy to say it is flat when you were actually in a position when the strategy was shut down? In effect having the strategy reflect a different state than when it was shut down, if that state was not flat? Interesting notion.
                  I don't care what the strategy position says. I just want to ignore it. I'm using unmanaged orders, so this really shouldn't be hard to do.

                  Comment


                    #10
                    Originally posted by sjwelch View Post
                    I don't care what the strategy position says. I just want to ignore it. I'm using unmanaged orders, so this really shouldn't be hard to do.
                    Well, the engine can only do that which it was programmed to do. Apparently, strategy position will be tracked and used to determine what kind of order is sent. You can manage to work around it as I described, or you can wait for NT to reprogram the engine to do as you want. I think I know which is faster.

                    Comment


                      #11
                      Originally posted by koganam View Post
                      Well, the engine can only do that which it was programmed to do. Apparently, strategy position will be tracked and used to determine what kind of order is sent. You can manage to work around it as I described, or you can wait for NT to reprogram the engine to do as you want. I think I know which is faster.
                      I don't know what the engine can/can't do, but if unmanaged orders are really as flexible as the help guide says, then there must be a way to do this simple task. Does anybody know this for sure?

                      Comment


                        #12
                        Originally posted by sjwelch View Post
                        I don't know what the engine can/can't do, but if unmanaged orders are really as flexible as the help guide says, then there must be a way to do this simple task. Does anybody know this for sure?
                        Well I certainly hope so, because I actually agree with you: if the code is unmanaged, then it should leave well enough alone, and we should be able to buy and sell, all willy-nilly, without NT interjecting itself.

                        It is just that I think there was an oversight, where the ramifications of always tracking the strategy position, and using it to gate orders, were not considered for that particular situation that you have just managed to expose.

                        NT Support: Can we suggest this to Development, please?

                        Comment


                          #13
                          Thanks guys, I've attempted to recreate the scenario here and have not seen any issue, if I had for example historically a short position from the strategy tracks, the either Buy or BuyToCover would have worked on a flat account as I would expect.

                          Which instrument and brokerage technology have you exactly tested with sjwelche? Was it on our most recent NT7 R13 release?

                          Thanks
                          BertrandNinjaTrader Customer Service

                          Comment


                            #14
                            Originally posted by NinjaTrader_Bertrand View Post
                            Thanks guys, I've attempted to recreate the scenario here and have not seen any issue, if I had for example historically a short position from the strategy tracks, the either Buy or BuyToCover would have worked on a flat account as I would expect.

                            Which instrument and brokerage technology have you exactly tested with sjwelche? Was it on our most recent NT7 R13 release?

                            Thanks
                            It works on Sim. Does it work on a real account? I have not tested a real account unfortunately.

                            Comment


                              #15
                              Originally posted by NinjaTrader_Bertrand View Post
                              Thanks guys, I've attempted to recreate the scenario here and have not seen any issue, if I had for example historically a short position from the strategy tracks, the either Buy or BuyToCover would have worked on a flat account as I would expect.

                              Which instrument and brokerage technology have you exactly tested with sjwelche? Was it on our most recent NT7 R13 release?

                              Thanks
                              Thanks for simulating this. I'm curious, when you use SubmitOrder with OrderAction.Buy, and your strategy position is short (but account is flat), what does it say under 'Action = ' on the log where it submits the order? Mine says 'Action = Buy to Cover', which is where I believe the problem is coming from. I think it should say 'Action = Buy' since that's what I specifically defined when I used OrderAction.Buy instead of OrderAction.BuyToCover. NT's probably converting it because it thinks I'm short (when I'm really flat).

                              I'm using NT7 R13 and TDA is my broker.
                              Last edited by sjwelch; 06-03-2013, 05:28 PM.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by strategist007, Today, 07:51 PM
                              0 responses
                              2 views
                              0 likes
                              Last Post strategist007  
                              Started by StockTrader88, 03-06-2021, 08:58 AM
                              44 responses
                              3,967 views
                              3 likes
                              Last Post jhudas88  
                              Started by rbeckmann05, Today, 06:48 PM
                              0 responses
                              4 views
                              0 likes
                              Last Post rbeckmann05  
                              Started by rhyminkevin, Today, 04:58 PM
                              4 responses
                              55 views
                              0 likes
                              Last Post dp8282
                              by dp8282
                               
                              Started by iceman2018, Today, 05:07 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post iceman2018  
                              Working...
                              X