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 traderqz, Today, 12:06 AM
          3 responses
          6 views
          0 likes
          Last Post NinjaTrader_Gaby  
          Started by RideMe, 04-07-2024, 04:54 PM
          5 responses
          28 views
          0 likes
          Last Post NinjaTrader_BrandonH  
          Started by f.saeidi, Today, 08:13 AM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by DavidHP, Today, 07:56 AM
          1 response
          7 views
          0 likes
          Last Post NinjaTrader_Erick  
          Started by kujista, Today, 06:23 AM
          3 responses
          11 views
          0 likes
          Last Post kujista
          by kujista
           
          Working...
          X