• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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,
    https://ninjatrader.com/support/foru...ead.php?t=6652

    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 kabott, Today, 10:47 AM
        0 responses
        2 views
        0 likes
        Last Post kabott
        by kabott
         
        Started by bc24fl, Today, 10:00 AM
        3 responses
        8 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by TonyParisi, Today, 07:38 AM
        2 responses
        11 views
        0 likes
        Last Post TonyParisi  
        Started by fx.practic, Today, 10:03 AM
        2 responses
        7 views
        0 likes
        Last Post fx.practic  
        Started by traderpards, 12-12-2018, 01:15 PM
        6 responses
        154 views
        0 likes
        Last Post NinjaTrader_PaulH  
        Working...
        X