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

strategy won't place stops

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

    strategy won't place stops

    Hi, can you please review and tell me why the strategy won't place stops (at all)?
    Attached Files

    #2
    Hello trader3000a,

    Thank you for your note.

    While I do see stops being placed with the attached test script, I think you're pretty likely to run into issues here. You're setting the stop to the low of the previous bar. If the low of the prior bar is equal to the open of the next bar, and the price immediately continues to move down, you're going to get a rejected order as Stop Market orders cannot be placed above the current market price. If this occurs, the strategy will disable itself. This may be what's occurring when you're testing. Also, keep in mind that if you're running this On Bar Close, the stop order for the entry will not be placed until the close of the bar the entry was made on, as the position will not have had time to update, so if you're running this on a 60 minute chart, the stop wouldn't get placed until the 60 minute bar the order was placed on closes.

    Do you see stops being placed when using the test reproduction below? If not, what instrument and bar type/interval are you testing with?

    Thanks in advance; I look forward to assisting you further.
    Attached Files
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hi Kate, I realize now that what I want to do is this:

      1. We get a green candle with a higher low and a higher high than the prior red candle

      2. Provided that price is above the high of that red candle, place a limit buy order at that red candle's high, and a stop loss at that red candle's low

      I get buy orders filled, but no stops are generated. I can't get the strategy builder to place a stop. I tried asking it to wait until a 3rd bar's price is above the red candle's high to place the orders, but it still only places the buy order. Any losing trades hold until the end of session.

      Is it because, in the strat builder, we can't place a stop unless we are filled first? And at that point, I can't figure out how to tell it to look back to that first red candle's low since the fill could be any number of candles later...
      Last edited by trader3000a; 09-24-2021, 07:28 AM.

      Comment


        #4
        Hello trader3000a,

        Thank you for your reply.

        Yes, exit orders would be ignored until the entry order has filled. This would apply to any strategy using the Managed Approach, not just Strategy Builder strategies.

        You could save the low price of the bar to a variable called something like StopPrice when the entry order is placed. Then, when the position is long, submit the ExitLongStopMarket. I'd again caution you with this that if you have two bars, one red, one green where the low and high are above the prior low and high, but they don't have a very large range, and are followed by wider ranging bars, you could easily hit that same issue with the stop price being above the market by the time the order has filled. I've attached an example script that illustrates this approach, and if you run it for a bit you'll likely run into a rejection for that reason. I would suggest calculating the stop price as a number of ticks off the average entry price instead to avoid this scenario.

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

        Comment


          #5
          Kate, that's a great help, thank-you!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by TheMarlin801, 10-13-2020, 01:40 AM
          20 responses
          3,914 views
          0 likes
          Last Post Bidder
          by Bidder
           
          Started by timmbbo, 07-05-2023, 10:21 PM
          3 responses
          150 views
          0 likes
          Last Post grayfrog  
          Started by Lumbeezl, 01-11-2022, 06:50 PM
          30 responses
          806 views
          1 like
          Last Post grayfrog  
          Started by xiinteractive, 04-09-2024, 08:08 AM
          3 responses
          11 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by Johnny Santiago, 10-11-2019, 09:21 AM
          95 responses
          6,194 views
          0 likes
          Last Post xiinteractive  
          Working...
          X