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

Order errors handling in Indicator

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

    Order errors handling in Indicator

    Hello

    I programmed an indicator/robot.

    When I place a stopmarket order long, priced BELOW the current close we are getting an error, this can happen in a fast-moving market. In a strategy you have a way to suppress the error message using RealtimeErrorHandling = RealtimeErrorHandling.IgnoreAllErrors;

    My indicator does not stop, this is good, as it keeps on working. But the error messages are a bit ugly and will add up. I do check the price just before placing the order, but sometimes it just goes too fast. I use Close[0] + (TickSize * 5)

    Is there something to suppress the error messages for placing orders in indicators?

    #2
    Hello tullips,

    Thanks for your post.

    I see you mentioned you are getting an error. What exactly does the error state?

    If possible, send a screenshot of the error so I may accurately assist.
    • To send a screenshot with Windows 10 or newer I would recommend using the Windows Snipping Tool.
    • Alternatively to send a screenshot press Alt + PRINT SCREEN to take a screenshot of the selected window. Then go to Start--> Accessories--> Paint, and press CTRL + V to paste the image. Lastly, save it as a jpeg file and send the file as an attachment.

    No, there are no supported means for suppressing error messages from appearing. We are tracking interest for this in an internal feature request ticket and I have added your vote. This request is being tracked under the number SFT-671.

    As with all feature requests, interest is tracked before implementation is considered, so we cannot offer an ETA or promise of fulfillment. If implemented, it will be noted on the Release Notes page of the Help Guide.

    Release Notes — https://ninjatrader.com/support/help...ease_notes.htm
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      Click image for larger version

Name:	image.png
Views:	114
Size:	8.0 KB
ID:	1254707

      I am forcing the error here, but I did put the buy order within a try/catch/error. But this does not seem to work

      try
      {
      myOrder = myAccount.CreateOrder(Instrument, OrderAction.Buy, OrderType.StopMarket, OrderEntry.Manual, TimeInForce.Gtc, StartPositions, 0, stepOrderPrice, "", "stepOrder" + currentTime.ToLongTimeString(), DateTime.MaxValue, null);
      myAccount.Submit(new[] { myOrder });
      }
      catch (Exception ex)
      {
      Print("ERROR order!!!");
      }
      ​

      Comment


        #4
        You should be checking if the order you would place is across the market and if it is, sending a market order not a stop market order. Still, in very fast market conditions, you could be wrong by a tick by the time it gets there. But, if you check first, and use the bid/ask rather than last, you'll be right almost all of the time.
        Bruce DeVault
        QuantKey Trading Vendor Services
        NinjaTrader Ecosystem Vendor - QuantKey

        Comment


          #5
          Hello tullips,

          Thanks for your notes.

          The message is letting you know that a stop order was rejected because the strategy submitted the order to an invalid price level. Buy stop orders must be placed above the current ask price. Sell stop orders must be placed below the current bid price.

          Note if this is due to market volatility then there isn't really a way to 100% avoid this occurring, as in volatile markets the market could move so far and fast that this would occur.

          I would recommend you add prints to the strategy to determine why the stop order is being rejected. One line above where the stop order is placed, print the GetCurrentAsk()/GetCurrentBid() and print the price being submitted to the order method.

          Below is a link to a forum post that demonstrates using prints to understand behavior.
          https://ninjatrader.com/support/foru...121#post791121

          Something you could consider is using GetCurrentBid() and GetCurrentAsk() to offset orders so that they are more likely to land on the correct side of the market.

          See these help guide pages for more information.
          GetCurrentBid(): https://ninjatrader.com/support/help...currentbid.htm
          GetCurrentAsk(): https://ninjatrader.com/support/help...currentask.htm

          You could also consider using RealtimeErrorHandling.IgnoreAllErrors to trap order errors in OnOrderUpdate().

          Please note that setting this property value to IgnoreAllErrors can have serious adverse affects on a running strategy unless you have programmed your own order rejection handling in the OnOrderUpdate() method. To do this you could trap the rejected order by checking if the OrderState is Rejected within OnOrderUpdate() followed by defining your own order rejection handling behavior for the rejected order.

          Please see the example in the help guide link below that demonstrates using RealtimeErrorHandling and trapping a rejected order in OnOrderUpdate().

          RealtimeErrorHandling — https://ninjatrader.com/es/support/h...orhandling.htm
          Brandon H.NinjaTrader Customer Service

          Comment


            #6
            Yes, I have seen the error handling in Strategies, but I am using an indicator setup to place my orders.

            Comment


              #7
              After testing and testing and creating a big booboo, which could have blown out my whole account. I have figured out that one of the most difficult things in placing orders is the StopMarket orders. Yes, they work 99% of the time, but the 1% can ruin your whole account. So, for now I will stick with safe, and will use market orders. I can allow myself a few ticks taking away some profits. I am not a scalper.

              I have seen some odd behavior's when placing an order just after a flattening, where the quantity was not what I had put into the order.
              Now here I am using a timer (2 seconds) in between orders, to keep it safe.



              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by cre8able, Yesterday, 01:16 PM
              3 responses
              11 views
              0 likes
              Last Post cre8able  
              Started by ChartTourist, Today, 08:22 AM
              0 responses
              6 views
              0 likes
              Last Post ChartTourist  
              Started by LiamTwine, Today, 08:10 AM
              0 responses
              2 views
              0 likes
              Last Post LiamTwine  
              Started by Balage0922, Today, 07:38 AM
              0 responses
              5 views
              0 likes
              Last Post Balage0922  
              Started by JoMoon2024, Today, 06:56 AM
              0 responses
              6 views
              0 likes
              Last Post JoMoon2024  
              Working...
              X