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.

    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 FishTrade, Today, 03:42 PM
      0 responses
      1 view
      0 likes
      Last Post FishTrade  
      Started by Richozzy38, Today, 01:06 PM
      3 responses
      14 views
      0 likes
      Last Post Richozzy38  
      Started by ttrader23, Today, 09:04 AM
      2 responses
      12 views
      0 likes
      Last Post ttrader23  
      Started by geotrades1, Today, 07:54 AM
      10 responses
      26 views
      0 likes
      Last Post NinjaTrader_BrandonH  
      Started by ninza33, Yesterday, 12:31 PM
      3 responses
      16 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Working...
      X