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

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:



    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:


        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 bortz, 11-06-2023, 08:04 AM
          47 responses
          1,605 views
          0 likes
          Last Post aligator  
          Started by jaybedreamin, Today, 05:56 PM
          0 responses
          8 views
          0 likes
          Last Post jaybedreamin  
          Started by DJ888, 04-16-2024, 06:09 PM
          6 responses
          18 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by Jon17, Today, 04:33 PM
          0 responses
          4 views
          0 likes
          Last Post Jon17
          by Jon17
           
          Started by Javierw.ok, Today, 04:12 PM
          0 responses
          13 views
          0 likes
          Last Post Javierw.ok  
          Working...
          X