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 Brevo, Today, 01:45 AM
    0 responses
    2 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    3 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    238 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    384 views
    1 like
    Last Post Gavini
    by Gavini
     
    Started by oviejo, Today, 12:28 AM
    0 responses
    4 views
    0 likes
    Last Post oviejo
    by oviejo
     
    Working...
    X