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

Orders

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

    Orders

    Hi,

    I am developing a strategy but i have some issues. I am using the manage approach to send limit orders (target) and stop order (Stoploss). When the entry order for 5 contracts is executed, in the strategy, I send 2 limit orders for the target 1 and 2 (see picture 1 and 2) and stoploss. The problem is that when the price reach the target 1, inmediadly, the target 2 and stoploss are cancelled (see picture 3).
    This problems occurs when the entry order has slippage, as you can see in the image, this example has slippage.

    I used TraceOrders and the results in Ninjatrader output are:

    to the orders:

    29/01/2018 2:21:08 p. m. Strategy ‘Test Strategy/141663278’: Entered internal SubmitOrderManaged() method at 29/01/2018 2:21:08 p. m.: BarsInProgress=4 Action=BuyToCover OrderType=Limit Quantity=2 LimitPrice=2862.75 StopPrice=0 SignalName='Target 0 - Minute 7' FromEntrySignal='Short Entry Minute 7'
    29/01/2018 2:21:08 p. m. Strategy ‘Test Strategy/141663278’: Entered internal

    SubmitOrderManaged() method at 29/01/2018 2:21:08 p. m.: BarsInProgress=4 Action=BuyToCover OrderType=Limit Quantity=2 LimitPrice=2862.00 StopPrice=0 SignalName='Target 1 - Minute 7' FromEntrySignal='Short Entry Minute 7'
    29/01/2018 2:21:08 p. m. Strategy ‘Test Strategy/141663278’: Entered internal
    SubmitOrderManaged() method at 29/01/2018 2:21:08 p. m.: BarsInProgress=4 Action=BuyToCover OrderType=StopMarket Quantity=5 LimitPrice=0 StopPrice=2866.00 SignalName='Stoploss Minute 7' FromEntrySignal='Short Entry Minute 7'

    And this the code that is generated when the orders are cancelled:

    29/01/2018 2:27:44 p. m. Strategy ‘141663278/Test Strategy: Cancelled pending exit order, since associated position is closed, orderId='384926a31216458597aac6850408ab30' account='Playback101' name='Stoploss Minute 7' orderState=Accepted instrument='ES 09-18' orderAction=BuyToCover orderType='Stop Market' limitPrice=0 stopPrice=2864 quantity=3 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=1803 time='2018-01-29 14:21:08' gtd='2099-12-01' statementDate='2018-01-29'

    29/01/2018 2:27:44 p. m. Strategy ‘141663278/Test Strategy: Cancelled pending exit order, since associated position is closed, orderId='14a4b2cb39974b77ae988a186afa9ddf' account='Playback101' name='Target 1 - Minute 7' orderState=Working instrument='ES 09-18' orderAction=BuyToCover orderType='Limit' limitPrice=2862 stopPrice=0 quantity=2 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=1802 time='2018-01-29 14:21:08' gtd='2099-12-01' statementDate='2018-01-29'

    Can you help me to solve this issue?

    Richard Martinez M.
    Attached Files

    #2
    Hello Richardmm,
    Thanks for your post.

    It looks like you may be trying to scale out of your position. Scaling out is not possible in this way with the 'Managed Approach'. If you submit two exit orders with the same "fromEntrySignal" then as soon as the first order fills it will cancel all of the others.I can take a closer look but I would need to see the strategy.

    The following link is a reference sample of how to scale out of position.


    If you have made all of the above considerations and still seeing unexpected behavior you can write in to PlatformSupport(at)NinjaTrader(dot)com and reference this forum post.

    You can export your strategy by going to Tools > Export > NinjaScript Add On > Add > select your strategy > OK > Export > name the file 'NTsupport' > Save. The file will be located under Documents\NinjaTrader 8\bin\Custom\ExportNinjaScript.
    Josh G.NinjaTrader Customer Service

    Comment


      #3
      Thank you, I saw the example but I don't use SetProfitTarget and SetTrailStop, I use EnterLongStopMarket and EnterShortStopMarket; for the target, ExitShorLimit and ExitLongLimit.

      Looking for Ninjatrader Forum, I found this thread.



      The user has the same problem. A Ninjatrader Customer Service proposed Unmanaged mode but it has a problem for me because my strategy is multi-timeframe and I need "fromEntrySignal" parameter.

      Richard Martinez M.

      Comment


        #4
        Bertrand is correct in that post. If you choose to go with the 'Unmanaged Approach' you could work with an OCO ID instead of "fromEntrySignal" to submit the orders how you describe.
        Josh G.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by maybeimnotrader, Yesterday, 05:46 PM
        4 responses
        23 views
        0 likes
        Last Post maybeimnotrader  
        Started by frankthearm, Today, 09:08 AM
        6 responses
        24 views
        0 likes
        Last Post frankthearm  
        Started by adeelshahzad, Today, 03:54 AM
        5 responses
        33 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by stafe, 04-15-2024, 08:34 PM
        7 responses
        32 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by merzo, 06-25-2023, 02:19 AM
        10 responses
        823 views
        1 like
        Last Post NinjaTrader_ChristopherJ  
        Working...
        X