Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Strategy Analyzer - Enter Short but use Trailing Stop as if Long

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

    Strategy Analyzer - Enter Short but use Trailing Stop as if Long

    Hi,

    I found a strategy that was very unprofitable. It was buying the dip when my custom indicator was high and placing a trailing stop on it. So....I wanted to reverse it by shorting when my indicator is high, but then using the trailing stop from the long position.

    In strategy builder if I put it to Short and then have a trail stop it assumes a short position. I want to think of the position as long and exit as if long, although I'm short. How can I do this? Here's my simple code below. Thanks.

    if (MidTermBottom(Close,11,11,11,10,10,11,10,11,11,11 )[0] > ExecutionValueBot)
    EnterShort();

    SetTrailStop(@"", CalculationMode.Ticks, TrailDefault, false);

    I want to set the trail stop looking at the position as a Long position, not a Short position.

    Thanks!


    #2
    Hello GoodTradingFun,

    Thank you for your post.

    SetTrailStop cannot be used in this way - for a short position it will always be above the open position and for a long position it will always trail below.

    However, you could emulate the behavior of the trailing stop to use a Buy Stop Limit or Buy MIT order below the short position or a Sell Stop Limit or Sell MIT above an open long position as more of a trailing profit target.

    I don't have any examples of this specifically, however, I'm attaching an example of creating a trailing stop loss using the Strategy Builder. You'd really have to reverse the offset logic to place orders above the market, and change to a ExitShortStopLimit or ExitShortMIT order, but this should give you an idea of the logic necessary to have that trailing action.

    Please let us know if we may be of further assistance to you.
    Attached Files
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Thank you. I'm not sure I follow all of the code you sent. For a short position, I think ultimately I just need to look at the high since entry price and compare it to the current value and if the difference is greater than X close the position. I tried writing the below formula but I get an error for how I am using High. Could you assist with this? Thanks.

      if ((High(BarsSinceEntryExecution()) - Close[0]) > (30 * TickSize));
      ..............

      Comment


        #4
        Hello GoodTradingFun,

        Thank you for your reply.

        High is a series, not a method. High[BarsSinceEntryExecution()] would get you the value of the high for however many bars back it's been since your entry was last executed, but it's important to keep in mind that if no entries have been taken, BarsSinceEntryExecution would return a -1.

        If you wanted to get the maximum high since the entry, this starts to get more complicated, especially if you're using the Strategy Builder and haven't unlocked the code. You can use the MAX() indicator to return the highest high since entry, but the lookback period for this cannot be 0 or -1. It's much simpler to code this logic manually with all the offsets you want to do. I've created a simple unlocked example that illustrates entering short, getting the bars since the entry, and using this with the MAX indicator to get the maximum high since entry to trigger the exit if the difference between that and the close is greater than 30 ticks.

        Here's some help guide links that may be helpful:







        Please let us know if we may be of further assistance to you.
        Attached Files
        Kate W.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Christopher_R, Today, 12:29 AM
        0 responses
        9 views
        0 likes
        Last Post Christopher_R  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        166 responses
        2,235 views
        0 likes
        Last Post sidlercom80  
        Started by thread, Yesterday, 11:58 PM
        0 responses
        3 views
        0 likes
        Last Post thread
        by thread
         
        Started by jclose, Yesterday, 09:37 PM
        0 responses
        8 views
        0 likes
        Last Post jclose
        by jclose
         
        Started by WeyldFalcon, 08-07-2020, 06:13 AM
        10 responses
        1,415 views
        0 likes
        Last Post Traderontheroad  
        Working...
        X