Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

SetTrailStop with Multi Time Frame

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

    SetTrailStop with Multi Time Frame

    I have a strategy that uses SetTrailStop to exit once a specific price target is reached.

    Everything works fine on the first trade, but once the strategy re-enters a trade, a trailing stop is immediately placed prior to the price target being reached. The order trails by the same amount of ticks that the prior trade used. It's as if the system isn't aware that the first trailing stop was executed and attempts to amend the prior trailing stop once I am long again.

    I'm using the same code for the trailing stop that worked fine on a different single time frame strategy, so I'm assuming multi time frame has something to do with it.

    Anybody have any ideas on this? Any help would be appreciated.

    #2
    Hello,

    Are you modifying the SetTrailStop anytime after it has initially been set?

    Try resetting this just before you enter a position.

    For example:

    if (Close[0] > Close[1])
    {
    SetTrailStop(CalculationMode.Ticks, 10);
    EnterLong();
    }

    Let me know if this does not work for you.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Yes, the Trail gets tighter as the trade gets more profitable.

      So you're saying if I trigger a SetTrailStop without a position, it will reset the prior order which amends when I re-enter a long?



      Originally posted by NinjaTrader_ChelseaB View Post
      Hello,

      Are you modifying the SetTrailStop anytime after it has initially been set?

      Try resetting this just before you enter a position.

      For example:

      if (Close[0] > Close[1])
      {
      SetTrailStop(CalculationMode.Ticks, 10);
      EnterLong();
      }

      Let me know if this does not work for you.

      Comment


        #4
        Hello peteM,

        Setting SetTrailStop when flat will set the stop amount for when an order is entered. It is something that you set ahead of entering an order. Typically this is set once in the OnStartUp() (while flat).

        Setting SetTrailStop at any time will change the amount of the trial. Setting this without an entry signal will set the trail for all entry orders.

        The issue is that you are setting the trail stop shorter and short for all orders. When a new order is made the trail stop is already set very tight and causes it to exit quickly.

        Resetting this before your order will set the trail to the desired amount.

        If you are wanting to set the trail per order, use an entry signal for the order so the trail stop isn't set for all orders.

        For example:
        Code:
        protected override void OnStartUp()
        {
        SetTrailStop(CalculationMode.Ticks, 15, false);
        }
        
        protected override void OnBarUpdate()
        {
        if (Close[0] > Close[1])
        {
        EnterLong(1, "long");
        EnterLong(1);
        }
        
        if (CurrentBar % 5 == 0)
        {
        SetTrailStop("long", CalculationMode.Ticks, 2);
        }
        }
        SetTrailStop(string fromEntrySignal, CalculationMode mode, double value, bool simulated)

        This code would set all orders to initially have a stop loss of 15. Two orders are entered for a position size of 2. If the CurrentBar is a multiple of 5, the stop loss for the long entry signal only will move to 2 ticks. This means that there will be a stop loss at 2 ticks for the long entry signal and a stop loss trailing at 15 for the order without an entry signal.

        Below is a link to the help guide on SetTrailStop.
        http://www.ninjatrader.com/support/h...ttrailstop.htm
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by rocketman7, Today, 02:12 AM
        2 responses
        16 views
        0 likes
        Last Post rocketman7  
        Started by briansaul, Today, 05:31 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by PaulMohn, Today, 03:49 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by frslvr, 04-11-2024, 07:26 AM
        6 responses
        106 views
        1 like
        Last Post NinjaTrader_BrandonH  
        Started by trilliantrader, 04-18-2024, 08:16 AM
        6 responses
        26 views
        0 likes
        Last Post trilliantrader  
        Working...
        X