Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop Order Being Ignored

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

    Stop Order Being Ignored

    Hey there, I currently have a strategy with a set limit stop loss and sometimes when the next bars are below the stop loss order (which shouldn't happen in real time and most likely the stop would get triggered in the same bar). I understand how the back test works with the OHLC and basically "creates" the bars on the fly. So I am wondering if there is a way to set the stop loss to re activate or just take a stop market order. When the stop loss order gets canceled and then closes on the session end it is really messing up my statistics when I run a back test.
    I will attach two pictures on of a .77 stop loss getting rejected and never coming back and one of a .78 stop loss getting triggered and closing the trade. I am using a minute bar chart and using the ninja trader strategy builder. I will also attach a picture of my Stop Loss Code.

    This is the error in the logs for the rejected order:
    Strategy 'PivotWithBEStop1062023/-1': An order has been ignored since the stop price ‘55.74’ near the bar stamped ‘10/13/2022 11:18:00 AM’ is invalid based on the price range of the bar. This is an invalid order and subsequent orders may also be ignored.

    Thank you for your help.
    p.s. I understand why the order can't exist (because you cant set a stop above the current market price) and gets canceled but there has to be a way to solve this for the back test results.

    #2
    Hi noshowstock,

    I think you have wrong settings in the ExitLongStopLimit() order.
    Look again at your "stop" and "limit" parameters. They should have a distance.
    Plus, Market was below those values, so you could not get a fill in the 2nd photo.
    Last edited by KonstantinosNT; 01-19-2023, 08:11 AM.

    Comment


      #3
      Hello noshowstock,

      As KonstantinosNT mentioned it looks like the orders you have are using a price in a strange way, if your variable is specifically an amount of offset in price then what you have should work. You are subtracting a fixed amount from the average price. If you meant to offset by an amount of ticks or some other calculation you would need to take a look at those orders prices again.

      When submitting orders from the sets like this there is not necessarily a way to avoid that besides making sure the price used is offset enough to avoid being invalid or on the wrong side of the market on a new bar.

      You can use the OnOrderTrace override to see the trace order output in your script so you could potentially read that information and then have the script resubmit the order in the future if it sees that warning. That would still end up allowing that order to expire and leave the position unprotected. If your strategy does nothing after the original order expired and you observe that warning using OnOrderTrace you could use that to submit a new order after that point.

      Comment


        #4
        Originally posted by KonstantinosNT View Post
        Hi noshowstock,

        I think you have wrong settings in the ExitLongStopLimit() order.
        Look again at your "stop" and "limit" parameters. They should have a distance.
        Plus, Market was below those values, so you could not get a fill in the 2nd photo.
        I tried all three order types but no matter how I have it set my order gets canceled because the back test thinks the order is above the "current market" price, but in reality price does not jump like that minute to minute the price flows up and down. So I WOULD ASSUME in real time it would place the stop and it would organically get hit and stop me out.

        It is just messing up my back test results when it shouldn't be. I wish there was a way to re send the stop order if you still have an open position with no stop loss.

        Comment


          #5
          I fixed the issue - I basically told the script to check if I am in an open position, if I am in an open position and the close of the current bar is lower that what my my stop loss would be then just slam a exit long market order in there and close the position. It is clunky but it is working for my back test to yield better results.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          89 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          48 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          31 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          34 views
          0 likes
          Last Post TheRealMorford  
          Started by Mindset, 02-28-2026, 06:16 AM
          0 responses
          69 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Working...
          X