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 SydniBuck, Today, 12:54 AM
          0 responses
          6 views
          0 likes
          Last Post SydniBuck  
          Started by ketostrongbuyno, Yesterday, 11:50 PM
          0 responses
          10 views
          0 likes
          Last Post ketostrongbuyno  
          Started by ReinaKutch, Yesterday, 11:08 PM
          0 responses
          9 views
          0 likes
          Last Post ReinaKutch  
          Started by JackyThur, Yesterday, 10:51 PM
          0 responses
          10 views
          0 likes
          Last Post JackyThur  
          Started by sjeffblack, Yesterday, 01:22 PM
          2 responses
          30 views
          0 likes
          Last Post sjeffblack  
          Working...
          X