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

Place Buy order and Sell order at same time.

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

    #31
    Great! Back to 6.5. Is is possible to do it with multiple orders with Ninja Script ATM Strategy?

    This isn't working, it only submits one order:

    AtmStrategyCreate(Action.Buy, OrderType.Limit, Reference -2, 0, TimeInForce.Day, orderId, "ESScalpATM1", atmStrategyId);
    AtmStrategyCreate(Action.Buy, OrderType.Limit, Reference -4, 0, TimeInForce.Day, orderId, "ESScalpATM2", atmStrategyId);

    Comment


      #32
      It should be possible to do multiple orders with ATM strategies. To figure out why that code isn't working, I suggest setting TraceOrders = true. There is a great post by Josh that explains how TraceOrders can help you.
      AustinNinjaTrader Customer Service

      Comment


        #33
        Okay... what is it telling me? :-)

        See attached...
        Attached Files

        Comment


          #34
          I think this might have something to do with it:

          2009-08-07 15:15:03:013 ERROR: AtmStrategyId parameter 'dbadaa4676d4431fb051eaf7d35e121e' already used

          Comment


            #35
            Originally posted by heyligerb View Post
            I think this might have something to do with it:

            2009-08-07 15:15:03:013 ERROR: AtmStrategyId parameter 'dbadaa4676d4431fb051eaf7d35e121e' already used
            I think that might have something to do with it as well. You need a new AtmStrategyId for every ATM strategy order you place. There is a function named GetAtmStrategyUniqueId() that will generate an ID value for you.
            AustinNinjaTrader Customer Service

            Comment


              #36
              Yea... tried that too.

              if (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] > Open[0])
              {
              atmStrategyId = GetAtmStrategyUniqueId();
              orderId = GetAtmStrategyUniqueId();
              AtmStrategyCreate(Action.Buy, OrderType.Limit, 940, 0, TimeInForce.Day, orderId, "ESScalpATM1", atmStrategyId);;
              }

              if (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] > Open[0])
              {
              atmStrategyId = GetAtmStrategyUniqueId();
              orderId = GetAtmStrategyUniqueId();
              AtmStrategyCreate(Action.Buy, OrderType.Limit, 940, 0, TimeInForce.Day, orderId, "ESScalpATM2", atmStrategyId);
              }




              Same thing. Only one order. This time no error in the trace.

              Comment


                #37
                Hold that thought.... a little trial an error never hurt anyone! Got it:

                if (orderId.Length == 0 && atmStrategyId.Length == 0 && Close[0] > Open[0])
                {
                atmStrategyId = GetAtmStrategyUniqueId();
                orderId = GetAtmStrategyUniqueId();
                AtmStrategyCreate(Action.Buy, OrderType.Limit, 940, 0, TimeInForce.Day, orderId, "ESScalpATM1", atmStrategyId);;

                atmStrategyId = GetAtmStrategyUniqueId();
                orderId = GetAtmStrategyUniqueId();
                AtmStrategyCreate(Action.Buy, OrderType.Limit, 940, 0, TimeInForce.Day, orderId, "ESScalpATM2", atmStrategyId);
                }

                Comment


                  #38
                  Can you copy + paste the text from the output window and not the actual trace files?

                  TraceOrders prints information to the output window, not to the trace file.
                  AustinNinjaTrader Customer Service

                  Comment


                    #39
                    no need... got it working.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by terofs, Yesterday, 04:18 PM
                    1 response
                    21 views
                    0 likes
                    Last Post terofs
                    by terofs
                     
                    Started by CommonWhale, Today, 09:55 AM
                    1 response
                    3 views
                    0 likes
                    Last Post NinjaTrader_Erick  
                    Started by Gerik, Today, 09:40 AM
                    2 responses
                    7 views
                    0 likes
                    Last Post Gerik
                    by Gerik
                     
                    Started by RookieTrader, Today, 09:37 AM
                    2 responses
                    12 views
                    0 likes
                    Last Post RookieTrader  
                    Started by alifarahani, Today, 09:40 AM
                    1 response
                    7 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Working...
                    X