Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy to advance Trail Stop

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

    Strategy to advance Trail Stop

    i am using this method in a strategy for a trailstop

    // TrailStop begins at Profit Trigger settings and then advance based on Step Frequency
    if (((High[0] + (-ProfitTrigger * TickSize)) > (Position.AveragePrice))
    && (Position.MarketPosition == MarketPosition.Long)
    && (UseTrailStopForExit == true))
    {

    ExitLongStopMarket(Convert.ToInt32(Position.Quanti ty), (Open[3] + (TrailStop * TickSize)) , @"ExitStopMarketTrail", "");

    }

    CURRENTLY this only triggers at ProfitTrigger and the uses information in the Order syntax

    what is my next step to have this advance based on a step frequency
    Thanks for any help

    #2
    Hello DTSSTS,

    Thanks for your post.

    Having the trailing stop advance based on a frequency similar to the trailing stop feature of an ATM strategy will involve calling your order submission method every so many OnBarUpdate iterations, or to change the price every so many OnBarUpdate iterations.

    For example, if you wanted to move the stop loss every so many bars, you could assign CurrentBar to your own variable when you submit the order, and check if CurrentBar is greater than your variable plus X number of bars before submitting the order. This would be an additional condition controlling when the logic reaches the order submission method.

    If you would like to update the stop loss after so many ticks, you could use Calculate.OnEachTick, and then increment a a variable with each OnBarUpdate iteration to have a "tick counter." The same approach as above can then be used using your "tick counter" instead of CurrentBar.

    The above implies that you will be using IsLiveUntilCancelled overloads since the order method would not be called with each new OnBarUpdate iteration.

    We look forward to assisting.
    Last edited by NinjaTrader_Jim; 02-07-2020, 08:47 AM.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    88 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    48 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    30 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    34 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    68 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X