Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to know the sellshort is execute ??

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

    How to know the sellshort is execute ??

    I execute the sellshort(OrderAction) with the limitprice Close[0].

    And then i will do the BuyToCover (OrderAction) if it fulfill execute the sellshort order first.

    By right, we will sellshort first, then only have BuyToCover.

    However, when there is no sellshort(OrderAction), the BuyToCover (OrderAction) still will carry out.

    Is that anyway to check either sellshort(OrderAction) have been execute or not.



    I attach with the picture and code.:
    Code:
    protected override void OnBarUpdate()
    {
    ......
    entryShort = SubmitOrderUnmanaged(0, OrderAction.SellShort, OrderType.Limit, LotsQuantity, entryShortPriceWithOffset, 0, "", "Sell Short");
    .....
    }
    Code:
    protected override void OnExecutionUpdate(Cbi.Execution execution, string executionId, double price, int quantity, Cbi.MarketPosition marketPosition, string orderId, DateTime time)
    {
    ....
    
    if (execution.Order == entryShort)
    {
    
    if (entryShort.OrderState != OrderState.filled)
    {
    exitShort = SubmitOrderUnmanaged(0, OrderAction.BuyToCover, OrderType.Limit, Position.Quantity, exitShortPrice, 0, "", "Exit Short");
    }
    ....
    }
    Although i make a orderstate.filled check, but it didnt work.

    #2
    Hello soon123,

    Thank you for writing in.

    OnExecutionUpdate would be used to check when an order is executed. If you are working with order objects, it is best practice to have the Order object assigned in OnOrderUpdate.

    Attached is an example that submits an order, checks that it fills in OnExecututionUpdate, and then submits a new order. You may compare your logic against this working example.

    Please let us know if we may further assist.
    Attached Files
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      I still facing the same error.

      But theoretically was right.
      And i think i learn the correct way from you.

      I will double check my code first.
      (Worry is another part causing this error).

      If cant solve the problem, i will inform here again.

      Btw, thanks.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by fawzanalim, Yesterday, 05:59 PM
      1 response
      15 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by JuanPabloQuevedo, Yesterday, 05:27 PM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by StevenNelson, Yesterday, 03:24 PM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by my-trade, Yesterday, 10:45 AM
      1 response
      14 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by s.kinra, Yesterday, 11:36 PM
      0 responses
      6 views
      0 likes
      Last Post s.kinra
      by s.kinra
       
      Working...
      X