Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Exit Stops Not Working

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

    Exit Stops Not Working

    I am trying to execute a stop exit which moves up for longs and down down for shorts on subsequent bar movements in the direction of the trend. The code below reflects my entry with associated stop placement and the second code section is the component which moves the stop down if the current bar is lower relative to the variable set when the stop order is initially placed or moved.
    None of this is working. When I back test in the strategy analyzer I don't get a single stop exit, just a buy or sell on close. what am I doing wrong? I test to make sure the stop price is above or below the current ask or bid to make sure I'm not placing an illegal stop order. I have TraceOrders turned on and I see planty of stop orders going through wih the occassional exit order placed without and assocatied order, (not sure why that happens but I'm guessing it has to do with the imprefections of backtesting in the SA).
    Any idea what I am messing up?

    Code:
                // Short Entry
           if(anaGaussianFilter(9, 3).Gaussian[0] <= anaSuperSmootherFilter(9, 3).SuperSmoother[0]
    && TriggerLinesDelta(20, 8).TL_Delta[0] < 0
    && Falling(TriggerLinesDelta(20, 8).TL_Delta) == true
    && 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, "Sc2_S");
    	ExitShortStop(High[1] + +2 * TickSize, "Sc2_SX", "Sc2_S");
    	Variable1 = High[1] + +2 * TickSize;
                }
    Second code sample for moving stop down with new lower bar

    Code:
    				
    			// 	Lock in Profit on Short Position
                if (Position.MarketPosition == MarketPosition.Short
                    && Close[0] < Position.AvgPrice - Take_Profit * TickSize
    								&& Variable1 > GetCurrentAsk()
    				&& !controlOne)
                	{
    				ExitShortStop(High[0] + 2 * TickSize, "Sc2_SPX", "Sc2_S");
    				Variable1 = High[0] + 2 * TickSize;
    				controlOne = false;
    				}

    #2
    daven,

    Some of what you are describing here is due to a lack of intrabar granularity. You may want to use the following reference sample to see if it helps.

    You can submit orders to different Bars objects. This allows you the flexibility of submitting orders to different timeframes. Like in live trading, taking entry conditions from a 5min chart means executing your order as soon as possible instead of waiting until the next 5min bar starts building. You can achieve this by
    Adam P.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by GussJ, 03-04-2020, 03:11 PM
    11 responses
    3,227 views
    0 likes
    Last Post xiinteractive  
    Started by andrewtrades, Today, 04:57 PM
    1 response
    13 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by chbruno, Today, 04:10 PM
    0 responses
    7 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Started by josh18955, 03-25-2023, 11:16 AM
    6 responses
    440 views
    0 likes
    Last Post Delerium  
    Started by FAQtrader, Today, 03:35 PM
    0 responses
    12 views
    0 likes
    Last Post FAQtrader  
    Working...
    X