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 tsantospinto, 04-12-2024, 07:04 PM
        7 responses
        126 views
        0 likes
        Last Post aligator  
        Started by futtrader, 04-21-2024, 01:50 AM
        5 responses
        56 views
        0 likes
        Last Post NinjaTrader_Eduardo  
        Started by PeakTry, Today, 10:49 AM
        0 responses
        2 views
        0 likes
        Last Post PeakTry
        by PeakTry
         
        Started by llanqui, Today, 10:32 AM
        0 responses
        5 views
        0 likes
        Last Post llanqui
        by llanqui
         
        Started by StockTrader88, 03-06-2021, 08:58 AM
        45 responses
        3,994 views
        3 likes
        Last Post johntraderuser2  
        Working...
        X