Announcement

Collapse
No announcement yet.

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 pdennis, Today, 07:43 AM
          1 response
          5 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by NinjaTrader_Brandon, Today, 07:49 AM
          0 responses
          7 views
          0 likes
          Last Post NinjaTrader_Brandon  
          Started by b16_aln, Today, 05:15 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by Negustrader, Today, 01:01 AM
          1 response
          16 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Started by soon123, Yesterday, 10:50 PM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_ChrisL  
          Working...
          X