Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Switching from Stop to TrailStop

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

    Switching from Stop to TrailStop

    I have a strategy in which I would like to start with a fixed stop in ticks, and then when the position achieves a certain unrealized profit, move to a trailing stop. Here is part of the code:

    Code:
                // Short Entry
                if (EMAProgressionAvg(14, 5).Trade_Entry[0] == -1 && EMAProgressionAvg(14, 5).Trade_Entry[1] != -1
    				&& Position.MarketPosition == MarketPosition.Flat
    				&& ((ToTime(Time[0]) > TT1_Start && ToTime(Time[0]) < TT1_End ) || (ToTime(Time[0]) > TT2_Start && ToTime(Time[0]) < TT2_End )))
                	{
                    EnterShort(DefaultQuantity, "EPA_S");
    	            SetStopLoss("", CalculationMode.Ticks, Stop, false);
                	}
    				
    			if (Position.GetProfitLoss(Close[0], PerformanceUnit.Currency) > Mov_Stop * TickSize)
    				{
    				SetTrailStop("", CalculationMode.Ticks, Stop2, false);
    				}
    The relevant portion is the last part where I test if unrealized profit (in currency) is greater than a variable, Mov_Stop. If so, then I set the trail stop to a new. smaller stop, "Stop2". The problem is it doesn't seem to work. When I back test I never see a trade which ends because of the trailing stop. I just see trades which exit via a profit target, the original stop loss, or close of the session.
    Is it possible to switch, on the fly, from a stop loss to a trail stop?
    Thanks
    DaveN

    #2
    Hello daven,

    Thanks for your note.

    It is not possible to switch from SetStopLoss to SetTrailStop. This is mentioned in the SetStopTrail section of the help guide linked below.
    http://www.ninjatrader.com/support/h...ttrailstop.htm

    Once SetStopLoss has been set for an entry signal it will over write any SetTrailStop.
    An alternative would be to use an ExitLongStop or ExitLongStopLimit and update the stop price either every tick or every so many ticks in the OnMarketData method.

    Below is a link to the help guide on OnMarketData.
    http://www.ninjatrader.com/support/h...marketdata.htm


    Please let me know if this does not resolve your inquiry.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by josh18955, 03-25-2023, 11:16 AM
    6 responses
    435 views
    0 likes
    Last Post Delerium  
    Started by FAQtrader, Today, 03:35 PM
    0 responses
    3 views
    0 likes
    Last Post FAQtrader  
    Started by rocketman7, Today, 09:41 AM
    5 responses
    18 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by frslvr, 04-11-2024, 07:26 AM
    9 responses
    126 views
    1 like
    Last Post caryc123  
    Started by selu72, Today, 02:01 PM
    1 response
    12 views
    0 likes
    Last Post NinjaTrader_Zachary  
    Working...
    X