Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Simultaneous orders

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

    Simultaneous orders

    I am trying to place a simultaneous buy and sell order, but it is ignoring the second order. My code looks like this. Am I doing something wrong?

    Code:
    LE=EnterLongStop(lprice,"LE");
    SE=EnterShortStop(sprice,"SE");

    #2
    You cannot place simultaneous orders in the opposite direction for the same instrument. Please use TraceOrders = true to see reasons for why your orders are rejected or ignored.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I was about to ask the same question... how is it if you don't have an ATM selected in chart trader that you can have both a Long Stop order and a Short Stop order active. You can also have 2 separate strategies active - one placing a Long Stop order and the other placing a Short Stop order.

      I'm not nit picking deliberately - I would genuinely like to have a Longstop and shortstop order active at the same time from within the same strategy -- when one gets filled the other gets cancelled.

      If one strategy fills an order can another active strategy on the same instrument see that it has been filled ?

      Comment


        #4
        Chart Trader is different. Each group of orders are managed independently of each other. From a single NinjaScript strategy you cannot place simultaneous entry orders in opposite directions for the same instrument. If you read the TraceOrders output when you try to do this it will tell you to review the Internal Order Handling Rules.

        You can review them here: http://www.ninjatrader-support.com/H...verview36.html

        Cross-strategy communication is not supported.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Josh View Post

          Cross-strategy communication is not supported.
          Quick response - thanks. Had a quick read of the link.

          Can a strategy tell if an instrument has got an active order OR if there is a position in the market ?

          My requirement is very simple - have a longstop strategy and a shortstop strategy - if one gets filled the other cancels itself when it sees that there is a position in the market.

          Comment


            #6
            Unfortunately, no, a strategy only knows what is calculated based off of the strategy. What you want to do requires cross-strategy communication. It is possible through more advanced C#. You can search the forums for other users who have tried, but this is an endeavor we cannot offer you any support on.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Before I try it - Is it possible to call up 2 ATM Strategies from within a single strategy -- one to "buy" and one to "sell" - when one is filled cancel the other.

              Clutching at straws I guess

              Comment


                #8
                Yes you can. Keep them separate with their own IDs.
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Excellent - I'll have a play. Thanks for the great support.

                  Comment


                    #10
                    Originally posted by scottyboy View Post
                    ...If one strategy fills an order can another active strategy on the same instrument see that it has been filled ?...
                    scottyboy,

                    Cross-strategy communication could be achieved by implementing static data members/methods in the strategy class or designing a strategy base class containing the static data. When multiple strategies are instantiated, they all share the static elements.

                    Regards
                    Ralph

                    Comment


                      #11
                      Thanks Ralph - I will have to look into that but I suspect it's going to make me scratch my head a bit. I found a post that shows how to call up StreamWriter and create a text file -- this quick and dirty method will allow me to easily flag up what the other strategy is doing.



                      If you get a quiet moment in the next few days I would appreciate you pointing me in the right direction with...

                      implementing static data members/methods in the strategy class or designing a strategy base class containing the static data.


                      Off to bed for me - getting very late.

                      Comment


                        #12
                        Hi scottyboy,

                        in reference to the link you mentioned, here is an example how to code a similar concept with a static data flag:

                        Define a static strategy variable:

                        private static longPosFlag;

                        If your entry conditions are met:

                        if (!longPosFlag) {
                        EnterLong...
                        longPosFlag = true;
                        }

                        If your exit conditions are met:

                        ExitLong...
                        longPosFlag = false;

                        Regards
                        Ralph

                        Comment


                          #13
                          Hello Ralph, I tried this but when I ran the same strategy twice longPosFlag did not seem to be affected by the value in the other strategy.

                          I had to use private static bool longPosFlag;

                          I put it in #region Variables

                          I suspect I have mis-understood what you intended.

                          Thanks for your help with this.

                          Comment


                            #14
                            What you did is correct scottyboy. It is a typo, and I am too ment a static boolean variable. I am not sure what the default type for a variable is, if the type is not declared and if the compiler accepts that (perhaps an int?).

                            Regards
                            Ralph

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                            0 responses
                            558 views
                            0 likes
                            Last Post Geovanny Suaza  
                            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                            0 responses
                            324 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by Mindset, 02-09-2026, 11:44 AM
                            0 responses
                            101 views
                            0 likes
                            Last Post Mindset
                            by Mindset
                             
                            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                            0 responses
                            545 views
                            1 like
                            Last Post Geovanny Suaza  
                            Started by RFrosty, 01-28-2026, 06:49 PM
                            0 responses
                            547 views
                            1 like
                            Last Post RFrosty
                            by RFrosty
                             
                            Working...
                            X