• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

SetTrailStop with SetStopLoss One Cancels The Other

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

    SetTrailStop with SetStopLoss One Cancels The Other

    I'm working on a strategy that requires the use of both SetTrailStop and SetStopLoss but according to the docs (see line below) SetStopLoss has precedence unless using different signal names. I don't think i can use different signal names since i'm trading 1 instrument and 1 contract. What i'm trying to accomplish is have a fixed stop (SetStopLoss) for the x number of profit ticks and then cancel the SetStopLoss and move to a SetTrailStop. Any ideas? See pseudo code below:

    PSEUDO CODE:
    IF 8 TICK PROFIT - MOVE UP STOP LOSS TO BREAK EVEN
    THEN TRAIL THE REST OF THE MOVE.

    I can accomplish a trail using SetStopLoss but it's not as elegant as the one liner SetTrailStop.


    DOCUMENTATION:
    The SetTrailStop() method can NOT be used concurrently with the SetStopLoss() or SetParabolicStop() method for the same position, if any of methods are called for the same position (fromEntrySignal) the SetStopLoss() will always take precedence. You can however, use all three methods in the same strategy if they reference different signal names.

    #2
    Hello bc24fl,

    In this situation you would likely be best off just using SetStopLoss or an exit method and then adding logic to make that trail. As you noted you cannot use both types of orders at once so logic would be the next best solution.

    We have a sample that shows how to move a stop to breakeven, so that part can be used for this purpose: https://ninjatrader.com/support/help...and_onexec.htm

    A secondary condition could be placed after the break even condition to check if the stop should trail from that point. Calling SetStopLoss again will just update it so you can make it trail by calling it again for each OnBarUpdate where it should be trailing. Keep in mind if you control this with logic, you need to make that logic only work in one direction. What I mean is that if the price moved back down, you want the condition to recognize this so it does not adjust the stop back down in the opposite direction.

    You can find an example of trailing logic in the following post, this uses exit orders however the concept is generally the same. Using a condition you would trail the price yourself by calling the order method again with a new price: https://ninjatrader.com/support/foru...654#post785654


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      I have done something similar with help from Jim. To trail it you check for the profit above average entry price and move the Stop accordingly. So it moves on each tick of profit as in the ATM.

      Comment


        #4
        I have used this from the start to trail a position.

        if (Close[0] >= Position.AveragePrice + (11 * TickSize))

        SetStopLoss(CalculationMode.Price, Close[0] - (10 * TickSize));

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Fastbyte, Yesterday, 11:13 PM
        1 response
        1 view
        0 likes
        Last Post NinjaTrader_ChrisSch  
        Started by StealthM93, Yesterday, 07:58 PM
        1 response
        7 views
        0 likes
        Last Post bltdavid  
        Started by Mykro, Yesterday, 11:01 AM
        1 response
        5 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by bauerjj10, Yesterday, 12:24 PM
        1 response
        15 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Newtrader101, Yesterday, 06:01 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_EricB  
        Working...
        X