Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Another overill issue

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

    Another overill issue

    I am running a strategy that returns an overfill error - it closes all positions and shuts down the strategy.

    Basically I am just trying to close out a short position and open a long position. My statements are:
    _exit = ExitShort();
    _entry = EnterLong(contracts);


    contracts = 1 here. Do I need to delay between these 2 statements (is that possible?). This works when backtesting but not running as a strategy running in real time.


    #2
    Hi gregm,

    For position reversals you don't need both ExitShort() and EnterLong(). EnterLong() by itself will take care of closing the short position and opening a long position.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      OK thanks - but I would think ExitShort would close my position anyway and then EnterLong would just open a new position ?

      or are these happening too fast ? I am just trying to understand what is going on.

      Comment


        #4
        Yes, exactly. The problem is sending them at the same time. If you wait until the ExitShort() order is filled before sending EnterLong(), it would submit with the right quantity. Since EnterLong() can take care of reversals already, this level of control isn't typically needed.
        Last edited by NinjaTrader_RyanM1; 02-15-2012, 02:16 PM.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          OK sorry to continue this but I need separate commands as one routine closes a trade and another opens a trade (and I don't know when closing a trade if the logic will be opening a new one).
          So I need to close the trade and then wait for the position to close before my logic continues. What can I use to yield until the ExitShort is successfully completed.

          I tried using a While !Flat after the exit command to wait (but this just locked up when loading the strategy.

          Flat was defined as:
          private bool Flat { get { return Position.MarketPosition == MarketPosition.Flat; } }

          thanks

          Comment


            #6
            A simple check would be to make sure that you're flat before submitting EnterLong(), and then you'll also need to add some control that this is only processed when the long signals are valid. You could do this with a bool flag or just duplicating the conditions used in ExitShort().

            if (Position.MarketPosition == MarketPosition.Flat)
            EnterLong();

            If you wanted the most control, you could structure your orders as IOrder, and then monitor for the fill state on the exit short order before submitting enter long. This sample can help with a lot of the techniques needed for this:
            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()
            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
            650 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            370 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            109 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            574 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            577 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X