• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

limiting SetTrailStop() updates to once every second

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

    limiting SetTrailStop() updates to once every second

    Hi,

    at present I have a trailing stop configured as below:

    else if (State == State.Configure)
    {
    //Sets a trailing stop
    SetTrailStop(CalculationMode.Ticks, Trailing_Stop);

    }


    I notice that every single tick is causing my trailing stop position to be re-evaluated, causing problems with my connection to my broker.

    What is the best practice method to throttle the updates to my trailing stop? are there any examples?

    Ideally these should not be updating more than once per second.

    Do I need to create a for loop and evaluate the trailing stop within this, or is there a variable I can configure?

    #2
    Hello Conall,

    Thank you for your note.

    What do you have Calculate set to in State.Set Defaults? If this is set to calculate on each tick, that's exactly how your stop will be evaluated - every time a tick comes in. If you set this to OnBarClose for your strategy, it will only evaluate when the bar closes, which as long as you're not running said strategy on a 1 tick data series, would be less often than each tick.

    Here's a link to our help guide on SetTrailStop:

    https://ninjatrader.com/support/help...ttrailstop.htm

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hi Kate,

      the issue with this approach is that it affects the whole strategy.

      In the scenario where I wish for it to apply to the trailing stop only, and not the rest of the strategy, what is the best method to implement this?

      Is it possible for me to for example, call a method from a different script, and have that script have a different calculation method?, or should I rely on using a loop or a counter of some kind ?

      regards,
      Conall

      Comment


        #4
        Hello Conall,

        Thank you for your post.

        If you would like the SetTrailStop() to only update when the bar closes, set Calculate to OnBarClose, for all other actions you would like triggered intra-bar, add a secondary series and trigger the logic for that series' BarsInProgress.

        Here's a link to one of our forum posts with further information about utilizing a secondary data sereies for intrabar granularity:
        https://ninjatrader.com/support/foru...377#post773377

        Please let us know if we may be of further assistance to you.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          thanks for getting back to me Kate, that looks like a great solution. Thanks.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by vantojo, Today, 08:35 AM
          1 response
          4 views
          0 likes
          Last Post NinjaTrader_PatrickG  
          Started by frankduc, Today, 08:28 AM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Jim  
          Started by EddieBeanPit, 06-21-2019, 07:17 PM
          1 response
          20 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by futures2018!, Yesterday, 05:01 PM
          3 responses
          14 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by Splex, Today, 12:04 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Jim  
          Working...
          X