Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Invalid order

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

    Invalid order

    I am using the default strategy settings. For testing purpose, I just call this in the OnBarUpdate:

    if (CurrentBar == 0) EnterLongStopMarket(18.67);

    This results in an error: "An order has been ignored since the stop price ‘18.67’ near the bar stamped ‘18.10.2021 19:00:00’ is invalid based on the price range of the bar."

    I dont understand why. I would expect to buy when the price falls to 18.67 a few days after the first bar.

    #2
    Hello Bobin,

    Thanks for your post.

    You are submitting an order on the very first historical bar which seems a bit unusual. This error is most often seen with Standard Order Fill Resolution where the order fills are estimated using "virtual bars" and formation of the virtual bars indicate that the order cannot be filled with that price action. Setting Order Fill Resolution to High and using a 1 tick data series as the fill series or submitting orders to a single tick data series would be a good way to avoid those types of errors.

    Note: In the Managed approach the entry order of EnterLongStopMarket(18.67) would be automatically canceled if not filled on the first bar that it is entered on. In order to maintain the order, you would need to resubmit it on each bar until it is filled or you no longer want the order. Alternatively, you can use the Advanced Order handling overload (Not available if using the Strategy Builder) that allows for a bool called IsLiveUntilCanceled to be set true.

    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello Paul,
      thanks for your answer.

      I set IsLiveUntilCanceled to true, but the order is not filled a few days after I set the order.
      Do I have to change something else?
      Last edited by Bobin; 01-25-2022, 08:13 AM.

      Comment


        #4
        Hello Bobin,

        Thanks for your reply.

        Please check the "Log" tab of the NinjaTrader Control center for any recent error message(s) to the latest application of the strategy.

        If no errors, please post the code for the entry order.

        Paul H.NinjaTrader Customer Service

        Comment


          #5
          There is no error.
          The code is just:
          if (CurrentBar == 40) EnterLongLimit(0, true, 1, 18.6, "Signal");

          Comment


            #6
            Hello Bobin,

            Thanks for your reply.

            Are you testing this on the historical bars of a chart, or testing in the strategy analyzer, or using playback with market replay data?

            Are you using the Strategy Builder or working directly in Ninjascript?

            What are you using for an exit order?

            Please post a screenshot that shows where the entry-level on bar #40 was placed and then the subsequent bars that would have filled that level. (You can use a horizontal line for the level and a vertical line to identify bar #40. Please make sure the chart shows the price scale, the time scale, and the instrument used.

            Thanks in advance.
            Paul H.NinjaTrader Customer Service

            Comment


              #7
              I use a historical bars chart, directly in Ninjascript.
              I dont have an exit, because the Order to buy is not even executed. This is why the screenshot is just a simple chart, there are no visible entries.
              I marked bar 40.
              18.6 would be a few days after bar 40.

              Comment


                #8
                Hello Bobin,

                Thanks for your reply.

                I created a strategy based on what you provided, recreated your chart, and added a stop and profit target. I also had the strategy draw the line (ray) at the entry point. As you can see the order was filled and closed with a stoploss.

                Click image for larger version

Name:	Bobin-1.PNG
Views:	540
Size:	100.5 KB
ID:	1187002

                Please see if you can recreate.
                Paul H.NinjaTrader Customer Service

                Comment


                  #9
                  Hello,
                  I tried it again, but it just doesnt work.
                  I call the following code and it prints "asdsd", but I cannot see the order being filled in the chart.
                  The class does nothing else...

                  Code:
                  protected override void OnBarUpdate() {
                     if (CurrentBar == 40) {
                        EnterLong();
                        Print("asdsd");
                      }
                  }

                  Edit: I tried to set IsExitOnSessionCloseStrategy to false, but still doesnt work.

                  Edit 2: ah... I had to reset the strategy settings from the UI.
                  Tbh this is SO confusing and contra intuitive.
                  Last edited by Bobin; 03-31-2022, 03:43 PM.

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Ashkam, 04-29-2024, 09:28 AM
                  4 responses
                  42 views
                  0 likes
                  Last Post Ashkam
                  by Ashkam
                   
                  Started by nightstalker, Yesterday, 02:05 PM
                  1 response
                  29 views
                  0 likes
                  Last Post NinjaTrader_Eduardo  
                  Started by dcriador, Today, 02:09 PM
                  0 responses
                  3 views
                  0 likes
                  Last Post dcriador  
                  Started by nicthe, Today, 07:38 AM
                  4 responses
                  21 views
                  0 likes
                  Last Post bltdavid  
                  Started by cmtjoancolmenero, 04-29-2024, 03:40 PM
                  30 responses
                  98 views
                  0 likes
                  Last Post cmtjoancolmenero  
                  Working...
                  X