Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

EnterShortLimit just cancel the previous ExitLongLimit order !

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

    EnterShortLimit just cancel the previous ExitLongLimit order !

    Hi all,

    A strategy with CalculateOnBarClose = true;

    1st bar : Enterlong();
    2nd bar : ExitLongLimit(price)
    next bars : If the previous ExitLongLimit order is not filled, I want to enter short with a EnterShortLimit(price2);

    my problem is that the ExitLongLimit order is just canceled at the 3rd bard and there is no short pending order !



    Here is a simple ( but stupid ) example which would cause this behaviour :

    protected override void OnBarUpdate()
    {

    if ( Position.MarketPosition == MarketPosition.Flat )
    { EnterLong(1); }

    if ( Position.MarketPosition == MarketPosition.Long ) {

    if ( BarsSinceEntry() < 2 )
    ExitLongLimit(High[0]+20);
    else
    EnterShortLimit(GetCurrentAsk()+1);
    }

    if ( Position.MarketPosition == MarketPosition.Short )
    ExitShort();
    }

    #2
    Hello,

    Please see the following help guide page.

    You will see that an order is cancelled if it is not removed on the next bar. Which with your current code it gets cancelled because of this.



    If you add TraceOrders = True in the Initialize Method you will be able to trace the orders to see what is happening.



    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      Thanks for your answer which helped me.

      I haven't undestood the utility of "EntryPerDirection" and the "Internal Order Handling Rules" in general.


      Here is a extract of the page

      which precisely answer to my question.

      Thanks a lot.

      ------
      The following rules are true per unique signal name excluding market orders:


      Methods that generate orders (excluding market orders) to enter a position will be ignored if:
      • A position is open and an order submitted by an exit method (ExitLongLimit() for example) is active and the order is used to open a position in the opposite direction

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      69 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      42 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      24 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      27 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      54 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X