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

Stop Limit Order easily canceled by Chart Trader

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

    Stop Limit Order easily canceled by Chart Trader

    Hi,

    I am developing a Strategy that uses AtmStrategyCreate to submit orders for futures (YM or NQ). The problem I encounter is that Chart Trader cancels the orders quite often
    e.g. strategy issues a stop limit order to sell at (limitPrice=stopPrice=35550), once price zooms past the price, the order is cancelled. What I would like is to have the limit order "stand" i.e. limit order to sell at 35550 so that it will be filled once price reaches back up to that level.

    I looked at checking the event in OnOrderUpdate (and putting in a limit order) but the cancellation of the order does not come with any indication that it was Chart Trader that "automagically" canceled the order or that the reason for the cancellation was because the price has zoomed way past the limit price.

    Anybody:
    1. Is there a way to check for the specific condition (Chart Trader cancels order because price zoomed past)?
    2. Some suggestions/tips to overcome this
    Thanks!

    #2
    Hello mav8rick,

    Thank you for your reply.

    I would recommend turning on TraceOrders:

    Strategy Builder > Default Properties > More Properties > Trace Orders, or:

    if (State == State.SetDefaults)
    {
    TraceOrders = true;
    }

    Once you then recompile the strategy, you can open a new NinjaScript Output window under New > NinjaScript Output. This will print a log of any orders submitted by the strategy during while it's running, along with any ignored or cancelled orders. You can then look through and see what may be occurring.

    Here is a link to our help guide that goes into more detail on tracing orders:

    https://ninjatrader.com/support/help...aceorders2.htm

    As Stop Limit orders can only be placed above the market for buy stop limits and below the market for sell stop limits, I suspect this may be related to the stop limit being on the wrong side of the market.

    Please let us know if we may be of further assistance to you.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Hi Kate,

      I have added the line to my code and compiled it under non-debug AND debug - in both cases, I cannot find any trace in the NinjaScript Output window.

      Say, currently price is 35555 and I place a stop limit sell at limitPrice=stopPrice=35550 in a range chart (it seems like system acts differently in time-based e.g. min-chart over tick/range charts). The order is "submitted" but not "accepted" right? Ninja will then attempt to place the order once price 35550 e.g 35548. However, since price is now 35548, Ninja will automatically cancel the order. So far, is my description of what happened correct? In this case, I won't even get an order trace.

      My question is - if my description is correct - how do I get the system to either "keep" the sell limit order at 35550 OR give me a signal that I can work with so that I can add code to put in a new order for a limit sell at 35550?

      Comment


        #4
        Hello mav8rick,

        To clarify, TraceOrders will show order feedback for orders belonging to the NinjaScript strategy. Atm Strategy NinjaScript methods trigger Atm strategies, so we would not see TraceOrder output from those order methods.

        A Sell Stop Limit order of 35550x35550 placed when the market is at 35555 would be submitted and unless the market moves 5 ticks before the order is received and processed, it will reach Accepted. Once the stop price is hit, it will convert to a limit order and reach a Working state. As it would be a limit order, we then have 2 scenarios:

        1. Market moves below the Sell Limit Order price of 35550 and the order remains active/working, because the sell limit price is higher than the current market price
        2. Market moves above the Sell Limit Order price of 35550 and the order automatically fills, because the sell limit order is lower than the current market price

        Atm Strategy methods do not have an IsLiveUntilCancelled parameter like Managed Approach order methods. The order must be cancelled in the strategy code, or possibly through actions like clicking the Close button on Chart Trader.

        I have attached a test strategy that is a modification of the SampleAtmStrategy example that places a Sell Stop Limit order at 3555x3555 and can be tested on ES 12-21 10 second chart with your Sim101 account. Please test this on a new chart in a blank workspace that does not have anything else added to it. We want to be sure that the order does not automatically cancel here when all we do is enable the strategy. (We should not expect a cancel because we are not taking any actions that would trigger a cancel, and neither is the strategy.)

        The test strategy starts an ATM strategy template named "ATM 1"

        If you see cancel behaviors with your strategy, but not with this test strategy, it would mean there is some logic in your strategy that is cancelling the order.

        If you see the cancel behavior with the test strategy, please clarify how you are testing and what exactly occurs when the order gets cancelled. I may also ask that you reach out to me over email and provide your log and trace files, since we can better see where a cancel may be coming from. You may email me at scriptingsupport [at] ninjatrader [dot] com with the text "Attn Jim 3369287" Please include a link to this thread in addition to those files.

        Attaching Log and Trace files

        You may follow the steps below to attach your log and trace files in an email to us:
        • Open your NinjaTrader folder under My Documents.
        • Right click on the 'log' and 'trace' folders and select Send To> Compressed (zipped) Folder.
        • Send the 2 compressed folders as attachments to an email to me.
        • Once complete, you can delete these compressed folders.
        We look forward to assisting.



        Attached Files
        JimNinjaTrader Customer Service

        Comment


          #5
          Hi Jim,

          I am having problems trying to replicate the problem because under Sim, I always get filled but in real-life, I normally don't get filled.

          I have tried throwing away my programmed strategy and just use a pure manual ATM approach to test:
          1. Have a range chart (e.g. 5-range chart) on something like YM, MNQ etc
          2. Place a buy stop limit (when price is above the trigger price of course)
          3. Price moves down and past the level
          4. You will see that Ninja cancels the order
          I have just done a manual order using a live account (Interactive Brokers) using the above steps and the log shows:
          12/2/2021 4:15 Order Order='418905677/U******' Name='Entry' New state='Cancelled' Instrument='MNQ 12-21' Action='Buy' Limit price=15971.25 Stop price=15971.25 Quantity=1 Type='Stop Limit' Time in force=DAY Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
          12/2/2021 4:15 Order Order='aaabc89b50fc4270af8390847cfeff8a/U******' Name='Entry' New state='Submitted' Instrument='MNQ 12-21' Action='Buy' Limit price=15971.25 Stop price=15971.25 Quantity=1 Type='Stop Limit' Time in force=DAY Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
          12/2/2021 4:15 Order Chart Trader submitting order with strategy '1x SL 20 - 1' (Ticks)

          You can see that the order was "Submitted" but it was never "Accepted" and once price zooms past the limit price which is 15971.25, Ninja automatically cancelled the order - I did not have any strategy sending close/cancels and I certainly did NOT press the close button on ATM.

          As I have said - I think the problem wasn't there on the minute/time charts but I am having hell of a problem with the range charts - which I need - because they help me enter during periods of what looks like super low volatility price action on even the 1-min.

          Note - it's 3 specific conditions; it must be "live" (you will never see the problem under Sim) and you must be using a range chart and you must be using a stop limit buy/sell order on ATM (programmatically/manual).
          Last edited by NinjaTrader_Jim; 12-02-2021, 08:50 AM. Reason: Redacted account number

          Comment


            #6
            Hello mav8rick,

            I would like to further review the full log and trace files so I may confirm the actions taken by the platform. If we are now talking about manual submissions alone (without automation,) please email me at platformsupport [at] ninjatrader [dot] com with the text "Attn Jim 3369287" Please include a link to this thread in addition to those files. Please also detail specific Order ID's for me to reference and specific times. (418905677 @ 12/2/2021 4:15 would be an example case I can check into)

            Could you also confirm that you see this behavior when using the version of TWS/IB Gateway that we include in our Connection Guide? Using other versions of these applications with NinjaTrader have sometimes lead to unexpected results.

            Connection Guide - https://ninjatrader.com/ConnectionGu...nnection-Guide

            I performed some manual tests entering long with an ATM that has a 5 tick Stop Loss submitted as a Stop Limit order this morning. I tested on an Interactive Brokers paper trading account on TWS 985.1g and I did not get any stop losses that were cancelled instead of filling. I also did not have issues with entry Stop Limit orders that have the same Limit and Stop price.

            I look forward to hearing from you.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Sparkyboy, Today, 10:57 AM
            0 responses
            3 views
            0 likes
            Last Post Sparkyboy  
            Started by TheMarlin801, 10-13-2020, 01:40 AM
            21 responses
            3,917 views
            0 likes
            Last Post Bidder
            by Bidder
             
            Started by timmbbo, 07-05-2023, 10:21 PM
            3 responses
            152 views
            0 likes
            Last Post grayfrog  
            Started by Lumbeezl, 01-11-2022, 06:50 PM
            30 responses
            811 views
            1 like
            Last Post grayfrog  
            Started by xiinteractive, 04-09-2024, 08:08 AM
            3 responses
            11 views
            0 likes
            Last Post NinjaTrader_Erick  
            Working...
            X