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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    129 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    74 views
    1 like
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    116 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    110 views
    1 like
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    89 views
    0 likes
    Last Post CarlTrading  
    Working...
    X