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

STOP Loss and Profit target based on ATR

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

    STOP Loss and Profit target based on ATR

    Hello support team,

    I have 2 dataseries, a 1minute to detect the ATR value.

    Now I would like to set the stoploss and profit target based on the actual ATR Value

    Example:
    Stoploss 2xATR
    Profittarget 3xATR value

    1. How can this be done with builder, I have no coding experience
    2. Later I would like to have the possibility to optimize the ATR Multiplier with the analyzer.

    Thanks a lot for your great support, if you could make a short video would be great.




    #2
    In the builder, add a SL or TP, select unit of "price" then value in the right side of the box click set, then select the indicator, at the bottom of the indicator settings in that window is a sector for "arithmetic", you can change that to "*" and input your multiplier

    Comment


      #3
      Thank you very much, perfect!

      Comment


        #4
        I am trying to set up in strategy builder an atr non trailing stop. Can someone explain wher to select unit of price? In the builder, add a SL or TP, select unit of "price"

        Comment


          #5
          In sb add sl or pt, select unit price. Looking at the possible selection i dont see unit of price.
          Attached Files

          Comment


            #6
            Hello SpongeRob,

            Unfortunately, a limitation of the Strategy Builder is the Stops and Targets cannot use dynamic values. These are set once in State.Configure, and are not updated during the life of the script in OnBarUpdate.
            Indicators plots and Series<T> bar information is not processed, and no bar is pointed to with CurrentBar, until these series begin processing in OnBarUpdate(). This means, while the indicator instance might exist and properties can be set, no plot value from an indicator and no bar price, like the Close price, can be called in OnStateChange until State.Historical and OnBarUpdate begins processing the series data and advancing CurrentBar.

            Because of this dynamic values such as indicator, bar prices, or calculated values, cannot be used for Stops and Targets in the Strategy Builder.
            When using the mode 'Price', a typed number can be used as the value. A number accepted by the user as an input, that is not dynamically modified in the conditions and actions, would also be acceptable. However, this number would not change and would be the same price for all future orders.

            To submit orders using dynamic prices in the Strategy Builder it would be necessary to use Exit methods in the 'Do the following' > Order Management section. This logic is run for every bar in the OnBarUpdate() method, and is updated dynamically.

            Below is a link to a simple example created with the Strategy Builder that adjusts an exit order price dynamically with logic.
            https://ninjatrader.com/support/foru...596#post806596

            In an unlocked NinjaScript Strategy, you may call Set methods in OnBarUpdate() and use SetStopLoss() dynamically with an indicator or other bar price with a lot more freedom.

            Below is a link to an unlocked example that uses dynamic values with set methods in OnBarUpdate().
            https://ninjatrader.com/support/foru...269#post802269

            The Strategy Builder is also limited with math. The only math available is with offsets on Series (like price and indicator plot series).

            For the ATR specifically, this means a variable could be used that has the value set to the Close with the Offset set to + (add) or - (subtract), with the value set to Indicator -> ATR and this used as the stop price for an order.

            NinjaTrader_Jim has posted a demonstration video.
            https://ninjatrader.com/support/foru...15#post1121015

            NinjaTrader_BrandonH has provided an example.
            https://ninjatrader.com/support/foru...53#post1155153

            There is a more complex unlocked script that uses the ATR in the calculations, but is not created with the Strategy Builder.
            https://ninjatraderecosystem.com/use...d/atrtrailing/

            Attached is a simple example that submits orders using prices from an indicator plot created with the Strategy Builder.
            IndicatorAsOrderPriceBuilderExample_NT8.zip

            The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
            Attached Files
            Last edited by NinjaTrader_ChelseaB; 01-09-2022, 03:54 PM.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Thanks a lot Chelsea, with the exits its working fine... !

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by tkaboris, Today, 05:13 PM
              0 responses
              2 views
              0 likes
              Last Post tkaboris  
              Started by GussJ, 03-04-2020, 03:11 PM
              16 responses
              3,281 views
              0 likes
              Last Post Leafcutter  
              Started by WHICKED, Today, 12:45 PM
              2 responses
              19 views
              0 likes
              Last Post WHICKED
              by WHICKED
               
              Started by Tim-c, Today, 02:10 PM
              1 response
              10 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by Taddypole, Today, 02:47 PM
              0 responses
              5 views
              0 likes
              Last Post Taddypole  
              Working...
              X