Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

profit target & stop loss after gap on new trading day

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

    profit target & stop loss after gap on new trading day

    Hi,

    how does Ninjatrader handle a profit target after a gap (first candle on new trading day)?
    how does Ninjatrader handle a stop loss after a gap (first candle on new trading day)?

    See images attached. Both strategys are exactly the same, but one does EnterLong the other EnterShort. One is executed on candles low the other on candles open.





    Regards,

    Martin
    Attached Files

    #2
    Hello Emakon,

    Thank you for your note.

    You are short, market closes, market opens above your stop price and your order is triggered on the opening print.

    Regarding the PT being filled after the open, at a lower price, this could be resolved by adding a secondary tick series to the script. Please see the following example,
    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


    Please let us know if you need further assistance.
    Alan P.NinjaTrader Customer Service

    Comment


      #3
      Hi Alan,

      thanks for the info.

      How do I define SetProfitTarget to work on the new data series?

      As far as I know I can define BarsInProgress on EnterLong etc.

      Martin

      Comment


        #4
        OK, I coded my own SL and TP

        Code:
        protected override void OnOrderUpdate(Order order, double limitPrice, double stopPrice, int quantity, int filled, double averageFillPrice, OrderState orderState, DateTime time, ErrorCode error, string comment ) {
        			
        			if ( order.OrderState == OrderState.Filled && order.Name == "X" ) {
        				
        				double TP_Price = averageFillPrice * ( 1 + SLTPinPercent / 100 );
        				double SL_Price = averageFillPrice / ( 1 + SLTPinPercent / 100 );
        				
        				TP_Order = ExitLongLimit( 2, true, 1, TP_Price, "TP", "X" );
        				SL_Order = ExitLongStopMarket( 2, true, 1, SL_Price, "SL", "X" );
        			}
        			
        			if ( order.OrderState == OrderState.Filled && order.Name == "TP" ) {
        				CancelOrder( SL_Order );
        			}
        			if ( order.OrderState == OrderState.Filled && order.Name == "SL" ) {
        				CancelOrder( TP_Order );
        			}
        		}

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by maybeimnotrader, Today, 05:46 PM
        0 responses
        6 views
        0 likes
        Last Post maybeimnotrader  
        Started by quantismo, Today, 05:13 PM
        0 responses
        6 views
        0 likes
        Last Post quantismo  
        Started by AttiM, 02-14-2024, 05:20 PM
        8 responses
        166 views
        0 likes
        Last Post jeronymite  
        Started by cre8able, Today, 04:22 PM
        0 responses
        8 views
        0 likes
        Last Post cre8able  
        Started by RichStudent, Today, 04:21 PM
        0 responses
        5 views
        0 likes
        Last Post RichStudent  
        Working...
        X