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 inanazsocial, Today, 01:15 AM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Jason  
    Started by rocketman7, Today, 02:12 AM
    0 responses
    6 views
    0 likes
    Last Post rocketman7  
    Started by dustydbayer, Today, 01:59 AM
    0 responses
    1 view
    0 likes
    Last Post dustydbayer  
    Started by trilliantrader, 04-18-2024, 08:16 AM
    5 responses
    23 views
    0 likes
    Last Post trilliantrader  
    Started by Davidtowleii, Today, 12:15 AM
    0 responses
    3 views
    0 likes
    Last Post Davidtowleii  
    Working...
    X