Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.


    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.
    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.


        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 jclose, Today, 09:37 PM
        0 responses
        4 views
        0 likes
        Last Post jclose
        by jclose
         
        Started by WeyldFalcon, 08-07-2020, 06:13 AM
        10 responses
        1,413 views
        0 likes
        Last Post Traderontheroad  
        Started by firefoxforum12, Today, 08:53 PM
        0 responses
        10 views
        0 likes
        Last Post firefoxforum12  
        Started by stafe, Today, 08:34 PM
        0 responses
        10 views
        0 likes
        Last Post stafe
        by stafe
         
        Started by sastrades, 01-31-2024, 10:19 PM
        11 responses
        169 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X