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

2 entry orders help!

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

    Hello bobperez,

    In the UnmanagedOCOBracketExample_NT8 note I've used OrderType.StopMarket orders.
    A buy stop order would be placed above the ask, a sell stop order would be placed below the bid.

    In this code you have chosen to use OrderType.Limit which are placed on the reverse side of the market.
    A buy limit would be placed below the ask, a sell limit would be placed above the bid.

    I see in your code you've submitted the buy limit at the High of the most recently closed bar and the sell limit at the Low of the most recently closed bar. These orders will most likely be on the wrong side of the market when the new bar opens.
    With some brokerages that order will be immediately filled (including NinjaTrader), with other brokerages that order would be rejected (such as Forex brokerages).

    Also, orders should be assigned to variables in OnOrderUpdate() and not directly from the order method.

    I've changed is and tested the suggested code and I am finding this is working.

    Below is a link to a video of the test.

    BobperezTest_NT8.zip

    There are no exit orders or setting the variables back to null so it only places orders once, but this works as expected.
    Chelsea B.NinjaTrader Customer Service

    Comment


      Originally posted by NinjaTrader_ChelseaB View Post
      Hello bobperez,

      In the UnmanagedOCOBracketExample_NT8 note I've used OrderType.StopMarket orders.
      A buy stop order would be placed above the ask, a sell stop order would be placed below the bid.

      In this code you have chosen to use OrderType.Limit which are placed on the reverse side of the market.
      A buy limit would be placed below the ask, a sell limit would be placed above the bid.

      I see in your code you've submitted the buy limit at the High of the most recently closed bar and the sell limit at the Low of the most recently closed bar. These orders will most likely be on the wrong side of the market when the new bar opens.
      With some brokerages that order will be immediately filled (including NinjaTrader), with other brokerages that order would be rejected (such as Forex brokerages).

      Also, orders should be assigned to variables in OnOrderUpdate() and not directly from the order method.

      I've changed is and tested the suggested code and I am finding this is working.

      Below is a link to a video of the test.

      [ATTACH]n1295472[/ATTACH]

      There are no exit orders or setting the variables back to null so it only places orders once, but this works as expected.
      Hi Chelsa,

      Thank you so much for your continued support. I'll check the video and your suggestions and will let you know later my results.

      I've implemented your suggestions and they work perfectly. I've also changed the entry Limit orders for Stop Orders.

      Cheers!

      Bob Perez
      Last edited by bobperez; 03-13-2024, 11:41 AM.

      Comment


        Originally posted by NinjaTrader_ChelseaB View Post
        Hello bobperez,

        In the UnmanagedOCOBracketExample_NT8 note I've used OrderType.StopMarket orders.
        A buy stop order would be placed above the ask, a sell stop order would be placed below the bid.

        In this code you have chosen to use OrderType.Limit which are placed on the reverse side of the market.
        A buy limit would be placed below the ask, a sell limit would be placed above the bid.

        I see in your code you've submitted the buy limit at the High of the most recently closed bar and the sell limit at the Low of the most recently closed bar. These orders will most likely be on the wrong side of the market when the new bar opens.
        With some brokerages that order will be immediately filled (including NinjaTrader), with other brokerages that order would be rejected (such as Forex brokerages).

        Also, orders should be assigned to variables in OnOrderUpdate() and not directly from the order method.

        I've changed is and tested the suggested code and I am finding this is working.

        Below is a link to a video of the test.

        [ATTACH]n1295472[/ATTACH]

        There are no exit orders or setting the variables back to null so it only places orders once, but this works as expected.
        Hi Chelsea,

        If I want to enter the oco trades with 2 contracts instead of 1, and each contract with a different target, will I need to send one pair of orders for each contract separately?
        Last edited by bobperez; 03-15-2024, 10:37 AM.

        Comment


          Hello bobperez,

          Yes, this would be necessary to have independent OCO pairing. Use two entry orders with unique signal names and two exit orders with the from entry signals of those entries.
          Chelsea B.NinjaTrader Customer Service

          Comment


            Originally posted by NinjaTrader_ChelseaB View Post
            Hello bobperez,

            Yes, this would be necessary to have independent OCO pairing. Use two entry orders with unique signal names and two exit orders with the from entry signals of those entries.
            Ok, thank you, Chelsea.

            Comment


              Originally posted by NinjaTrader_ChelseaB View Post
              Hello bobperez,

              Yes, this would be necessary to have independent OCO pairing. Use two entry orders with unique signal names and two exit orders with the from entry signals of those entries.
              Hi Chelsea,

              I am getting the attached errors after a while Click image for larger version  Name:	F4.jpg Views:	19 Size:	107.7 KB ID:	1296087 .



              Is there anything missing?

              BobPerez
              Last edited by bobperez; 03-18-2024, 01:34 PM.

              Comment


                Hello bobperez,

                The message is stating there is no real-time data.

                Who are you connected to for data? (Do you see changing ask and bid prices in Chart Trader?)

                Are these orders being submitted during market hours?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  Originally posted by NinjaTrader_ChelseaB View Post
                  Hello bobperez,

                  The message is stating there is no real-time data.

                  Who are you connected to for data? (Do you see changing ask and bid prices in Chart Trader?)

                  Are these orders being submitted during market hours?
                  HI Chelsea, During the weekend I was connected to Rithmic, as well as today. Today it worked fine.

                  Bob

                  Comment


                    Hello Bob,

                    During the weekend the markets are closed and there is no real-time data.

                    However the Trading hours template should have prevented any trades.
                    Do you have Trading hours set to 'use instrument settings' in the Data Series window?
                    What Start behavior is selected in the Strategies window?
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      Originally posted by NinjaTrader_ChelseaB View Post
                      Hello Bob,

                      During the weekend the markets are closed and there is no real-time data.

                      However the Trading hours template should have prevented any trades.
                      Do you have Trading hours set to 'use instrument settings' in the Data Series window?
                      What Start behavior is selected in the Strategies window?
                      'use instrument settings' I : Yes
                      Start behavior I: Waiting UntilFlat

                      Bob

                      Comment


                        Hello Bob,

                        With 'Wait until flat' and not 'Wait until flat synchronize account' and the exchange trading hours, I would not expect an order to be submitted while the market is closed.

                        If you would like me to investigate further, please send an email to scriptingsupport[at]ninjatrader[dot]com so that I may request your log and trace files.
                        In the email, please include a link to this forum thread.
                        Chelsea B.NinjaTrader Customer Service

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Haiasi, 04-25-2024, 06:53 PM
                        2 responses
                        17 views
                        0 likes
                        Last Post Massinisa  
                        Started by Creamers, Today, 05:32 AM
                        0 responses
                        5 views
                        0 likes
                        Last Post Creamers  
                        Started by Segwin, 05-07-2018, 02:15 PM
                        12 responses
                        1,786 views
                        0 likes
                        Last Post Leafcutter  
                        Started by poplagelu, Today, 05:00 AM
                        0 responses
                        3 views
                        0 likes
                        Last Post poplagelu  
                        Started by fx.practic, 10-15-2013, 12:53 AM
                        5 responses
                        5,408 views
                        0 likes
                        Last Post Bidder
                        by Bidder
                         
                        Working...
                        X