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

There seems to be two ways of doing order protection

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

    There seems to be two ways of doing order protection

    There is the SetStopLoss and SetProfitTarget, which are sort of the easy way as I see it. Then as the sample shows there is the advanced way by using OnExecution and handling it yourself.

    Would it be fair to say the most advanced implementations would use OnExecution?

    My questions is if that's true, I take it you'd also have to handle scaling on your own in that event as well since the sample that shows scaling makes use of SetStopLoss, SetProfitTarget and SetTrailingStop().

    #2
    Correct. If you opt for using IOrders to manage your trade you will basically want to manual everything. It allows you the most flexibility in how you want to trade, but requires much more coding. If you feel the Set() methods provide enough functionality for your strategy then I would recommend just using those and save yourself the headache from the added complexity of IOrders.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Josh View Post
      Correct. If you opt for using IOrders to manage your trade you will basically want to manual everything. It allows you the most flexibility in how you want to trade, but requires much more coding. If you feel the Set() methods provide enough functionality for your strategy then I would recommend just using those and save yourself the headache from the added complexity of IOrders.
      So can the order protection sample be converted to do the same thing with the helper functions? Or will I need to do it manually? Like the breakeven, that is possible with the helper functions, I think you would just handle OnExecution, like in the sample?

      Comment


        #4
        It is up to you which method you wish to use. You can still do things like breakeven with Set() methods as demonstrated in this reference: http://www.ninjatrader-support.com/v...ead.php?t=3222

        The OnOrderUpdate()/OnExecution() example is there just to show you some basic functionality. I believe it can be done with Set() also. The purpose of the OnOrderUpdate() and other advanced methods is for people who wish to control their orders in different ways.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Josh View Post
          It is up to you which method you wish to use. You can still do things like breakeven with Set() methods as demonstrated in this reference: http://www.ninjatrader-support.com/v...ead.php?t=3222

          The OnOrderUpdate()/OnExecution() example is there just to show you some basic functionality. I believe it can be done with Set() also. The purpose of the OnOrderUpdate() and other advanced methods is for people who wish to control their orders in different ways.
          So basically I guess you can still use those events, but with the Set() methods to make it easier. Sounds good. Thx.

          Comment


            #6
            Right. Just keep in mind that Set() do not produce IOrder objects.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Josh,

              Does this hold true if you want to use limit orders for entry?

              From what I can tell, you can't combine the two. So is it fair to say that if you use the "set" methods, that you have to use all "set" methods for order handling in order to avoid issues.

              Also, can you use the "set" methods and avoid having your order updated on each bar update / tick?

              I couldn't seem to find a way to "fix" the order in place without advanced order handling (which does get complicated pretty fast if you don't code for a living, lol).

              So if you have a condition that tests for currentBid() > than close[1], get long but fade it by 5 ticks, and you want to keep the original order in place and not have it auto-update on each bar tick, or bar close, do you use the set methods, or advanced?

              UPDATE:
              As I think about it, I supposed I could use a bool or something to say whether or not the condition was met, that would avoid the bar update changing my order I suppose.

              I guess I am just trying to understand if I can accomplish the same things with less code.

              Thanks,
              Last edited by r2kTrader; 06-28-2009, 04:32 PM.

              Comment


                #8
                Hello,

                I will have Josh reply on Monday.
                DenNinjaTrader Customer Service

                Comment


                  #9
                  r2kTrader,

                  The bool would be the route I would take. Set() method will update every tick if it is called every tick, otherwise it will use whatever it was originally called as.
                  Josh P.NinjaTrader Customer Service

                  Comment


                    #10
                    Originally posted by NinjaTrader_Josh View Post
                    r2kTrader,

                    The bool would be the route I would take. Set() method will update every tick if it is called every tick, otherwise it will use whatever it was originally called as.
                    But then I can't use Limit orders, correct?

                    If I simulate a limit order, it could cause me to lag a bit.

                    Example:

                    If I want a long below 1000.00, say 999.00

                    psuedo code:
                    If signal is met, and GetCurrentBid() is < 999.00, then EnterLong().

                    But this leaves room for errors of course due to the fact I am still firing a market order.

                    Also, I can't seem to "label" the exits so I can decipher which SetStopLoss it was that took me out of the trade.

                    ---
                    I am starting to work with the Advanced Order Handling, and it's a brain twister, but does offer real granular control, very simlar to what I would do manually. Is there are graphic flow chart of any kind showing the ideal flow to follow for proper order management? A visual flow chart of some kind would be extrememly helpful for the left-brain impared


                    Thank you for the prompt reply,

                    Comment


                      #11
                      r2kTrader,

                      I am not sure what your concern is between an EnterLong() market order versus a Set(). Set() can't get you into a position so I am not sure how this is related to simulating limit orders.

                      You can't give Set() methods exit names because you can't have multiple SetStopLoss() working simultaneously on the same entry order.

                      Unfortunately there is no flowchart showing you the advanced order handling. There are reference samples you can take a look at for an idea of how things are done though.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_Josh View Post
                        r2kTrader,

                        I am not sure what your concern is between an EnterLong() market order versus a Set(). Set() can't get you into a position so I am not sure how this is related to simulating limit orders.

                        You can't give Set() methods exit names because you can't have multiple SetStopLoss() working simultaneously on the same entry order.

                        Unfortunately there is no flowchart showing you the advanced order handling. There are reference samples you can take a look at for an idea of how things are done though.
                        1. Is there any way to enter a trade with a limit order when using Set methods?

                        2. You answered my question regarding Set methods and labels. I supposed I could manually print something to the chart though when certain condition is met that fired trade, no? (but then I may as well consider advanced order handling, no?? lol)

                        Feels like I am splitting hairs, so here is my summary. Please tell me if correct or fairly correct.

                        1. If you want to use limit orders and "exit" labels, advanced order handling is the route to go. (I also like the idea of manually managing rejected orders, this way I could re-route the order if necessary or feasible).

                        2. If you just want simple order managment, and you want to focus more on the signals and don't care about labels or limit orders, then Set methods are the way to go.

                        While I can replicate some of what I can do with #2, it is possible only through some additional coding and tracking of bools, etc. perhaps?

                        Here are my objectives:

                        1. Upon signal firing, I want to take a position long with a limit order wit the label xyz (as an example).

                        2. I then want an immediate stop placed at a fixed value of some kind, which if hit, will reveal the "label or reason" as to what fired the exit. (Sold to exit xyz, etc.)

                        3. Upon 1 and 2, I then want to move my stop up to follow the trade if it goes my way (higher), and do so at the price of a certain value which I change as the trade goes. It might be a fixed amount of ticks, or it might be a price based on the close of a candle less some ticks, but it will be a dynamic value I decide on through logic as the trade develops.

                        4. I do not want my orders to cancel and update on each bar update, rather I want them to only change if new "conditions" are met which would in effect create new orders. Stop moves higher for example because profit increases.

                        5. I want all my trades to be profitable.


                        Those are my wants. What's the play. Advanced or Set Methods?


                        Thank you again Josh for the quick reply, it's helping me get the most of my morning.


                        Best regards,

                        Comment


                          #13
                          1. No. Set methods do not do entries. They only can do exits.

                          2. It is up to you which one you want to use. You can for sure print something on the chart.

                          1. You don't necessarily need to take it up all the way to advanced order handling to use labels. You can still use labels with normal ExitLongLimit() etc methods.

                          2. Set methods are designed for convenience. If you have complex logic please use the advanced order handling.

                          Use advanced order handling.
                          Josh P.NinjaTrader Customer Service

                          Comment


                            #14
                            Originally posted by NinjaTrader_Josh View Post
                            1. No. Set methods do not do entries. They only can do exits.

                            2. It is up to you which one you want to use. You can for sure print something on the chart.

                            1. You don't necessarily need to take it up all the way to advanced order handling to use labels. You can still use labels with normal ExitLongLimit() etc methods.

                            2. Set methods are designed for convenience. If you have complex logic please use the advanced order handling.

                            Use advanced order handling.
                            Josh,

                            Regarding your first reply. I understand Set Methods won't put you in a trade. I clearly understand that. But if you use Set Methods, you cannot use EnterLongLimit orders, correct? That was my point regarding entries. The fact that if you use Set Methods, you can't use Limit orders elsewhere in your strategy, no?

                            Regarding the first reply to 2., by the time I plot labels to charts and track a bool, I'm almost doing my own version of Advanced Order Handling, no? With all things being equal, is AOH the play? Based on your prior post, I am understanding yes.

                            Comment


                              #15
                              Only in very specific scenarios will Set methods prevent limit orders.

                              "Methods that generate orders (excluding market orders) to enter a position will be ignored if:
                              • A position is open and an order submitted by a set method (SetStopLoss() for example) is active and the order is used to open a position in the opposite direction"
                              Advanced order handling will allow you the flexibility you are looking for so yes.
                              Josh P.NinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by maybeimnotrader, Today, 05:46 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post maybeimnotrader  
                              Started by quantismo, Today, 05:13 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post quantismo  
                              Started by AttiM, 02-14-2024, 05:20 PM
                              8 responses
                              166 views
                              0 likes
                              Last Post jeronymite  
                              Started by cre8able, Today, 04:22 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post cre8able  
                              Started by RichStudent, Today, 04:21 PM
                              0 responses
                              5 views
                              0 likes
                              Last Post RichStudent  
                              Working...
                              X