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 burtoninlondon, Today, 12:38 AM
      0 responses
      2 views
      0 likes
      Last Post burtoninlondon  
      Started by AaronKoRn, Yesterday, 09:49 PM
      0 responses
      11 views
      0 likes
      Last Post AaronKoRn  
      Started by carnitron, Yesterday, 08:42 PM
      0 responses
      10 views
      0 likes
      Last Post carnitron  
      Started by strategist007, Yesterday, 07:51 PM
      0 responses
      12 views
      0 likes
      Last Post strategist007  
      Started by StockTrader88, 03-06-2021, 08:58 AM
      44 responses
      3,982 views
      3 likes
      Last Post jhudas88  
      Working...
      X