Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exiting Position Impossible?

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

    Exiting Position Impossible?

    I have spent a lot of time using

    Cbi.Position myPosition = Account.Positions.FindByInstrument(Instrument);

    To get some semblance of real (ie actual) portfolio level tracking into NT. Now I am at another barrier.

    I believe that Position.MarketPosition is used internally by NinjaScript to decide if there is or is not a position to "Exit" when using ExitLong, for example.

    This mean that although my code is now much more successful at traking the portfolio, all of the Exit commands are not working because internally NinjaScript thinks there is no position when in fact there is.

    How can I use "Exit" commands when

    Position.MarketPosition == MarketPosition.Flat

    But in fact a position exists?



    #2
    imported post

    You likely are confusing strategy position and account position.

    Strategy position = position managed by a strategy.
    Account position = actual position on an account.

    The strategy only processes exit orders as the strategy position is not flat, meaning a strategy will not process exit orders as the account position is not flat but the strategy position is flat.

    Please consult the docs on how to sync your account position with your strategy position: Options->Strategies tab

    Comment


      #3
      imported post

      I cannot understand your reply Dierk...

      I believe that the account is not flat, but the strategy is flat.

      So my original question still stands, when the Strategy IS flat, ie Position.MarketPosition == MarketPosition.Flat

      But the Account is NOT flat

      How can I get Exit commands to actually execute? <-That is the question.

      Comment


        #4
        imported post

        So strategy position is flat but account position is not flat? This is the scenario described by my post, where the strategy will not process exit orders.

        -> You can not exit the (non-flat) account position if the strategy position is flat.

        Comment


          #5
          imported post

          Dierk Droth wrote:
          -> You can not exit the (non-flat) account position if the strategy position is flat.
          I hope you realise what this means for automated trading systems...

          So I have gone to the trouble to code a whole work around to the fact that Strategy.Position is blind with respect to Account.Position, and now it turns out that this is useless because no EXIT commands work... highly ironic.

          Is there anyway to set the value of Position.MarketPosition? Can I change its value? <- question

          Comment


            #6
            imported post

            Sure exit commands work. Just enter a position with your strategy and then exit it with your strategy, no problem.

            I again recommend you check out the docs to understand the concept of syncing to your just started strategy to a live account position.

            Here is another sample: You can running multiple strategies on the same account. All strategies manage their own (strategy) position. However, all strategy positions result in one (!) real account position.

            -> The scenario where real account position does not match (virtual) strategy position is very likely. That's why we provided the options to sync both.

            Comment


              #7
              imported post

              Dierk, I don't think you are getting the point.

              1) For what ever reason a Strategy is interuptted and Restarted. The Strategy is now flat but the account is NOT flat. This means that the last thing that the Strategy did BEFORE the interuption was anENTER command. That is why the Account position is not flat.

              2) This restarted Strategy CANNOT enter because it already has an account position. The next thing it will have to do is EXIT. There is no need or posibility of ENTER here.

              3) However it cannot exit because Strategy is FLAT and ALL EXIT COMMANDS ARE IGNORED.

              4) I need to be able to use NinjaScript to set the Value of Position.MarketPosition. I want to tell the Strategy = you are not FLAT. How can I do this? <- question (again)

              Comment


                #8
                imported post

                Dierk Droth wrote:
                -> The scenario where real account position does not match (virtual) strategy position is very likely. That's why we provided the options to sync both.
                I am unable to locate documentation relating to this, can you please tell me where I can find it? Thanks...

                Comment


                  #9
                  imported post

                  Dierk Droth wrote:
                  Please consult the docs on how to sync your account position with your strategy position: Options->Strategies tab

                  Comment


                    #10
                    imported post

                    Screen 1
                    Attached Files

                    Comment


                      #11
                      imported post

                      Screen 2
                      Attached Files

                      Comment


                        #12
                        imported post

                        I can see no options that have anything to do with "syncing" Account.Position with Strategy.Position...

                        Please answer the following question: Can I manipulate the value of Position.MarketPosition?

                        Comment


                          #13
                          imported post

                          No you can not, since there is no need to.

                          Here is what happens as you start a strategy e.g. on chart:
                          - strategy is executed on the historical part of the data series (data in the past)
                          - let's say it ends up with a historical strategy position
                          - as the strategy now runs on realtime data, it continues on executing orders based on the strategy position which was build as the strategy ran on historical data.

                          -> strategy works consistent to it's historical position. No need to "fake" a strategy position. More so it could even throw off the strategy logic as you try to "fake" a position.

                          Of course, there is an issue where the strategy historical position does not match the real account position (multiple strategies running on the same account, or strategy logic just "moved on" and no longer reflects real account position as you restart the strategy while later). In that event options below - which you posted for our convenience - are available.

                          Hope this explains the concept.

                          Comment


                            #14
                            imported post

                            Unfortunately it explains nothing. And thanks for the sarcasm: just what a user needs from support...

                            What I have written here explains my situation, nothing you have replied provides a solution.

                            Oli wrote:
                            1) For what ever reason a Strategy is interuptted and Restarted. The Strategy is now flat but the account is NOT flat. This means that the last thing that the Strategy did BEFORE the interuption was anENTER command. That is why the Account position is not flat.

                            2) This restarted Strategy CANNOT enter because it already has an account position. The next thing it will have to do is EXIT. There is no need or posibility of ENTER here.

                            3) However it cannot exit because Strategy is FLAT and ALL EXIT COMMANDS ARE IGNORED.

                            4) I need to be able to use NinjaScript to set the Value of Position.MarketPosition. I want to tell the Strategy = you are not FLAT. How can I do this? <- question (again)

                            Comment


                              #15
                              imported post

                              Oli,

                              We currently do not provide support for exiting an account position.Somewhere in a previous post I had mentioned that you had to manualy enter orders to synca strategy position to an account position. Some users may want to do this, others may not since there is no one to one relationship between a strategy and account position.

                              Ray
                              RayNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by r68cervera, Today, 05:29 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post r68cervera  
                              Started by geddyisodin, Today, 05:20 AM
                              0 responses
                              3 views
                              0 likes
                              Last Post geddyisodin  
                              Started by JonesJoker, 04-22-2024, 12:23 PM
                              6 responses
                              35 views
                              0 likes
                              Last Post JonesJoker  
                              Started by GussJ, 03-04-2020, 03:11 PM
                              12 responses
                              3,239 views
                              0 likes
                              Last Post Leafcutter  
                              Started by AveryFlynn, Today, 04:57 AM
                              0 responses
                              6 views
                              0 likes
                              Last Post AveryFlynn  
                              Working...
                              X