• 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

Enter and Exit orders in the same bar update

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

    Enter and Exit orders in the same bar update

    Hi, I am trying to Enter a trade and set the take profit and loss points in the same bar update but the script seems to pass over the exit limit orders for some reason. I when I put the exit order logic into the following bar they get set but I also get this error in the output window:
    "A BuyToCover stop order placed at '9/1/2016 9:05:00 AM' has been ignored since the stop price is less than or equal to the close price of the current bar. This is an invalid order and subsequent orders may also be ignored. Please fix your strategy." I have multiple of these errors, I assume because the strategy is setting these limits a bar late and occasionally the price moves through the limit which isn't set yet.

    Below is the code that NT seems to be passing over:

    EnterLong(TradeSize, "longEntry");
    takeProfit= ExitLongMIT(0, true, TradeSize, LongSMA + ProfitMult*LongATR, "longProfit", "longEntry");
    takeLoss= ExitLongStopMarket(0, true, TradeSize/2, LongClose - LossMult*LongATR, "atrExitLong", "longEntry");

    Any ideas why it skips over the exit limits would be appreciated.

    Thanks,
    John

    #2
    Hello John,

    You are attempting to place these exit orders before the entry order exists or has filled.

    Do you want the entry and exit both working at the same time?

    Or do you want the exit to start working after the entry has filled?

    If you want the entry and exit both working at the same time submit the exit in OnOrderUpdate() after the entry has entered a working state.
    http://ninjatrader.com/support/helpG...rderupdate.htm

    If you want the exit to start working once the entry has filled and the position has been entered (similar to a stop loss or profit target), then submit the order in OnExecutionUpdate() after the entry order has filled.
    http://ninjatrader.com/support/helpG...tionupdate.htm
    Last edited by NinjaTrader_ChelseaB; 03-30-2017, 11:46 AM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Got it working using onexecutionupdate(). Thank you!

      Comment


        #4
        Originally posted by NinjaTrader_ChelseaB View Post
        Hello John,

        You are attempting to place these exit orders before the entry order exists or has filled.

        Do you want the entry and exit both working at the same time?

        Or do you want the exit to start working after the entry has filled?

        If you want the entry and exit both working at the same time submit the exit in OnOrderUpdate() after the entry has entered a working state.
        http://ninjatrader.com/support/helpG...rderupdate.htm

        If you want the exit to start working once the entry has filled and the position has been entered (similar to a stop loss or profit target), then submit the order in OnExecutionUpdate() after the entry order has filled.
        http://ninjatrader.com/support/helpG...tionupdate.htm
        Very helpful!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by riuhdfjkbh, Today, 05:40 AM
        0 responses
        2 views
        0 likes
        Last Post riuhdfjkbh  
        Started by pol133, Today, 02:35 AM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_Marco  
        Started by JAtrades, Today, 05:20 AM
        1 response
        4 views
        0 likes
        Last Post JAtrades  
        Started by timko, Today, 05:12 AM
        1 response
        6 views
        0 likes
        Last Post NinjaTrader_Marco  
        Started by collagen, 06-18-2020, 05:55 AM
        6 responses
        51 views
        1 like
        Last Post timko
        by timko
         
        Working...
        X