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

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by johnMoss, Today, 10:12 AM
        1 response
        18 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by thaison316, 03-29-2021, 03:12 PM
        4 responses
        52 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by WHICKED, Today, 09:51 AM
        1 response
        20 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by simple_goodoboy, Today, 09:15 AM
        1 response
        21 views
        0 likes
        Last Post NinjaTrader_Kate  
        Started by debleded, Today, 09:10 AM
        1 response
        25 views
        0 likes
        Last Post NinjaTrader_Kate  
        Working...
        X