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

Buy Stop can't be placed below the market

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

    Buy Stop can't be placed below the market

    Is this the correct way to resubmit rejected EnterLongStopMarket() orders:


    private Order rejectedEntryOrder = null;

    if (rejectedEntryOrder != null)
    rejectedEntryOrder = GetRealtimeOrder(rejectedEntryOrder);

    if ((entryOrder == null || entryOrder2 == null) && Close[0] > Close[1])
    {
    EnterLongStopMarket(0, true, 1, mfe[0], @"myEntryOrderLong1");
    }

    // Rejeced Order Mangement
    if (rejectedEntryOrder == null)
    rejectedEntryOrder = EnterLongStopMarket(0, true, 1, mfe[0], @"myEntryOrderLong1");

    // Rejection entry orders
    if (order.Name == @"myEntryOrderLong1")
    rejectedEntryOrder = order;

    if (rejectedEntryOrder != null && rejectedEntryOrder == order)
    {
    // Rejection handling
    if (order.OrderState == OrderState.Rejected)
    {
    // Entry order was rejected !!!!
    EnterLongStopMarket(0, true, 1, mfe[0], @"myEntryOrderLong1");
    }
    }

    When I run the script in playback, I still get the error messages that say: "Buy stop or buy stop limit orders can't be placed below the market. affected order: Buy 1 StopMarket @3931.50
    Then NT8 crashes.

    I know I can do a check for High[0] > GetCurrentAsk(), but this check decreases my entry signals by a lot.
    Last edited by AdeptistJune; 05-24-2022, 09:53 PM.

    #2
    Without directly addressing your question, but nevertheless being very relevant, the following are essential to understanding Limit and Stop orders:
    • Buy Limit must be BELOW current Ask
    • Buy Stop must be ABOVE current Ask
    • Sell Limit must be ABOVE current Bid
    • Sell Stop must be BELOW current Bid
    Thanks.
    Multi-Dimensional Managed Trading
    jeronymite
    NinjaTrader Ecosystem Vendor - Mizpah Software

    Comment


      #3
      Hello AdeptistJune,

      Thank you for your reply.

      Looks like you're setting the price of the order to mfe[0] but you're not checking that that price is above current ask before submitting the order. I would suggest checking that's above the current price and if it isn't, adjust the price so it is.

      Please let us know if we may be of further assistance to you.
      Kate W.NinjaTrader Customer Service

      Comment


        #4
        Hello Kate,

        My mistake for saying HIgh[0], when actually, I am checking mfe[0] > GetCurrentAsk(). I was just saying High[0] as an example.

        When I check mfe[0] > GetCurrentAsk(), it decreases my number of trading signals.

        I'm thinking of commenting out mfe[0] > GetCurrentAsk(), and trapping the rejected order, and resubmitting the order again.

        When I tried this last night, in playback, the error occurred, and my NT8 crashed.

        So either I wrote the rejection handling script wrong, or what I'm attempting doesn't work.

        Any advice on how to approach EnterLong(Short)BuyStopMarket() orders that are rejected if I choose not to use the mfe[0] > GetCurrentAsk() check?

        Thanks.

        Comment


          #5
          Hello AdeptistJune,

          Thank you for your reply.

          I mean, at some point you're going to need to check that when the order is submitted that it's at a valid price, if you just keep trying to submit the order at the same price you'd likely end up in kind of a loop of rejections and resubmittals. I would definitely advise checking that the mfe value is on the correct side before even submitting the order initially.

          Please let us know if we may be of further assistance to you.
          Kate W.NinjaTrader Customer Service

          Comment


            #6
            Hello Kate,

            I was thinking the same thing, but it helps to hear it from someone who has more experience than myself. I will continue testing mfe[0] > CurrentAsk().

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Balage0922, Today, 07:38 AM
            0 responses
            1 view
            0 likes
            Last Post Balage0922  
            Started by JoMoon2024, Today, 06:56 AM
            0 responses
            6 views
            0 likes
            Last Post JoMoon2024  
            Started by Haiasi, 04-25-2024, 06:53 PM
            2 responses
            19 views
            0 likes
            Last Post Massinisa  
            Started by Creamers, Today, 05:32 AM
            0 responses
            6 views
            0 likes
            Last Post Creamers  
            Started by Segwin, 05-07-2018, 02:15 PM
            12 responses
            1,786 views
            0 likes
            Last Post Leafcutter  
            Working...
            X