Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EnterLong after Short opens double position

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

    EnterLong after Short opens double position

    Hi,

    In one of my strategies after a certain signal I want to go from 1 Short position to 1 Long position.
    But I have this problem: When I am 1 Short and there is a Long signal, my strat goes sometimes in a double (2) Long position.
    Questions:
    - Does anyone know what I am doing wrong?
    - When position is 1 Short and command is EnterLong, is the position then Flat or 1 Long?
    I have CalculateOnBarClose = True.
    Quantity's are always 1.

    Here's the corresponding code after the signal:
    if ( (Position.MarketPosition == MarketPosition.Short)
    )
    {
    ExitShort(QuantShort1,
    "Exit ShortOpSTnr1", "ShortOpSTnr1");
    if ( tijdok == "ja") {EnterLong(QuantLong1, "LongOpSTnr1");} //
    }

    TIA,
    Anne

    #2
    Hello,

    Using the managed approach, there is no reason to call both ExitShort and EnterLong.

    EnterLong will take your position into account, so if you're in a 1 short position and call EnterLong, it will buy to cover your short position and buy 1 to enter you in a long.

    Calling ExitShort and EnterLong can result in a race condition where two market orders are submitted.

    You should only use ExitShort/ExitLong when you're sure you want to scale out, or flatten.
    MatthewNinjaTrader Product Management

    Comment


      #3
      Ok, that clears things up. Thanks.
      One question about this:
      In my code I give the Exit order a name:"Exit ShortOpSTnr1"
      But how can I recognize the exit order now? Because I can't give it a name...

      Comment


        #4
        The managed exit order would be called "Close Position"
        MatthewNinjaTrader Product Management

        Comment


          #5
          Ok, thanks. I understand I can't give the managed Exit order a custom name.
          Thanks and regards,
          Anne

          Comment


            #6
            Any way to avoid two trades when short and calling EnterLong?

            I am using this approach and noticed that when I call EnterLong when I am short (or vice versa), two trades get executed. One to close the short position, and another to buy for the long position. This charges me two commissions, is there any way to avoid that? I am using Interactive Brokers.

            Comment


              #7
              Originally posted by tbwerz View Post
              I am using this approach and noticed that when I call EnterLong when I am short (or vice versa), two trades get executed. One to close the short position, and another to buy for the long position. This charges me two commissions, is there any way to avoid that? I am using Interactive Brokers.
              Unmanaged approach. Reverse by using double the position quantity.

              Comment


                #8
                I see, from what I've read I'd have to re-write and test my strategy to do this. I'm just using market orders, is there no simple way to reverse direction using a managed approach w/o getting hit with two commissions? This really seems like it should be a feature, why make everyone re-implement order management that seems to work pretty well otherwise? Those commissions add up when this happens 10 or 20 times a day.

                Comment


                  #9
                  Originally posted by tbwerz View Post
                  ... is there no simple way to reverse direction using a managed approach w/o getting hit with two commissions?
                  Unfortunately, at this time, there is not. Managed Orders were designed to be easy and safe to use, and so are somewhat constrained. There are still some options, but they are sparse and tight. If you need freedom to handle orders with elegance, you have no choice but to use the unmanaged approach and handle the safety aspects all on your lonesome.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by nleitman, Yesterday, 11:46 AM
                  9 responses
                  26 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by cmtjoancolmenero, 04-25-2024, 03:58 PM
                  18 responses
                  105 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by kujista, Yesterday, 12:39 AM
                  4 responses
                  17 views
                  0 likes
                  Last Post kujista
                  by kujista
                   
                  Started by Mindset, Yesterday, 06:19 AM
                  2 responses
                  15 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by bubblegum, 03-18-2024, 10:41 AM
                  4 responses
                  51 views
                  0 likes
                  Last Post NinjaTrader_Gaby  
                  Working...
                  X