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

Mkt order w/ attached stop

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

    Mkt order w/ attached stop

    I recently tested a strategy that when a MA is crossed It enters a buy order and if the price goes down to prior day's indicator level it "exits long". The strategy itself is a loser but it dawned on me, if say my machine crashes during the day would it not be better to place a protective stop as soon as my mkt entry order was filled. At least it seems more secure then to fire a mkt exit order if the condition is met? I know zero about coding at this point, I just can't get NT place a protective stop the second I enter the market?

    Thanks

    #2
    Hello,

    Yes, you may want to do that to protect yourself if you have any outages.
    DenNinjaTrader Customer Service

    Comment


      #3
      Thanks Ben for confirming that a protective stop should be entered. Can you please explain how I would get NT to submit a protective stop to Interactive brokers along with the mkt entry order? the stop would be based on a fixed level based on indicator result from yesterday. ex. buy mkt. when indicator A&B cross = $25.5 with protective stop based on indicator value from yesterday= $23...Thanks

      Comment


        #4
        Hello,

        You can place a working order with EnterLongLimit(), EnterLongStopLimit(), etc. or you can place the order with AtmStrategyCreate(). You can find all of these on this list:
        DenNinjaTrader Customer Service

        Comment


          #5
          Hello Again Ben,

          Sorry to re-ask the question, however re-directing me to the NT help guide is not achieving what I hoped for. I am new to this program and have zero experience programming, which I do plan on learning @ some point. My time during the day like many is to trade and in hopes of making it more efficient.

          I was able to develop a few systems using the pre built sytem writer, which as advertised prevents the need to program for simple traders like myself. in order to go live, I wanted to simply put a protective stop @ a fixed price based off an indicator value from yesterday. I have read the help guide and have tinkered with the system writer, however I cannot get this to work correctly? Thanks

          Comment


            #6
            rightcoast,

            As your condition you want to put in your market position. If you are long, do something. Or if you are short, do something else.

            The something you want to do as an action is add your protective stop. To do this you want to select ExitLongStop or ExitShortStop from the Order Management section. Then you just need to set the stop value to whatever you want.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Josh,

              Thanks for your response, at least I know I have been tinkering in the correct area. In "set 1" My conditions are set fine, my actions are to "EnterLong(DefaultQuantity."") works fine

              In "set 2" I'm trying "strategy" tab, long....doesn't work?

              What your describing makes perfect sense, however when I try to tell condition builder "hey, when im long send a protective sellstop.

              I even tried to add this to "Set 1" after my entry conditons and actions were met but that screws up the whole thing?

              Thanks

              Comment


                #8
                You want this in Set 2. Please see my screenshot of what the Condition Builder should be like.
                Attached Files
                Josh P.NinjaTrader Customer Service

                Comment


                  #9
                  Josh,

                  Understood, it simply was not replicating what I was choosing, to the bottom window. Now however when I backtest the results are all screwed up? some securities do 1 trade others do 100 trades. In order to go from testing to actual auto trading is it correct to:

                  1. backtest: "I buy" when price reaches a level and I exit @ a level.=results

                  2. Real world: "I buy" when price reaches a level, mkt. order but in order to protect from a bad situation, we go through the following steps to create a "real stop" order @ the level tested, that is sent immediately after were in a position

                  So overall we have 1 strategy that we can test and another strategy that should in theory be the same however it's functions are adjusted to trade in the real world. Not sure if this is what others do?

                  Thanks
                  Last edited by rightcoast; 02-02-2009, 12:29 PM.

                  Comment


                    #10
                    rightcoast,

                    For sure you can proceed in that manner. Backtesting is just one possible result in a whole list of possibilities. You can also forward test for another possibility, but at the end of the day any form of testing will not portray real-time conditions 100% and you should take their performance and results always with a grain of salt.
                    Josh P.NinjaTrader Customer Service

                    Comment


                      #11
                      Josh,

                      Sorry but Im getting a bit confused as to why I cant simply replicate something I created from a backtest.

                      Backtest: (Set 1 Conditions and actions) when XYZ crosess "Point A" Do the following:EnterLong(DefaultQuantity."")
                      (Set 2) if XYZ goes below "Point B".. Do the following: ExitLong(""."")

                      Real World: (Set 2) MarketPosition.Long == Position.MarketPosition
                      Do the following: ExitLongStop(my indicator)"Point B"

                      Real world I just watched on sim mode w/IB all it does is take entries, Some from several days ago and I specify to exit @ close?
                      If I backtest real world it does the same thing and ignores stop level and
                      out of the 10securities tested only 5 come back with results.
                      Last edited by rightcoast; 02-02-2009, 02:45 PM.

                      Comment


                        #12
                        rightcoast,

                        Backtesting is NEVER an accurate representation of real-time conditions.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          rightcoast,

                          Again, backtesting is never an accurate representation of real-time conditions. Please review the link posted earlier. It is imperative you understand these differences.

                          Backtesting provides you only a snapshot picture of one possibility of what your strategy can do. This possibility is almost guaranteed not to happen exactly as seen in testing during real-time.

                          Finally, if you want real-time results to even remotely resemble the results of backtesting, keep the code the same. You are completely changing your conditions. If you change your conditions you change your strategy. You change your strategy you change everything. You cannot expect it to produce even vaguely related results when you do this.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            Hello Josh,

                            I apologize for slamming you yesterday. I totally understand that a backtest is not going to be the same in real life. The problem is that if a backtest generates 100 trades and changing the exit logic from exit @ this indicator, to submit a stop @ that indicator, which generates 1 trade over the same period; something is not working. Obviously slippage and the unknown future cannot be known. The one trade instruments in this case, enter day one, ignore exit stops and do not exit @ close of each session.

                            As an example if i enter today mkt long@ 12:00 and instruct to place a long exit stop @ current session open, it works fine. If I substitute current session open with, prior session open, it ignores all stops and generates only the one trade. Seems like using a stop exit based on a prior day indicator level, in this case prior open, which is pre-built parameter in NT generates trades in some stocks =100 and 1 in others both of which are over a 3month period.
                            Thanks

                            Comment


                              #15
                              If you feel your stop orders are not going in you will need to debug them. The most common case scenario when using indicators to place stops is that you end up placing invalid stop prices. These stops are ignored/rejected.

                              Please see this tip on debugging your orders with TraceOrders = true. http://www.ninjatrader-support2.com/...ead.php?t=3627
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by rocketman7, Today, 02:12 AM
                              7 responses
                              30 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by guillembm, Yesterday, 11:25 AM
                              3 responses
                              16 views
                              0 likes
                              Last Post NinjaTrader_Jesse  
                              Started by junkone, 04-21-2024, 07:17 AM
                              10 responses
                              149 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by tsantospinto, 04-12-2024, 07:04 PM
                              6 responses
                              101 views
                              0 likes
                              Last Post tsantospinto  
                              Started by trilliantrader, 04-18-2024, 08:16 AM
                              7 responses
                              28 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Working...
                              X