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 set for BarClose -- Stoploss executed earlier

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

    Strategy set for BarClose -- Stoploss executed earlier

    I have a strategy set to calculate at BarClose. I set a stoploss in the strategy and the first bar after entry closed above the entry price, but it stopped out before the bar closed. Is there a way to set the stop so that it will only execute at barclose?

    #2
    Hi ronaldgreene828,
    What you see is expected behaviour. It shall protect you because the price can move further against you until the bar closes.
    IF sending stops to the broker at order entry (already) is not a "must have" for you, you could consider managing your stop or/and profit target yourself in variables instead of using the built in SL or/and TP. On each bar update, you would then check if the price crossed the stop or profit target you calculated, and if Yes, send an (SL or TP) Exit order to the market.
    This can even be done using the Strategy Builder.
    Please carefully consider the Con's, particularly that i) a robust and fast internet connection is absolutely critical, ii) your exits will aways occur with one bar delay (neither during current bar, nor at current bar close, but at the next bar open).
    As Pro, note that your SL/TP are not visible on the market. Your Exit order will only be routed to the market once the respective level is triggered.
    NOT a recommendation, just a suggestion how you could bypass NT restrictions on built in SL or/and TP, provided you really wanted to do that after most careful consideration.
    NT-Roland

    Comment


      #3
      I'm using something called NS Full Range renko bars, so the maximum height for any bar is set. If I use a setting of 25, the maximum bar height is 6.25 on the NQ. I realize that a substantial move could move the exit price beyond by several points before it has a chance to close.

      Comment


        #4
        I did as you described using a variable to set the stop loss. The strange thing is, it still stops out before the bar closes. I have it set on bar close. Could it be something with the renko type bars I'm using? They look more like regular candlesticks except that they never go beyond a maximum height for the setting.

        Comment


          #5
          Hi ronaldgreene828,
          No, the bar type is not the issue.
          The internal management of SL and TP works like a charm (even using the StrategyBuilder only). The attached pictures illustrates that the exit is always executed after the trigger bar (grey background). And the trigger itself = comparison of price (here: Close) vs. calculated TP and SL level (variables, see dots) is always checked on bar close only.
          NT-Roland
          Attached Files

          Comment


            #6
            Ok. If I use a variable as a stoploss, I'll set a NT stoploss as a backup for insurance.

            Comment


              #7
              Hello ronaldgreene828,

              If you are only wanting an exit at the bar close, using an exit market order like ExitLong() or ExitShort() when a condition is true to place the exit order in OnBarUpdate would be very close. This would submit a market order when when the bar closes and would fill at the open of the next bar.

              The alternative you would have to predict what the close the price the bar will be and have an order (or stop loss) working at that price.

              NT-Roland, thank you for providing that information.
              Chelsea B.NinjaTrader Customer Service

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by love2code2trade, Yesterday, 01:45 PM
              3 responses
              22 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by trilliantrader, Today, 08:16 AM
              2 responses
              6 views
              0 likes
              Last Post trilliantrader  
              Started by samish18, Today, 08:31 AM
              1 response
              1 view
              0 likes
              Last Post NinjaTrader_Clayton  
              Started by Creamers, 09-08-2023, 10:26 AM
              6 responses
              157 views
              0 likes
              Last Post JonyGurt  
              Started by funk10101, Today, 08:14 AM
              1 response
              2 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X