Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Stop Loss Order Questions

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

    Stop Loss Order Questions

    Hi, Thanks in advance for shedding some light on my questions. The following code is called in OnBarUpdate() and CalculateOnBarClose = true;

    Code:
    if(Position.MarketPosition == MarketPosition.Long){	
    	 stopOrder = ExitLongStop(stopLoss,"Stop Losss Long",My_LONG);
    				   
    }
    So this would get called over and over again as long as I have a long position. What does Ninjatrader do here? does it get ignored if there is already a stop order in place? It looks almost like that if my observations are correct.

    I said "almost" because it works fine in the same trading session. However, Ninjatrader cancels the stop order, place another exactly same one if the trade spans multiple sessions even if the TIF is GTC.

    Another strange behavior is that if code is like the following, the stop order is in place for the next bar only and then gets cancelled and never generated again,




    Code:
     private IOrder stopOrder = null;
    
     protected override void OnBarUpdate(){
    	if(my condtions met){
    		EnterLong();
    		stopOrder = null;
    	}
    
    	if(Position.MarketPosition == MarketPosition.Long){	
    		if( stopOrder == null;)
    		   stopOrder = ExitLongStop(stopLoss,"Stop Losss Long",My_LONG);
    					   
    	}
    
    }

    #2
    Hello sys_trader,

    Thanks for your post.

    Yes this is correct. When the liveUntilCancelled bool is not used, the order will cancel at the end of the bar.

    To have an order not be cancelled at the end of the bar use liveUntilCancelled as true.
    For example:
    ExitLongStop(0, true, 1, stopLoss, "Stop Losss Long", My_LONG);
    ExitLongStop(int barsInProgressIndex, bool liveUntilCancelled, int quantity, double stopPrice, string signalName, string fromEntrySignal)
    http://www.ninjatrader.com/support/h...itlongstop.htm

    Also, when starting a strategy that has been disabled, NinjaTrader will first cancel any live working orders that were made by the strategy previously. (This is so no problems occur from the strategy when it trys to recalculate and resubmit profit targets, stop losses etc. from the previous run). If the Immediately submit live working historical orders is selected in Tools -> Options... -> Strategies -> NinjaScript, then any orders that should be live historically will be resubmitted.
    http://www.ninjatrader.com/support/h..._positions.htm
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by gentlebenthebear, Today, 01:30 AM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by Aviram Y, Today, 05:29 AM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by cls71, Today, 04:45 AM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by TradeForge, Today, 02:09 AM
    1 response
    22 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by elirion, Today, 01:36 AM
    2 responses
    14 views
    0 likes
    Last Post elirion
    by elirion
     
    Working...
    X