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

Ignored SubmitOrderManaged() Reason='Invalid order price, please see log tab' Error

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

    Ignored SubmitOrderManaged() Reason='Invalid order price, please see log tab' Error

    Hi,

    When back testing and optimising (especially optimisation) I get multiple error messages regarding my exit orders being ignored or rejected, and causes the optimisation to stop abruptly (albeit results are still partly generated)

    Ignored SubmitOrderManaged() method at 30/08/2019 21:11:59: BarsInProgress=1 Action=BuyToCover OrderType=StopMarket Quantity=163 LimitPrice=0 StopPrice=26345.56 SignalName='SE SL' FromEntrySignal='Short Entry' Reason='Invalid order price, please see log tab'
    Scanning the various print messages I can see its not true and the stop order exit has a price below the current CLOSE price. See screenshot below:

    Is there anything im missing here?
    Searching the forums I found "Internal Handling Rules" for my managed exits that might be causing the problem. If there is nothing wrong with the below, do I need to convert to unmanaged approach for all my orders? Its true im partially closing positions and exiting positions for the full left over quantity of position using ExitLongLimits & ExitLongStopMarket is this the problem?

    Thankyou for all your advice and help.

    Click image for larger version

Name:	Capture.JPG
Views:	210
Size:	253.9 KB
ID:	1069826

    #2
    Hi mr_trade, thanks for your post.

    What does the log tab say about this order? Could you provide a stripped-down test script that still produces the issue so I can test? See here for instructions on exporting a script.

    I look forward to hearing from you.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi ChrisL,

      I stripped it all down as requested and attached so you can see the issue, but I think I see the problem now (good advise to do strip it down). It appears to be my calculation for the stoploss price causing the issue.
      Im trying to calculate a percentage away from the position fill price to place the stoploss. But I see now that the close can be suddenly alot less than where my position opened even a tick later.

      So just to be clear should I be calculating the percentage on the close price when the OnExecutionUpdate is called? Is this going to be the close of the tick series1 or use series0? Is the below the best way to achieve this? Or simply use close price and ignore the fill price?

      Code:
      protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
        {
         switch (Position.MarketPosition)
                  {
                      case MarketPosition.Long:
           if (longEntryOrder != null && longEntryOrder == execution.Order)
           {
            if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
            {
      [COLOR=#FF0000]stopPrice = (double)Math.Round(Close[0] - (execution.Order.AverageFillPrice * 0.001), 2); // Calculate stoploss % away from current close based on fill price[/COLOR]
                                  ExitLongStopMarket(1, true, execution.Order.Filled, stopPrice, "LE SL", "Long Entry");
           }
           break;
                  }
      Thanks for your help once again.
      Attached Files

      Comment


        #4
        Hi mr_trade, thanks for your reply.

        To target a specific series, you need to use the Closes[][] array. If your 1 tick series is the second series, you would reference Closes[1][0] to get its most current price. If you use Close[0], you must make sure the BarInProgress index == 1 and not 0.

        e.g.

        Code:
        OnExecutionUpdate()
        {
            if(BarsInProgress == 1)
            {
                //Close[] will reffer to the secondary series here.
            }
        }
        Alternatively, you can use GetCurrentAsk()/GetCurrentBid() to circumvent the OnBarUpdate logic and get the ask or bid price directly from the data connection.

        See this page for a guide on multi time frame/multi instrument scripts.

        Kind regards.
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Haiasi, Today, 06:53 PM
        1 response
        4 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by ScottWalsh, Today, 06:52 PM
        1 response
        10 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by ScottW, Today, 06:09 PM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by ftsc2022, 10-25-2022, 12:03 PM
        5 responses
        256 views
        0 likes
        Last Post KeyonMatthews  
        Started by Board game geek, 10-29-2023, 12:00 PM
        14 responses
        244 views
        0 likes
        Last Post DJ888
        by DJ888
         
        Working...
        X