Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

short trade activates during long trade active

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

    short trade activates during long trade active

    hello
    how do i write the code to let the long trade reach the profit target, without the short trade activating while in a long trade. and the other way around. thanks

    #2
    Hello bizzz10,

    Thanks for your post.

    Entry orders in the opposite direction will automatically close existing position and then enter additional order(s) to achieve the new direction.

    To prevent this action, you can add the entry order condition that checks to see if the current market position is flat before placing the order.

    For example:

    if (your condition(s) to enter && Position.MarketPosition == MarketPosition.Flat)
    {
    // order entry
    }


    Reference: https://ninjatrader.com/support/help...etposition.htm

    Note, if you are using the NinjaTrader 7 strategy wizard, on the left side of the condition builder select Strategy>Current market position, in the center select == , on the right side select Strategy>Flat.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    47 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    141 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    160 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    96 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    275 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X