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

MACrossOver using EntryLimit Orders, Targets and Stops

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

    MACrossOver using EntryLimit Orders, Targets and Stops

    Do you have a sample MACrossover strategy somewhere using entry limit orders, not market orders, with profit targets and stoploss. Since NT ignores limit orders when there are working profit and stop orders I'm not quite getting the use of IOrders to solve this problem.
    Thanks

    #2
    Hi kenb2004,

    I'm not aware of example that offers this. You may consider explaining your strategy requirements to a NinjaScript consultant, and hiring one to code for you:
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Since this is such a basic simple moving average crossover I thought that NT would want to show how easy it is to use limit orders instead of market orders when using profit and stop orders. It would also give NT an opportunity to show how IOrders are used in this context, since there are very few examples on your site showing the use of IOrders.

      Comment


        #4
        Thanks for the feedback, Ken. There are a couple samples that use IOrders and they're also documented on all the pages that use them:
        The OnOrderUpdate() and OnExecution() methods are reserved for experienced programmers. Instead of using Set() methods to submit stop-loss and profit target orders, you can submit and update them manually through the use of IOrder and IExecution objects in the OnOrderUpdate() and OnExecution() methods. The OnOrderUpdate()

        When using NinjaTrader's Enter() and Exit() methods, the default behavior is to automatically expire them at the end of a bar unless they are resubmitted to keep them alive. Sometimes you may want more flexibility in this behavior and wish to submit orders as live-until-cancelled. When orders are submitted as live-until


        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Is there a list of sample strategies somewhere on your website? I know there is a SampleMACrossover strategy that comes with NT, how about Josh writing one demonstrating the use of limit order entries, profits and stops and the use of IOrders? It's the next step in the learning process. I need to do this on my own, not hire someone, but I need examples of how NT wants limit orders to be handled and not ignored.

          Comment


            #6
            The available strategy samples we have are here:
            Following are links to all available NinjaScript reference samples within this forum section: Strategy Reference Samples (NinjaTrader 8) - also applicable to NT7 Using a time filter to limit trading hours (http://www.ninjatrader.com/support/forum/showthread.php?t=3226) Using multiple entry/exit signals simultaneously
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Ryan
              Since NT's internal order handling is what is preventing limit order entries with profits and stops from working and being ignored instead, could you please ask Josh to writie a Sample demonstrating the use of limit order entries, profits and stops and the use of IOrders? I'm sure there are many traders using NinjaTrader who understand the value of limit orders vs market orders and would benefit greatly by this Sample.
              Thanks

              Comment


                #8
                I will forward your request. Thanks for the comments.

                If there's something you need coded right away a NinjaScript consultant can be hired to create the strategy to your specifications:
                Last edited by NinjaTrader_RyanM1; 06-23-2011, 01:32 PM.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  Ryan

                  I put together a MACrossover strategy using Limit entries, stop and profit targets as best I could using the bits and pieces of the SampleCancelOrder, SampleOnOrderUpdate, and LimitReversal strategies. It seems to be working OK but I just wanted to check with you to see if I had missed something or was handling the IOrder process correctly. It's too long to post so is there a way to attach it?
                  Thanks

                  Comment


                    #10
                    kenb2004,

                    You can export your NinjaScript through File > Utilities > Export NinjaScript and then attach the .zip file it makes to a forum post here.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      OK, thanks, here's the .zip
                      Attached Files

                      Comment


                        #12
                        kenb2004,

                        Only suggestion I would make is on your cross over condition to not submit your Enter() order from there. I would first wait for confirmed cancellation of your orders and then place the new entry order.

                        You can get confirmation on the cancel in OnOrderUpdate. After you receive both cancel confirmations or never needed to cancel any orders to begin with is when you should then place your new limit order.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Would this accomplish what you are saying?
                          if (selltarget == null && sellstop == null)
                          buyentry = EnterLongLimit(0, true, 1, Close[0] + TickSize * 1, "Buy_1");
                          thanks

                          Comment


                            #14
                            You probably need an additional bool tracking the state of the cross over. When the cross over occurs, set bool to true. Then outside of the cross over if-statement, put an if-statement for the bool. If it is true and your order cancellations have successfully came back, then you can place your entry order. Once the entry order is placed, reset the bool to false.
                            Josh P.NinjaTrader Customer Service

                            Comment


                              #15
                              "put an if-statement for the bool" where? In the OnOrderUpdate section at the end of the selltarget and sellstop blocks?

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by gbourque, Today, 06:39 AM
                              0 responses
                              2 views
                              0 likes
                              Last Post gbourque  
                              Started by cmtjoancolmenero, Yesterday, 03:58 PM
                              1 response
                              17 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by benmarkal, Yesterday, 12:52 PM
                              3 responses
                              23 views
                              0 likes
                              Last Post NinjaTrader_Gaby  
                              Started by helpwanted, Today, 03:06 AM
                              1 response
                              20 views
                              0 likes
                              Last Post sarafuenonly123  
                              Started by Brevo, Today, 01:45 AM
                              0 responses
                              12 views
                              0 likes
                              Last Post Brevo
                              by Brevo
                               
                              Working...
                              X