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

CancelEntryOrder

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

    CancelEntryOrder

    Hi,


    I'm testing a strategy and having problems when a StopLimit Order isn't filled..

    I need to cancel the EntryOrder and I'm using this code.


    AtmStrategyCancelEntryOrder(orderId);

    But I get this message...


    'AtmStrategyCancelEntryOrder' method error: OrderId 'e76fd41fc98b4a508f1ad1373300f87d' does not exist


    But when I put some Print statements in the code to print to the output window the OrderId is correct...


    This is the details I get once the order is submitted.
    MES 03-22 Chart
    Limt Buy Price : 4688.75
    Stop Buy Price : 4688.25
    OrderId : e76fd41fc98b4a508f1ad1373300f87d


    and then when my code attempts to CancelEntryOrder I double check OrderId and it's this

    MES 03-22 Chart
    OrderId : e76fd41fc98b4a508f1ad1373300f87d

    'AtmStrategyCancelEntryOrder' method error: Order ID 'e76fd41fc98b4a508f1ad1373300f87d' does not exist


    It does it every-time..

    PS. I'm using some of the code from SampleATMStrategy. to place the order and manage.

    isAtmStrategyCreated = false;
    atmStrategyId = GetAtmStrategyUniqueId();
    orderId = GetAtmStrategyUniqueId();

    AtmStrategyCreate(OrderAction.Buy, OrderType.StopLimit, limitPrice, stopPrice, TimeInForce.Gtc, orderId, "AtmStrategyTemplate", atmStrategyId, (atmCallbackErrorCode, atmCallBackId) =>
    {

    //check that the atm strategy create did not result in error, and that the requested atm strategy matches the id in callback
    if (atmCallbackErrorCode == ErrorCode.NoError && atmCallBackId == atmStrategyId)
    isAtmStrategyCreated = true;

    }
    );

    This is just part of the code hopefully you will understand...



    Thanks..


    #2
    Hi traderhawk, thanks for posting.

    Either the entry order is filled or does not exist at the time you cancel or the order is not valid in the first place. The test script I attached works to cancel the entry order on the next bar. Please test on your end to confirm this one works as well. You can test this file by placing the .cs within Documents\NinjaTrader 8\bin\Custom\Strategies and ensure you have an ATM template called "AtmStrategyTemplate"

    Kind regards,
    -ChrisL
    Attached Files
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hi Chris,

      Thanks for the reply.. I'm trying your Strategy...

      Regards
      Bruce

      Comment


        #4
        Hi Chris,

        Ok finally worked it out.. I used your code which I modified slightly (CurrentBar != submitbar + 1) to fix a problem to managed order before filled but also had to use IsFirstTickOfBar to confirm order...see attached.. works on 6 range and I guess other data series.. but easier to test order management on 6 range as new bars generated often. This Strategy is just for testing order flow and management so I can understand how it works..achieved that..
        Thanks for your help.
        Attached Files
        Last edited by traderhawk; 12-14-2021, 05:34 AM.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Karado58, 11-26-2012, 02:57 PM
        8 responses
        14,825 views
        0 likes
        Last Post Option Whisperer  
        Started by Option Whisperer, Today, 09:05 AM
        0 responses
        1 view
        0 likes
        Last Post Option Whisperer  
        Started by cre8able, Yesterday, 01:16 PM
        3 responses
        11 views
        0 likes
        Last Post cre8able  
        Started by Harry, 05-02-2018, 01:54 PM
        10 responses
        3,204 views
        0 likes
        Last Post tharton3  
        Started by ChartTourist, Today, 08:22 AM
        0 responses
        6 views
        0 likes
        Last Post ChartTourist  
        Working...
        X