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

Trailing stop based on bar close below indicator

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

    Trailing stop based on bar close below indicator

    Hi everyone, I’m new. Is it possible to use a trailing stop attached to a moving average but for the stop to trigger only if the bar closes below the moving average?

    thanks in advance

    #2
    Hello tffmd123,

    Thanks for your post and welcome to the NinjaTrader forums!

    Can you clarify if you are working with a strategy? If so are you using the Strategy Builder or writing directly in Ninjascript?




    Paul H.NinjaTrader Customer Service

    Comment


      #3
      Hello and thank you for your prompt reply. I am new to ninja trader and I am not currently working with any strategy. I would like to be able to use a strategy to trail a portion of a position such that when a bar, either intro day or daily, depending on the situation closes below a given moving average. I saw the parameter to offset based on moving average but not to only trigger a close up on the close of the bar below the moving average. How would one accomplish this? Kind regards, Tom

      Comment


        #4
        Hello tffmd123,

        Thanks for your reply.

        Can you provide a reference to, " I saw the parameter to offset based on moving average but not to only trigger a close up on the close of the bar below the moving average"?

        I'm just trying to understand the context of what you are working with if it is not a strategy.

        Thanks in advance.

        Paul H.NinjaTrader Customer Service

        Comment


          #5
          I was referring to the option to attach a stop to an indicator within chart trader

          Comment


            #6
            Hello tffmd123,

            Thanks for your reply.

            In that situation of manually attaching an order to an indicator, there are no options to fill the order when the bar closes. You can add an "offset" in ticks so that for the order to fill the price would have to cross the moving average by however many ticks you specify. (Use a negative number to subtract ticks).

            Otherwise, you could create a Ninjascript strategy that monitors price and the moving average, and when the cross of the close price over the moving average has been detected, the strategy can issue a market order to exit the position. However as this strategy did not initiate the original entry, you would have to use the AdoptAccountPosition and this precludes creating the strategy in the Strategy Builder.


            Paul H.NinjaTrader Customer Service

            Comment


              #7
              You could do this with your own custom indicator. For example the custom indicator would calculate its value based on your moving average from the previously closed bar. Then you can attach your stop to your custom indicator, knowing that the value of your custom indicator will always be the value of the moving average indicator from the previously closed bar.

              I've done something similar, where the stop loss automatically trials to 1 tick below the last closed bar.

              Originally posted by tffmd123 View Post
              I was referring to the option to attach a stop to an indicator within chart trader
              Vendor_NT_Mobile
              NinjaTrader Ecosystem Vendor - Ninja Mobile Trader VPS

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by trilliantrader, 04-10-2024, 09:33 PM
              7 responses
              25 views
              0 likes
              Last Post NinjaTrader_BrandonH  
              Started by traderqz, Today, 12:06 AM
              5 responses
              11 views
              0 likes
              Last Post NinjaTrader_Gaby  
              Started by Mongo, Today, 11:05 AM
              2 responses
              10 views
              0 likes
              Last Post Mongo
              by Mongo
               
              Started by guillembm, Today, 11:25 AM
              0 responses
              5 views
              0 likes
              Last Post guillembm  
              Started by Tim-c, Today, 10:58 AM
              1 response
              3 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X