Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Commissions - Enter once, exit twice

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

    Commissions - Enter once, exit twice

    Ninja,

    I'm trying to replicate the way ATM handles orders though a NinjaScript Strategy. The reason that I am just not using ATM is because I need to dynamically modify my share quantity. That said, I am having trouble figuring out a way that I can do it without doubling the commission that I incur upon my entry.

    Here's my problem:
    When I enter an order with ATM to buy 100 shares then set two profit targets (each for 50 shares). The 100 share order is treated as a single order (thus one commission). Unfotunately, when I try to replicate this in NinjaScript, I find that since I can only specify the fromEntrySignal name in SetProfitTarget(), I must enter my 100 shares in two orders of 50 shares in order to set the two profit targets.... thus generating 2 commissions, instead of the 1 when using the ATM. If I could specify the number of shares at the Profit Target then I could do it, but that is not available.

    Scenario 1: Two entries: (Is this the only way?)

    EnterLong(50, 32.50, "LongEntry1");
    SetProfitTarget("LongEntry1",CalculationMode.Price , 34)
    EnterLong(50, 32.50, "LongEntry2");
    SetProfitTarget("LongEntry2",CalculationMode.Price , 40)

    Scenario 2: Single entry: (I know this won't work, as is, but is there another way to enter once, but exit twice?)

    EnterLong(100, 32.50, "LongEntry1");
    SetProfitTarget("LongEntry1",CalculationMode.Price , 34) //Exit 50 shares
    SetProfitTarget("LongEntry1",CalculationMode.Price , 34) //Exit remaining 50 shares

    Is there some way that I can do this? Otherwise, for EACH profit target I wish to have, I must enter the position as a separate order? From a commission standpoint, that can be very costly (i.e., effectively doubling ones commissions). Please tell me that there is a way to "Enter once, but exit twice" using NinjaScript.

    Thanks.

    fosch
    Last edited by fosch; 12-02-2010, 02:46 PM. Reason: more info...

    #2
    Hello fosch,

    Unfortunately no way around this in a managed strategy. In order to scale in or out, you must use separate signal names which will submit separate orders.

    You could use an unmanaged strategy and submit the orders exactly the way you want.
    Ryan M.NinjaTrader Customer Service

    Comment


      #3
      Thanks Ryan. I'm looking into the unmanaged approach through the help guide, but I am not finding a lot that details the approach.

      For instance, when I use the SubmitOrder() method to enter my order, how and where would I put my code to enter a stop loss & profit target? Would I simply use the SubmitOrder() method twice (once for my stop loss order and once for my profit target order) and tie them together with the OCO id?

      If so, then where would this code go? In the OnBarUpdate() method or some other method?

      fosch

      Comment


        #4
        Right - Set statements can't be used here so they would have to be manually expressed with SubmitOrder()

        Correct, these orders can be tied together with OCO.

        You can use OnBarUpdate() to submit orders. For a little more control you can submit in other methods. This sample details this approach, of course switching the Set statements to SubmitOrder().

        Using OnOrderUpdate() and OnExecution() methods to submit protective orders
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Thanks Ryan, This is very helpful.

          A related question on losing a connection...

          When using ATM strategies, if I place an stop order to buy (with the ATM portion holding my profit target and stop limit), and then I lose my connection to the broker or internet, I am left with an buy stop order that is sitting at the exchange (I use Interactive Brokers) without a profit target or stop order since they have not been sent yet. Is that correct?

          Then, if the connection is restored, will my ATM start up right where it left off (whether I have already been filled on that open order or not)? Or does the ATM strategy "turn off" once a connection is lost?

          fosch

          Comment


            #6
            The ATM strategy won't be active if NinjaTrader doesn't receive the proper fill event for the entry order. In this case you would want to manage your position manually.
            Ryan M.NinjaTrader Customer Service

            Comment


              #7
              Ok. But what about my second point... what if the connection is then reestablished (like 10 seconds later)? Then would the strategy pick up where it left off?

              Comment


                #8
                I'm not sure what happens in this case. I'll check into this scenario tomorrow and update this thread.
                Ryan M.NinjaTrader Customer Service

                Comment


                  #9
                  Ok. Thanks!

                  Comment


                    #10
                    Ryan,

                    Back to the original intent of this thread, figuring out how I can enter an order once in NinjaScript and then exit with multiple stop stops and profit targets.

                    I just went through the code you sent me regarding the OnOrderUpdate() method. Correct me if I am wrong (and I think I must be wrong), but it appears that I could just use the concepts in this strategy (a managed approach) to acheive my original goal?

                    I would place my EnterLong() order in OnBarUpdate(). Then I would place my stop-loss and targets in OnExecution() using the ExitLongStop() and ExitLongLimit() methods. My original dilemma dealt with the fact that the SetStopLoss() and SetProfitTarget() methods did not take a quantity as an argument, but that is not the case with teh ExitLongStop() and ExitLongLimit() methods (as they both take quantity arguements). Wouldn't this appraoch suffice?

                    Here are my potential code snippets:

                    OnBarUpdate()
                    ...
                    // Enter opening order
                    longEntry = EnterLong(100, "MyEntry");
                    ...

                    OnExecution()
                    ...
                    //Enter stops
                    stopOrder1 = ExitLongStop(0, true, 50, Low[0], "MyStop1", "MyEntry");
                    stopOrder2 = ExitLongStop(0, true, 50, Low[0] - 0.05, "MyStop2", "MyEntry");

                    //Enter targets
                    limitOrder1 = ExitLongLimit(0, ture, 50, High[0] + 0.25, "MyLimit1", "MyEntry");
                    limitOrder2 = ExitLongLimit(0, ture, 50, High[0] + 0.50, "MyLimit2", "MyEntry");
                    ...

                    Seems like this would work? No? But I think there may be a problem with the fact that the stop and limit orders are not tied together with an OCO?

                    Does the fact that each of the 4 orders I have placed in the OnExecution() method explicitly reference the "MyEntry" order mean that upon ANY of these orders being executed that the rest would be automatically cancelled?

                    I'm almost there....

                    Thanks.
                    fosch

                    Comment


                      #11
                      If you're working from a managed order system and want to scale out, you must first scale in. If you want two separate exits, your entry orders must be two separate statements with unique signal names.
                      Ryan M.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_RyanM View Post
                        I'm not sure what happens in this case. I'll check into this scenario tomorrow and update this thread.
                        Hey Ryan,

                        Were you able to get some more information on this...

                        Thanks.
                        fosch

                        Comment


                          #13
                          I will look at this in the afternoon today before market closes. Thank you for your patience.
                          Ryan M.NinjaTrader Customer Service

                          Comment


                            #14
                            The ATM strategy will not be able to manage this position, if the fill takes place outside of NinjaTrader. NinjaTrader needs to receive the fill event when it happens for the ATM strategy to manage your position.
                            Ryan M.NinjaTrader Customer Service

                            Comment


                              #15
                              Radon share size in strategy

                              I'm getting odd results from my unmanaged strategy when entering orders. I'm using NT 7 64-bit, and running it against live data in SIM account.

                              Essentially, I'm submitting my order in OnBarUpdate() and then placing my stops in OnExecution(). When the orders are being placed the share size is random? For instance, if I place an order for 150 shares, upon execution, a profit target and stop loss OCO orders are place for 250 shares? I'm using execution.Order.Filled as my parameter for Quantity in SubmitOrder()?

                              What might be going on here?

                              fosch
                              Last edited by fosch; 12-07-2010, 10:15 AM. Reason: typo

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              650 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              370 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              109 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              574 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              577 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X