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

Cancelled Order prevent New Order

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

    Cancelled Order prevent New Order

    Hi,

    I have a strategy using Buttons. Following the UserControlCollection guide, i am able to create the buttons with Long and Short Limit entries. However, there seem to be a problem:
    1. Click LONG Button.
    2. Order placed.
    3. Cancels the order by clicking the 'x' on the Chart. (Before the order is triggered)
    4. Recreate order by clicking the LONG button. Nothing happens. Log prints.

    - Have debugged using a unique signalName. Doesn't work.
    - Removing signalName. Doesn't work.

    I'm suspecting the strategy needs to have cancel the order too? If so, how can it be detected when the 'x' is clicked

    #2
    Hello twelvester,

    Welcome to the NinjaTrader support forums.

    If your plan involves working with orders manually at all from any existing tool you should avoid using a strategy for this. Canceling the order would also need to be done using a custom button and then using the CancelOrder command. https://ninjatrader.com/support/help...ub=CancelOrder
    You won't be able to detect the cancel by using the X button to correctly cancel the order.

    If you want to work with the existing order entry tools or do manual modifications to orders without making custom buttons you should use an Indicator and the Addon account methods. With an indicator you can observe an account directly to submit or modify orders. This does not use the strategies managed order handling approach which expects the strategy to do all order related actions.





    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi Jesse,

      I think i used strategies as the methods did not seem to exist when i use the Indicator. Getting an error in the Indicator that EnterLongStopLimit, EnterShortStopLimit, SetStopLoss, and SetProfitTarget does not exist in the current context. Am i able to create an order using an Indicator?

      As the existing Buttons on the Chart Trader Buys at Market or Bid, i actually would like to have the order say at 1 tick above the current bar. Using the mouse right click is sometimes too slow.

      Comment


        #4
        Hello twelvester,

        I think i used strategies as the methods did not seem to exist when i use the Indicator. Getting an error in the Indicator that EnterLongStopLimit, EnterShortStopLimit, SetStopLoss, and SetProfitTarget does not exist in the current context. Am i able to create an order using an Indicator?
        The methods you are referring to are part of the strategy specifically, that is the Managed apparoch. If you want to work with the orders the manual tools make or if you want to manually modify orders any still have logic you would want to avoid using anything strategy related. The strategy expects to trade for you without manual interaction.

        You could instead use the addon account methods to place orders from any other context that is not a strategy. You would not use the methods like EnterLong you would instead use the account object and its Submit method. I provided some links about those functions in the last post. Here are some comments for those links:
        https://ninjatrader.com/support/help...ount_class.htm accessing the account and storing it to a variable
        https://ninjatrader.com/support/help...t8/?submit.htm submitting orders using the account

        As the existing Buttons on the Chart Trader Buys at Market or Bid, i actually would like to have the order say at 1 tick above the current bar. Using the mouse right click is sometimes too slow.
        Sure you could do that in the strategy or indicator by using its bar prices and events. If you need to calculate a price that's 1 tick away you could use the formula Price + 1 * TickSize.
        JesseNinjaTrader Customer Service

        Comment


          #5
          Thanks so much for the information. I have decided that the Managed Approach is much easier to handle and its safer.

          Would i be able to mimic the Buy and Sell buttons in the Chart Trader where by the order levels can be dragged and dropped. Is this the UnManaged approach?

          Comment


            #6
            Hello twelvester,

            You could recreate the buy/sell orders however the lines that you see for the chart trader are made specifically by the chart trader for manual orders, while those do show up for strategy based orders you won't be able to accurately use them to control the orders. If you drag and drop the order you still have the chance the strategy will update the order back to the original price, for this concept you could likely use a drawing object and monitor it but that gets into more complex code.

            As it sounds like this is intended to be a realtime tool you could use the drawing objects collection to monitor an object you drew. For example drawing the object when your order is submitted. In your code you could check at some interval what the values are for the object and if that differs from the order, if it differed change the order.

            With strategies you generally have to get creative if you plan to use any manual interactions as they are really intended to trade based on logic.
            example of storing an object to a variable: https://ninjatrader.com/support/help...rawingtool.htm
            Finding other manual objects:
            https://ninjatrader.com/support/help...ub=drawobjects
            Dynamic is often needed to use objects:
            https://ninjatrader.com/support/help...ghtsub=dynamic


            I look forward to being of further assistance.
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by f.saeidi, Yesterday, 12:14 PM
            9 responses
            23 views
            0 likes
            Last Post f.saeidi  
            Started by Tim-c, Today, 03:54 AM
            0 responses
            3 views
            0 likes
            Last Post Tim-c
            by Tim-c
             
            Started by FrancisMorro, Today, 03:24 AM
            0 responses
            3 views
            0 likes
            Last Post FrancisMorro  
            Started by Segwin, 05-07-2018, 02:15 PM
            10 responses
            1,772 views
            0 likes
            Last Post Leafcutter  
            Started by Rapine Heihei, 04-23-2024, 07:51 PM
            2 responses
            31 views
            0 likes
            Last Post Max238
            by Max238
             
            Working...
            X