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.
    JimNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by corman, Today, 02:02 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by Uregon, Today, 12:12 PM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Kate  
    Started by kerplunk1899, Today, 10:03 AM
    1 response
    19 views
    0 likes
    Last Post NinjaTrader_Kate  
    Started by rexsole, Today, 10:20 AM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_RyanS  
    Started by pjsmith, Today, 03:01 AM
    6 responses
    18 views
    0 likes
    Last Post bltdavid  
    Working...
    X