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 FrancisMorro, Today, 03:24 AM
    0 responses
    1 view
    0 likes
    Last Post FrancisMorro  
    Started by Segwin, 05-07-2018, 02:15 PM
    10 responses
    1,769 views
    0 likes
    Last Post Leafcutter  
    Started by Rapine Heihei, 04-23-2024, 07:51 PM
    2 responses
    30 views
    0 likes
    Last Post Max238
    by Max238
     
    Started by Shansen, 08-30-2019, 10:18 PM
    24 responses
    943 views
    0 likes
    Last Post spwizard  
    Started by Max238, Today, 01:28 AM
    0 responses
    10 views
    0 likes
    Last Post Max238
    by Max238
     
    Working...
    X