Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problems with SubmitOrderUnmanaged

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

    Problems with SubmitOrderUnmanaged

    I am sending a StopMarket order in OnOrderUpdate() after the entry order has been completed.

    Order exit = SubmitOrderUnmanaged (0, OrderAction.Sell, OrderType.StopMarket, filled, 0, stopP, "", exitName);

    where stopP = 427.87. a Close [0] = 429.52. Although the stop price is below Close [0] I get the message:

    2019-04-16 16:58:30:950 ERROR: Strategy 'T1/-1': A Sell stop order placed at '07.01.2016 02:00:00' has been ignored since the stop price is greater than or equal to the close price of the current bar.

    There are only one asset. What is wrong ?
    I'm including screen from Visual Studio debuger.

    #2
    Hello Andrew_e,
    Thanks for your post.

    This is a historical error message. In real-time the order would have been rejected.

    You will need to add checks to make sure the price you want to submit at is valid. I suggest checking the high and low of each of those bars to be sure.
    Last edited by NinjaTrader_JoshG; 04-17-2019, 07:11 AM.
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Do you mean that the stop price for StopMarket must be lower than the current bar low?
      Last edited by Andrew_e; 04-16-2019, 10:44 AM.

      Comment


        #4
        Andrew_e,

        The stop price would need to be less than the close price of the current bar. Perhaps something similar to the following would work to get a valid stop price.

        Code:
        stopP = Math.Min(Close[0] - TickSize, myStopPrice);
        Josh G.NinjaTrader Customer Service

        Comment


          #5
          As I wrote in the first post, Close [0] was smaller and I get an error.

          At the moment, for historical data, I control the bar low and place an order below this low (same of course below Close [0])

          See the attached screen from the debugger. StopH is lower than low of bar and I still have erorr.

          double stopH = State == State.Historical? Math.Min (stopP, Low [0] - 2 * TickSize): stopP;

          Order exit = SubmitOrderUnmanaged (0, OrderAction.Sell, OrderType.StopMarket, filled, 0, stopH, "", exitName);

          However, I still have the error:

          A Sell stop order placed at '20.01.2016 10:00:00' has been ignored since the stop price is greater than or equal to the close price of the current bar.

          What should I do ?

          Comment


            #6
            Andrew_e,

            I suggest printing whatever price value you are actually passing into your SubmitOrderUnmanaged() along with the Close[0] value. By the looks of it your price could still be stopP which would certainly cause that error (according to your screenshot).

            You may may want to do some testing yourself to verify that this only occurs historically, real-time, or both.
            Josh G.NinjaTrader Customer Service

            Comment


              #7
              Josh, the price of the order is passed correctly. As I checked (through orderTrace and login values) the problem is that before calling OrderSubmit Close [0] and Low[0] shows the previous bar value, not the one on which the enter order. for which we are opening Stop Loss, has been activated.

              Close [0] before the order indicates the values ​​of the last closed bar - previous:

              2019-04-16 21:50: 28: 936 | 1 | 16 | Low [0] 379.38, Close [0] 380,24

              and at onOrderTrace we have:

              2019-04-16 21:50:48: 428 | 1 | 16 | 20.01.2016 14:00:00 Strategy 'Turtle1 / -1': Entered internal SubmitOrderUnmanaged () method at 20.01.2016 14:00:00: BarsInProgress = 0 Action = SellShort OrderType = StopMarket Quantity = 1 LimitPrice = 0 StopPrice = 375,00 SignalName = 'Short_signal_0' Close [0] 395.89, Low [0] 377.5

              that is, the data of the bar on which the input orders started.

              If I manually change the value of the order to less than 377.52, i.e. Low of this bar, then the error does not occur.

              How to solve it correctly? How should I have access to the new bar?

              Comment


                #8
                Andrew_e,

                If you want access to price data sooner than the bar close you would need to use Calculate.OnEachTick or Calculate.OnPriceChange

                Making sure you use a valid price (such as 377.52) will ultimately be how you resolve this.

                Josh G.NinjaTrader Customer Service

                Comment


                  #9
                  I solved this problem by adding an additional 1 minute series and placing orders on it, not on the main series. This has the disadvantage that it extends the backtest time significantly. I have another problem with orders, but this in a separate thread. Thank You.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by NullPointStrategies, 03-13-2026, 05:17 AM
                  0 responses
                  96 views
                  0 likes
                  Last Post NullPointStrategies  
                  Started by argusthome, 03-08-2026, 10:06 AM
                  0 responses
                  154 views
                  0 likes
                  Last Post argusthome  
                  Started by NabilKhattabi, 03-06-2026, 11:18 AM
                  0 responses
                  82 views
                  0 likes
                  Last Post NabilKhattabi  
                  Started by Deep42, 03-06-2026, 12:28 AM
                  0 responses
                  54 views
                  0 likes
                  Last Post Deep42
                  by Deep42
                   
                  Started by TheRealMorford, 03-05-2026, 06:15 PM
                  0 responses
                  72 views
                  0 likes
                  Last Post TheRealMorford  
                  Working...
                  X