Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ERROR: Buy stop or buy stop limit orders can't be place below the market

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

    ERROR: Buy stop or buy stop limit orders can't be place below the market

    Need some ideas on how to troubleshoot the issue that I am encountering.

    Order Management Coding Approach:
    - Using Managed with Advance Order Handling
    - I am creating order objects along with OnOrderUpdate() and OnExecutionUpdate() methods

    Issue:
    • I know that this error message occurs when the stop price is above the current price when going Long or the stop price is below the current price when going short. Based on the error message, the error is caused my the later description
    • When I run the strategy through the chart for an extended period, I see many scenarios where my stop loss orders works correctly. For some reason that I have not been able to determine, the last trade generates the error. It only happens to the last trade and when I am using a Custom Range for the data series time frame. If I use Days on Load data based on and set the End Date to the current date, I don't get the error.
    Other details:
    • This started happening when I started using Custom Range in the Data Series. The End Date is not the current date.
    What I have tried:
    • Using a separate chart that plots my Renko bars along with another tick data series using the Last price, I can confirm that the price at the time the ExitShortStopMarket was submitted is less than the price of the stopPrice. Even more interesting, since the order was created close to the end of the Custom range, when I submit the ExitShortStopMarket order, the market price NEVER came close to the stopPrice. There was never a quick spike to the upside so that when the order was submitted and created in Working status the current price would had been above the stopPrice of the order.
    What I think it is happening but don't have a way to confirm it
    • Keep in mind that this only happens when I set a Custom range and the End date is not the current date. In addition, before the last bar is executed in the Custom range, an order is Opened along with two working orders. The error message feels as if when it tries to create the ExitShortStopMarket, it is comparing the order's stopPrice with the current price in RealTime. In RealTime, the price is definitely above the order's stopPrice.
    I am including a screenshot form the log. In the I can see that the SL (stopLoss) order is getting rejected because the the strategy thinks that the current price is above the order's stopPrice.

    #2
    Hello GARZONJ ,

    Thank you for the post.

    From the details it seems you have a pretty good assessment of the situation and logic involved along with a way to reproduce the problem. Are you able to form a sample of this that you can upload for me to explore along with the steps you had used?

    Ideally if you can have the SampleMACrossOver replicate this, or modify it to replicate this that would be very helpful. That is not required but would reduce any extra code so we can highlight the problem.

    I look forward to being of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by NullPointStrategies, Today, 05:17 AM
    0 responses
    50 views
    0 likes
    Last Post NullPointStrategies  
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    126 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    69 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    42 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    46 views
    0 likes
    Last Post TheRealMorford  
    Working...
    X