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 charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    57 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    143 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    161 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    97 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    276 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X