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

Error: Sell stop order can't be placed above the market

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

    Error: Sell stop order can't be placed above the market

    Hello

    My script reads resistance prices from a txt file. If the market price gets as close as 3.5 points from the resistance price, a SellShortStopMarket order is submitted 5 points lower. But in some cases during playback after the SellShortStopMarket order is submitted the price has already moved 5 points lower and I'm getting this error: "Sell stop order can't be placed above the market". I attached a picture where there are 2 scenarios. First order gets submitted but on the second one I get the error. I also measured the time between when price triggers my order and when price reaches the triggered order's stop price and its over half a second which should be more than enough for an order to get submitted, right? I also attached my code together with the txt file.

    I know that during playback the price is updated down to 100 nanosecond level, but here it doesn't seem to be the case.
    I made my script cleaner and got rid of most of the code. I played through playback many times with the lowest speed and also switched to 10 tick chart to see if it makes a difference, but i get the same result. Might the problem be in the data feed that my playback is currently using which is CQG or does an order really take more than half a second to get submitted?

    What other options are there to make sure the playback goes through the price tick by tick and to make my order execution as fast as possible?

    Thank You!



    Attached Files

    #2
    Hi Karl, thanks for posting.

    A small number of milliseconds are added to the order fill time to simulate the order going to the exchange, but it should not be over half a second to fill the order. The most straight forward way to resolve it would be using RealtimeErrorHandling.IgnoreAllErrors and submit a market order if a reject happens in OnOrderUpdate. The order is being placed on the wrong side of the market. We must confrim if you are having issues in the playback connection or if this script is causing the issue. If you can run the linked script with no issues, your script needs to be debugged further tof ind the problem.



    Kind regards,
    -ChrisL
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thx Chris, I can run the linked script just fine with no issues.

      I tried using RealtimeErrorHandling.IgnoreAllErrors and tested it by printing into output through OnOrderUpdate when order.OrderState == OrderState.Rejected, but i still get the error: Sell stop order can't be placed above the market and nothing gets printed into output. Do you have an example script where this approach with rejected order is being used?

      Comment


        #4
        Hi Karl, thanks for the follow-up. You will still receive the notification that an order was rejected, but the strategy will not be automatically disabled so it will allow you to submit a market order if the Rejected state is seen on the order. I do not know of a full example, but you can test it out by submitting a market order to open a new position or close an existing position when OrderState == Rejected.

        Kind regards,
        -ChrisL
        Chris L.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Taddypole, 04-26-2024, 02:47 PM
        2 responses
        14 views
        0 likes
        Last Post Taddypole  
        Started by futtrader, 04-21-2024, 01:50 AM
        6 responses
        58 views
        0 likes
        Last Post futtrader  
        Started by sgordet, Today, 11:48 AM
        0 responses
        4 views
        0 likes
        Last Post sgordet
        by sgordet
         
        Started by Trader146, Today, 11:41 AM
        0 responses
        5 views
        0 likes
        Last Post Trader146  
        Started by jpapa, 04-23-2024, 07:22 AM
        2 responses
        22 views
        0 likes
        Last Post rene69851  
        Working...
        X