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

How to create bracket order which is identical to a bracket order in TWS?

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

    How to create bracket order which is identical to a bracket order in TWS?

    Hello,
    I want to create a bracket order, which is structured just like the bracket order in TWS.
    In picture 1 you can see that the bracket orders will be transmitted only if the main buy order is filled. But the orders are ready in TWS.
    I want to know how can I make a strategy that generate a LIMIT buy order but before it is executed it has attached to it a stop order and I can see it waiting in TWS.
    The logic for this is: if it is not waiting in TWS , if a connection problem occurs, I will be left off with a buy order without a stop attached to it.

    can you please give me example a simple code on how it is done?

    thank you. if needed I will explain further.

    #2
    Hello zoharcho, thanks for your post.

    Please note that our support staff will answer every post on the forum. I answered your support request through email, and will copy my response here as well.

    We have existing examples on setting up protective order brackets in NinjaScript. Please review the unmanaged examples we have here:

    https://ninjatrader.com/support/foru...elp#post770579

    This is based on this example, where it is officially documented as a reference sample, here is the managed version with links to all relevant documentation:

    https://ninjatrader.com/support/help...and_onexec.htm
    Best regards.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Thank you, I reviewed the unmanaged examples and tried that code, and it does not solve the problem as I mentioned. bracket orders are only submitted on execution, and not before as in the TWS bracket order.

      I am trying to run the SampleOnOrderUpdate strategy, but when I enable it, nothing happen, no historical trade or real time trade, any idea why?
      also not seeing any errors in log.

      thanks, ChrisL

      Comment


        #4
        Hello zoharcho, thanks for your reply.

        If you want to set your stop and target before the entry is filled you can do that, just call the respective orders when the entry order is submitted. E.g. if you are going to enter a long position use ExitLongStopMarket for the stop and ExitLongLimit for the limit order.

        I got at least one trade from the managed example I posted. If you right-click and go into the strategy performance, do you see a trade-in there? Also, if you are ever getting unexpected results in a strategy, place Print() methods throughout the strategy to see what code is being run and what code is not running e.g.

        if(EntryCondition)
        {
        Print("Entering Long");
        EnterLong();
        }

        Kind regards.
        Chris L.NinjaTrader Customer Service

        Comment


          #5
          Ok, thank you, will check it out, found also the TRACE option which is very useful.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by algospoke, 04-17-2024, 06:40 PM
          6 responses
          49 views
          0 likes
          Last Post algospoke  
          Started by arvidvanstaey, Today, 02:19 PM
          4 responses
          11 views
          0 likes
          Last Post arvidvanstaey  
          Started by samish18, 04-17-2024, 08:57 AM
          16 responses
          61 views
          0 likes
          Last Post samish18  
          Started by jordanq2, Today, 03:10 PM
          2 responses
          11 views
          0 likes
          Last Post jordanq2  
          Started by traderqz, Today, 12:06 AM
          10 responses
          21 views
          0 likes
          Last Post traderqz  
          Working...
          X