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 CarlTrading, Yesterday, 09:41 PM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    31 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    30 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-25-2026, 09:53 PM
    0 responses
    34 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 03-25-2026, 09:51 PM
    0 responses
    19 views
    0 likes
    Last Post CaptainJack  
    Working...
    X