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

Using the current bar size (in ticks) to create a safety stop and target.

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

    Using the current bar size (in ticks) to create a safety stop and target.

    I am trying to use the NT8 strategy builder to create a safety stop and a target stop based on the tick size of the entry bar. I am currently concentrating on plugging in the ATR with a look-back of one into the "percent" window in the last tab of the SB to no avail. Tried lots of different things as well. Help please.

    #2
    Hello White Fork,

    The Strategy Builder allows you to set a number of ticks from entry the stop is placed. This automatically uses the TickSize of the instrument.

    Is this insufficient for your needs?

    Any custom calculation would require unlocking the script and coding by hand.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks Chelsea! I have been working on figuring out coding for my system. Mostly just cobbling bits together and tweeking them at this point. However I can't find any previously code examples of my above request in the NT8 language. How would I express the above in code?

      Comment


        #4
        Hello White Fork,

        Are you asking about using an offset with a number of ticks?

        This is demonstrated in the Strategy Builder 301 course for the stop loss and profit target using a variable that represents a number of ticks from entry the stop or target will be placed.

        Below is a public link.


        Also below is a public link to the help guide.

        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Ticks, yes. But I want the "amount" of ticks to be derived from the size of the entry bar. When I get an entry signal from my "system". I am trying to generate a stop loss and target based on the size of the entry bar. Stop should be one (long signal) entry bar size away from the low of the (long signal) entry bar and target should be two (long signal) entry bar lengths away from the high of the
          (long signal) entry bar. Make sense?

          Comment


            #6
            Thank you for the links. I have already watched everything you guys have put out. In strategy builder (last tab) you can set the stop loss dialog "mode" box to ticks. Then in the "value" box pick whatever you want to generate the number of ticks. I totally get this. In the past I have linked the "Value" to my own input so as to control the number of ticks from my strategy after creating. I get this. i have also set the "value" box to "percent" and used the ATR indicator and nested ATR indicators inside of that but with out getting the desired results. What I can't figure out is what I pick in the "value" window that will allow me to place my stop loss one (or several) full bar length (entry bar/current bar) away from entry. Same with Target. I have tried nearly everything that won't return an error. Nothing works. Also the "Current Bar" in the misc tab, and so on. Will you please explain in detail how to do this? Thank you.

            Comment


              #7
              Hello White Fork,

              The Strategy Builder is not capable of math. Any kind of math other than using an offset would require unlocking the script and coding by hand.

              From example:
              Print( (Close[0] - Open[0]) / TickSize );

              This would print the number of ticks from the open to the close.

              That type of custom calculation could be used to calculate a new price for an exit order or could be used for a number of ticks for set methods using CalculationMode.Tick.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                Thank you.

                Comment


                  #9
                  So I tried to build what I've been looking for (original post above), per your reply's and the help documents on the NT site. Unfortunately it's not working.
                  See enclosed image (highlighted section of code). Any thoughts?

                  Comment


                    #10
                    Hello White Fork,

                    You will not be able to use Close[0] or any other bar information until the bars start updating in OnBarUpdate().

                    You could instead use CalculationMode.Ticks and set this to a number of ticks from entry.

                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Chelsea, You last reply "
                      That type of custom calculation could be used to calculate a new price for an exit order or could be used for a number of ticks for set methods using CalculationMode.Tick. " How is it possible to use the custom statement "( (Close[0] - Open[0]) / TickSize );" in the Calculation Mode?
                      "

                      Comment


                        #12
                        Hello White Fork,

                        Chelsea is out of the office today, but will get back to you as soon as he returns.

                        Thanks for your patience.
                        Josh G.NinjaTrader Customer Service

                        Comment


                          #13
                          What I'm not understanding is how to plug "
                          ( (Close[0] - Open[0]) / TickSize );" into "
                          SetProfitTarget(CalculationMode.Ticks, ProfitTargetTicks);". I tried plugging it into "ProfitTargetTicks" intead of "= 200;", but I got an error.

                          Comment


                            #14
                            Hello White Fork,

                            You are able to use Close[0] or any other bar information when the bars start updating in OnBarUpdate().

                            If you intend to set an exact price with CalculationMode.Price instead of a pre-set number of ticks, this logic will need to be performed for each bar in OnBarUpdate().
                            Chelsea B.NinjaTrader Customer Service

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by nandhumca, Today, 03:41 PM
                            0 responses
                            4 views
                            0 likes
                            Last Post nandhumca  
                            Started by The_Sec, Today, 03:37 PM
                            0 responses
                            3 views
                            0 likes
                            Last Post The_Sec
                            by The_Sec
                             
                            Started by GwFutures1988, Today, 02:48 PM
                            1 response
                            5 views
                            0 likes
                            Last Post NinjaTrader_Clayton  
                            Started by ScottWalsh, 04-16-2024, 04:29 PM
                            6 responses
                            33 views
                            0 likes
                            Last Post ScottWalsh  
                            Started by frankthearm, Today, 09:08 AM
                            10 responses
                            36 views
                            0 likes
                            Last Post frankthearm  
                            Working...
                            X