Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Recommended way to reverse a position.

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

    Recommended way to reverse a position.

    Hi,

    I have an strategy running multiple "substrategies". One one strategy opens an opposite position to the current position I would like to close the open position and then enter in the new direction.

    i.e.- MarketPosition is long, and we get a short signal, so we close the long and then open a long.

    I've tried doing:
    Code:
     
    if (Position.MarketPosition == MarketPosition.Long)
    {
          Position.Close();
    }
    EnterShort(contratos, EntryName[StrategyOne]);
    But although in replay and backtesting works OK in live tests sometimes I end up having positions unclosed.


    What is the best way to accomplish this?

    #2
    Hello dpicon,
    Unfortunately, Position.Close is beyond what we could supported.

    The standard EnterLong EnterShort should reverse your position.

    Position.MarketPosition returns the overall strategy position. You can have better control if you assign the IOrder objects for each individual orders.


    Also please make sure to use the TraceOrder code. It will let know which order is being submitted.
    JoydeepNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    649 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    370 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    109 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    573 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    576 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X