Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Help on opening and closing long and short position in strategy.

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

    Help on opening and closing long and short position in strategy.

    All questions below are using strategy builder. Trading ES.

    1. if i have an open long position opened with EnterLong. Should I close this position with Exit Long or Enter short position (saw this in NT video). Which is preferred way to close?
    2. Caveat to point above is I don't want to enter short position right away in every scenario. i may enter short position right away or 10 minutes later for example.
    3. Should I create separate strategies for long and short trading or the same strategy for long and short. I read there is a property wait until flat that I could use for entering short trade after long closes.
    4. summary - If i want to create long and short in same strategy or in different (two scenarios) how can i best manage independent entries for long and short without overlapping each other? What is NT recommendation?

    Thanks,

    #2
    Hi rocketstock, thanks for posting.

    1. You can close it with EnterShort() if you want to reverse. In the managed approach, if you are in a long position and call EnterShort, the long position will be closed automatically and the short order will be submitted.

    2. In this case, you will need to call ExitLong() when the exit signal happens, then call EnterShort() when the short position happens.

    3. Two strategies have no idea what the other one is doing, so I could not recommend making two strategies to run on the same instrument. It has the possibility of one going long and the other going short and that would leave the strategy out of sync.

    4. Keep one strategy that goes long and short, It is not a good practice to run two strategies on the same account for the reason mentioned in #3.

    Kind regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thanks very helpful.

      I like your idea of managing both in one strategy and also using exitlong instead of entershort.

      Follow up

      2. In this case, you will need to call ExitLong() when the exit signal happens, then call EnterShort() when the short position happens.

      In your response 2

      1. I assume the execution is sequential in strategy builder. Sequential in order box?
      2. How would I control the time of short entry after exit long has been called in this sequential scenario. Control as in I don't want to enter short immediately everytime I close long position. Create a separate set perhaps in same strategy? with what parameters such that second set checks if first set of long is closed? Plus reverse scenario switching from short to long with varied timings of entry.

      Thank you!


      Comment


        #4
        Hi, thanks for your followup.

        1. Each set in the builder is executed after its predecessor, assuming the strategy is running OnBarClose, each time the bar updates, set 1 will be evaluated first, then set 2, and so on.

        2. Create a set for each command. E.g. Set 1 contains the signal for EnterLong. Set 2 contains the signal for exit long, Set 3 contains the signal for EnterShort, and set 3 contains the signal for exit short. This will make it so each set or condition is de-coupled from one another and can process independently on every bar of the chart.

        Kind regards,
        -ChrisL
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Understood. This is great. Yes, I'm using BarCLose. Thanks for your help. I will try it out and get back. My newbie mind is wondering if there would ever be a scenario where set 2 of exit long does not meet criterion to exit and for speculative reason set 3 of enter short does meet and executes. Would end up closing the long position and end up flat. Although my indicators shouldn't permit that just being overly imaginative. :-) Thanks again. I'll post results.

          Comment


            #6
            Hi Chris , While I work on the short side of strategy. I had some basic questions that may be obvious but I'm not able to find documentation to solve this scenario above. I am coming from a perspective that short startegy might be completely different from long strategy. As in the indicators and measurements of calculated values are different between long and short.

            Example sequence of events. In this order 1-4. Circular reversal from 4-1 too. Recursive cycles.

            1. Set 1 - EnterLong() - Opens long position independent of any other set. Also send market order to let's say buy 1 contract. Using long logic with indicators for long
            2. Set 2 - Exit Long() - Closes a long position independent of any other set. Using same long logic as step 1.
            3. Set 3 - EnterShort - Opens short position independent of any other set. Also send market order to let's say sell 1 contract. Using completely different logic from long set 1 & 2.
            4. Set 4 - Exit Short() - Closes a short position independent of any other set. Using same long logic as step 3.


            Questions:

            1. Do you think it's possible there will be no overlap between any of 4 steps above even if the logic for long and short is different? If yes, how does one manage that?
            2. When EnterLong and EnterShort are kicked off what happens to existing positions?
            3. Exit methods - what happens when there is no position and they are called?
            4. I think EnterShort closes long position and opens a short position. Same reverse for EnterLong. Is that correct?
            5. Is there a flattenstrategy method that can be called before EnterShort and EnterLong in the order management tab in each set?
            6. What do Exit methods do. Just close or more?
            Last edited by rocketstock; 01-06-2022, 01:59 PM.

            Comment


              #7
              Hi, thanks for the follow up.

              1. You can prevent a set from running by using the Position.MarketPosition property of the strategy. E.g. only call EnterLong()/EnterShort() if the position is flat



              2. If an enter method is called and you are in a position in the other direction a reversal will take place.

              3. Nothing happens when an Exit method is called and there is no position.
              4. This is correct.
              5. No, but you can check for if(Position.MarketPosition == MarketPosition.Long || Position.MarketPosition == MarketPosition.Short) //Close long or short position
              6. Exit methods close a position if there is one.

              All of this is also testable in the Playback connection. Use the Playback connection to fast-forward, pause, and rewind a section of data where your signal occurs so you can test behavior that you are unsure how it would work in practice:


              Kind regards,
              -ChrisL
              Chris L.NinjaTrader Customer Service

              Comment


                #8
                Hi Chris, Thank you!

                The link you showed with current market position set to flat in enter sets is amazing. Using that there will never be any overlap between Enter long and short sets. Correct? I dont see any downsides of using that in all enter sets. Do you?

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by BeachTrader11807, Today, 01:14 PM
                3 responses
                20 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by futureszone, Today, 06:09 PM
                0 responses
                3 views
                0 likes
                Last Post futureszone  
                Started by futureszone, 02-07-2025, 02:48 AM
                2 responses
                21 views
                0 likes
                Last Post futureszone  
                Started by cutzpr, Today, 05:24 PM
                0 responses
                5 views
                0 likes
                Last Post cutzpr
                by cutzpr
                 
                Started by Ezequiel40, Today, 05:23 PM
                0 responses
                7 views
                0 likes
                Last Post Ezequiel40  
                Working...
                X