• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to avoid EnterShort/EnterLong closing Long/Short position?

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

    How to avoid EnterShort/EnterLong closing Long/Short position?

    I have two criteria in my script, one for going long, one for going short on the same instrument. I want my positions only closed when they reach profit target or stop loss.

    Let's say Long Criteria was triggered and I have a long position. At a later point in time, the Short Criteria is triggered, and EnterShort is being executed. The problem is that EnterShort will fully close my previous Long position, and then open the Short position in full too. I do not want my Long position closed, since it hasn't reached profit target or stop loss yet.

    How do I solve that within the same strategy? As a workaround, I could create two strategies, they would run independently. I'd like to implement it though in a single strategy, so that I could get more accurate backtest statistics on drawdown etc. of the combined strategy.

    #2
    Originally posted by mic414 View Post
    I have two criteria in my script, one for going long, one for going short on the same instrument. I want my positions only closed when they reach profit target or stop loss.

    Let's say Long Criteria was triggered and I have a long position. At a later point in time, the Short Criteria is triggered, and EnterShort is being executed. The problem is that EnterShort will fully close my previous Long position, and then open the Short position in full too. I do not want my Long position closed, since it hasn't reached profit target or stop loss yet.

    How do I solve that within the same strategy? As a workaround, I could create two strategies, they would run independently. I'd like to implement it though in a single strategy, so that I could get more accurate backtest statistics on drawdown etc. of the combined strategy.
    Either do what you have yourself outlines, using 2 independent strategies trading in opposite directions, or else use unmanaged orders.

    When using unmanaged orders, you have complete control. Just remember that you also have none of the safety built-in to NT's managed methods, so you have to take care yourself of everything; especially of everything that can possibly go wrong.

    Comment


      #3
      Hello,

      Thank you for the post.

      In general, we wouldn't suggest using two strategies for a long and short side as there would be a disconnect between the two strategies. A strategy has a virtual position and is not aware of what the other strategy may be doing which can cause lapses in logic.

      For this, I would suggest using the Position object to know when you are in a position to prevent the opposite order logic from happening.

      In your conditions to enter, you could do something like the following:


      Code:
      if(Position == MarketPosition.Flat)
      {
         // place entry logic here
      }
      Both the long and short side orders could go inside this code block to prevent any further orders from being submitted after you are already in a position. Once your stop or target was met and you were Flat again, this code could be run once again.

      I look forward to being of further assistance.
      JesseNinjaTrader Customer Service

      Comment


        #4
        Originally posted by NinjaTrader_Jesse View Post
        Hello,

        Thank you for the post.

        In general, we wouldn't suggest using two strategies for a long and short side as there would be a disconnect between the two strategies. A strategy has a virtual position and is not aware of what the other strategy may be doing which can cause lapses in logic.

        For this, I would suggest using the Position object to know when you are in a position to prevent the opposite order logic from happening.

        In your conditions to enter, you could do something like the following:


        Code:
        if(Position == MarketPosition.Flat)
        {
           // place entry logic here
        }
        Both the long and short side orders could go inside this code block to prevent any further orders from being submitted after you are already in a position. Once your stop or target was met and you were Flat again, this code could be run once again.

        I look forward to being of further assistance.
        That is not what the OP requested. He wants to be able to simultaneously, in a more or less virtual manner, hold both long and short positions. The reality, of course, is that in that case, he will be flat. However, there is the advantage that one is then ready to resume whichever trade goes in the desired direction. I speak from experience, because that is exactly what I most often do. I let all trades go to completion one way or another, rather than instantly reverse mid trade.

        Comment


          #5
          koganam, can you explain more?

          I did not think this is possible - simultaneously holding long and short positions in the same instrument?

          Comment


            #6
            Originally posted by janseun View Post
            koganam, can you explain more?

            I did not think this is possible - simultaneously holding long and short positions in the same instrument?
            If one insists on using the Managed Orders system that NT provides, the only real way to do this is to run 2 copies of the strategy: one going long only and the other going short only.

            The other way is to use Unmanaged Orders, in which case, one can pretty much do whatever one wants with orders. Be warned: if you use Unmanaged Orders, you must take care of all possible scenarios, or blowing up the account is a real, undesired, possible outcome.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by fredrikn, 05-08-2019, 04:01 AM
            17 responses
            668 views
            1 like
            Last Post emtrader  
            Started by zacharydw00, Yesterday, 10:19 PM
            0 responses
            3 views
            0 likes
            Last Post zacharydw00  
            Started by chafan11, Yesterday, 09:28 PM
            0 responses
            7 views
            0 likes
            Last Post chafan11  
            Started by GreenspanAlec, Yesterday, 05:32 PM
            0 responses
            7 views
            0 likes
            Last Post GreenspanAlec  
            Started by mrwarkhan, Yesterday, 03:45 PM
            0 responses
            18 views
            0 likes
            Last Post mrwarkhan  
            Working...
            X