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:



    Please let us know if we may be of further assistance to you.

    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.

        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 NullPointStrategies, Today, 05:17 AM
          0 responses
          41 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          124 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          64 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          41 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          46 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X