Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Unintened Position Reversals

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

    #16
    Hello,

    Ok thanks for posting.

    Alright so your explination would be correct for how this code is done.

    Once you submit order the iOrder object BullQuickI and BullRunnerI are holding an order object and is no longer null.

    That order objects holds the OrderState.Filled since the order was filled and will continue to hold this until you reset this object. If you dont reset the object it will always hold that filled state and you will never get another entry since the BullRunnerI is not equal to null which is what you check for your next trade.

    Therefor you will need to add code that checks the status of the entry order. If its been fulled then set the object back to null. Therefor allowing you to take more trades.

    Also you'll need your own flag to allwo or not allow the short position to fire if your currently in a long position. As here you are left with a flat position since the short condition triggers at the same time as the long. Leaving you flat.

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

    Comment


      #17
      Here is my feeble attempt at reseting the null. It's not working and I'm hoping you can point out my flaw.
      protected override void OnOrderUpdate(IOrder order)
      {
      if (order.FromEntrySignal == "BullQuickI" && order.OrderAction == OrderAction.BuyToCover)
      BullQuickI = null;
      if (order.FromEntrySignal == "BullRunnerI" && order.OrderAction == OrderAction.BuyToCover)
      BullRunnerI = null;
      if (order.FromEntrySignal == "BearQuickI" && order.OrderAction == OrderAction.SellShort)
      BearQuickI = null;
      if (order.FromEntrySignal == "BearRunnerI" && order.OrderAction == OrderAction.SellShort)
      BearRunnerI = null;
      }
      Thanks

      Comment


        #18
        Hi CaptainAmericaXX,

        You want to reset the object to null when it is filled / cancelled order state. There is an example of this below, and a complete script using IOrders is available here:
        The OnOrderUpdate() and OnExecution() methods are reserved for experienced programmers. Instead of using Set() methods to submit stop-loss and profit target orders, you can submit and update them manually through the use of IOrder and IExecution objects in the OnOrderUpdate() and OnExecution() methods. The OnOrderUpdate()


        protected override void OnOrderUpdate(IOrder order)
        {
        if (entryOrder != null && entryOrder == order)
        {
        if (order.OrderState == OrderState.Filled || order.OrderState == OrderState.Cancelled)
        entryOrder = null;
        }
        }
        Ryan M.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        601 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        347 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        559 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        558 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X