Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ATR Stop Query

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

    ATR Stop Query

    HI I've a doubt,

    What I am looking for is a trailing stoploss that is equal to the 10 period ATR, If I use the following code:

    SetTrailStop(CalculationMode.Ticks, ATR(10)/TickSize);

    would this keep fixed the ATR(10) numeric value at the time the strategy enters the position, or would the ATR(10) change on every BarUpdate according with the price?

    Thanks,

    #2
    Hello,

    This would depend on when/where you're calling SetTrailStop()

    If SetTrailStop() is never called again after the position is entered then it would use the initial ATR value otherwise it would update with each new call
    LanceNinjaTrader Customer Service

    Comment


      #3
      I am not sure I fully understand.

      You mean it depends if I place the SetTrailStop in the Initialize() or in the OnBarUpdate() ?

      Comment


        #4
        You wouldn't be able to use the line you have in Initialize() as you cannot use TickSize there.

        I mean your code could be made such that when it's time to enter a trade you also Set() your stop/target and then never call that section of code again until the position is flat.

        Without seeing your code I cannot verify how this will perform.
        LanceNinjaTrader Customer Service

        Comment


          #5
          I wasn't aware of the fact that in initialize() section you can't recall TickSize. Hower would it be possible use the exact TickSize? for example assuming the TickSize for the instrument is 0.01 would the following code make the trick?

          Initialize()
          SetTrailStop(CalculationMode.Ticks, 0.01 * ATR(10));

          I remind you that my objective is to have a static ATR calculation in the trailing stop.

          If this doesn't make the trick, would the following make it:

          Private void GoLong()

          SetTrailStop(CalculationMode.Ticks, ATR(10)/TickSize);

          Private void OnBarUpdate()
          {
          If (....)
          {
          GoLong();
          }

          Comment


            #6
            Hello,

            Yes you could hard code the value as .01 (or the required size)

            for more information about using TickSize: http://www.ninjatrader.com/support/h...l?ticksize.htm

            If you set the stop loss in the Initialize() your ATR value will not be the current ATR value as Initialize() is only called at the start before bars have been loaded. Instead the strategy will throw an error and not start.

            You would need to set your stop loss somewhere in OnBarUpdate()

            example
            Code:
            if (Position.MarketPosition == MarketPosition.Flat) 
            {
            //sets the trailing stop only when we are flat
              SetTrailStop(CalculationMode.Ticks, 0.01 * ATR(10)[0]);
            //enters long only if we are flat
              EnterLong()
            }
            LanceNinjaTrader Customer Service

            Comment


              #7
              So basically anything in the initialize() section is called only once at the start? Thanks for the tip.

              Going back to the code you posted, what happens if within the strategy the long postion is exited by a takeprofit condition stated in the initalize section. The strategy would now be flat, but would then SetTrailStop be automatically cancelled?

              Thanks,

              Comment


                #8
                Profit Targets that are generated with a stops loss or trail stop order will be linked via OCO. Should your profit target fill, the stop loss/trail stop would be canceled at that time.
                MatthewNinjaTrader Product Management

                Comment


                  #9
                  I guess the same happens if a short signal is triggered, or the long position is exited on an other codition, such as a moving average cross over, is this a correct assumption?

                  Comment


                    #10
                    Yes this is correct. The Set exit orders are tied to an entry, when the entry is terminated within the strategy it will remove the exits created by the Set methods
                    LanceNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by wzgy0920, 04-20-2024, 06:09 PM
                    2 responses
                    26 views
                    0 likes
                    Last Post wzgy0920  
                    Started by wzgy0920, 02-22-2024, 01:11 AM
                    5 responses
                    32 views
                    0 likes
                    Last Post wzgy0920  
                    Started by wzgy0920, Yesterday, 09:53 PM
                    2 responses
                    49 views
                    0 likes
                    Last Post wzgy0920  
                    Started by Kensonprib, 04-28-2021, 10:11 AM
                    5 responses
                    191 views
                    0 likes
                    Last Post Hasadafa  
                    Started by GussJ, 03-04-2020, 03:11 PM
                    11 responses
                    3,230 views
                    0 likes
                    Last Post xiinteractive  
                    Working...
                    X